安装Hive

您所在的位置:网站首页 hive初始化不成功 安装Hive

安装Hive

2023-06-20 06:36| 来源: 网络整理| 查看: 265

安装Hive 准备

安装Java环境:Hive需要Java环境支持,所以需要先安装Java。安装文档:http://t.csdn.cn/deBJu

安装MySQL数据库。http://t.csdn.cn/d24pN

下载Hive

下载Hive的二进制文件。

链接:https://pan.baidu.com/s/1fdg76k9kvd896pMpfYEG5w 提取码:8888

解压Hive

将下载的Hive压缩包解压到指定目录。

[root@master ~]# cd /usr/local [root@master local]# ll 总用量 279464 -rw-r--r--. 1 root root 286170958 6月 7 11:18 apache-hive-2.3.9-bin.tar.gz drwxr-xr-x. 11 1000 1000 272 5月 25 08:49 hadoop-3.3.1 drwxr-xr-x. 8 10143 10143 273 4月 8 2021 jdk1.8.0_291 # 解压 [root@master local]# tar -zxvf apache-hive-2.3.9-bin.tar.gz [root@master local]# ll 总用量 279464 drwxr-xr-x. 10 root root 184 6月 7 11:22 apache-hive-2.3.9-bin -rw-r--r--. 1 root root 286170958 6月 7 11:18 apache-hive-2.3.9-bin.tar.gz drwxr-xr-x. 11 1000 1000 272 5月 25 08:49 hadoop-3.3.1 drwxr-xr-x. 8 10143 10143 273 4月 8 2021 jdk1.8.0_291 配置Hive环境变量

将Hive的bin目录添加到系统环境变量中。

[root@master local]# vi /etc/profile # Hive export HIVE_HOME=/usr/local/apache-hive-2.3.9-bin export PATH=$PATH:$HIVE_HOME/bin [root@master local]# source /etc/profile 配置Hive配置文件 [root@master conf]# vi hive-env.sh.template HADOOP_HOME=$HADOOP_HOME export HIVE_CONF_DIR=$HIVE_HOME/conf 配置hive-config.sh [root@master ~]# cd /usr/local/apache-hive-2.3.9-bin/bin [root@master bin]# vi hive-config.sh # 配置hive export JAVA_HOME=/usr/local/jdk1.8.0_291 export HIVE_HOME=/usr/local/apache-hive-2.3.9-bin export HADOOP_HOME=/usr/local/hadoop-3.3.1 export HIVE_CONF_DIR=/usr/local/apache-hive-2.3.9-bin/conf 拷贝Hive配置文件 [root@master ~]# cd /usr/local/apache-hive-2.3.9-bin/conf/ [root@master conf]# cp hive-default.xml.template hive-site.xml 配置hive-site.xml [root@master conf]# vi hive-site.xml

修改Hive的配置文件hive-site.xml,设置Hive的元数据存储方式、Hadoop的配置文件路径等。

javax.jdo.option.ConnectionURL jdbc:mysql://localhost:3306/hive?useUnicode=true;characterEncoding=utf8;useSSL=false;serverTimezone=UTC MYSQL连接协议 javax.jdo.option.ConnectionDriverName com.mysql.jdbc.Driver JDBC连接驱动 javax.jdo.option.ConnectionUserName root 用户名 javax.jdo.option.ConnectionPassword 123456 密码 datanucleus.schema.autoCreatAll true 自动更新数据库 hive.metastore.schema.verification false hive.exec.local.scratchdir /usr/local/apache-hive-2.3.9-bin/tmp/${user.name} Local scratch space for Hive jobs system:java.io.tmpdir /usr/local/apache-hive-2.3.9-bin/iotmp hive.downloaded.resources.dir /usr/local/apache-hive-2.3.9-bin/tmp/${hive.session.id}_resources Temporary local directory for added resources in the remote file system. hive.querylog.location /usr/local/apache-hive-2.3.9-bin/tmp/${system:user.name} Location of Hive run time structured log file hive.server2.logging.operation.log.location /usr/local/apache-hive-2.3.9-bin/tmp/${system:user.name}/operation_logs Top level directory where operation logs are stored if logging functionality is enabled hive.metastore.db.type mysql hive.cli.print.current.db true Whether to include the current database in the Hive prompt. hive.cli.print.header true Whether to print the names of the columns in query output.

将mysq-comnector-java-5.1.32.jar驱动包上传至bin目录下

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-Waog7K8k-1686895673588)(E:\Java笔记\大数据\Hadoop\Hive\安装Hive\安装Hive.assets\image-20230616140723463.png)]

初始化元数据库 [root@master ~]# schematool -dbType mysql -initSchema SLF4J: Class path contains multiple SLF4J bindings. SLF4J: Found binding in [jar:file:/usr/local/apache-hive-2.3.9-bin/lib/log4j-slf4j-impl-2.6.2.jar!/org/slf4j/impl/StaticLoggerBinder.class] SLF4J: Found binding in [jar:file:/usr/local/hadoop-3.3.1/share/hadoop/common/lib/slf4j-log4j12-1.7.30.jar!/org/slf4j/impl/StaticLoggerBinder.class] SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation. SLF4J: Actual binding is of type [org.apache.logging.slf4j.Log4jLoggerFactory] Metastore connection URL: jdbc:mysql://localhost:3306/hive?useUnicode=true&characterEncoding=utf8&useSSL=false&serverTimezone=UTC Metastore Connection Driver : com.mysql.jdbc.Driver Metastore connection User: root Starting metastore schema initialization to 2.3.0 Initialization script hive-schema-2.3.0.mysql.sql Initialization script completed schemaTool completed 启动Hive

在命令行中输入hive命令,启动Hive。

[root@master conf]# hdfs namenode -format [root@master conf]# start-dfs.sh [root@master conf]# start-yarn.sh [root@master conf]# hive which: no hbase in (/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/usr/local/jdk1.8.0_291/bin:/usr/local/jdk1.8.0_291/jre/bin:/usr/local/hadoop-3.3.1/bin:/usr/local/hadoop-3.3.1/sbin:/root/bin:/usr/local/jdk1.8.0_291/bin:/usr/local/jdk1.8.0_291/jre/bin:/usr/local/hadoop-3.3.1/bin:/usr/local/hadoop-3.3.1/sbin:/usr/local/apache-hive-2.3.9-bin/bin) SLF4J: Class path contains multiple SLF4J bindings. SLF4J: Found binding in [jar:file:/usr/local/apache-hive-2.3.9-bin/lib/log4j-slf4j-impl-2.6.2.jar!/org/slf4j/impl/StaticLoggerBinder.class] SLF4J: Found binding in [jar:file:/usr/local/hadoop-3.3.1/share/hadoop/common/lib/slf4j-log4j12-1.7.30.jar!/org/slf4j/impl/StaticLoggerBinder.class] SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation. SLF4J: Actual binding is of type [org.apache.logging.slf4j.Log4jLoggerFactory] Logging initialized using configuration in jar:file:/usr/local/apache-hive-2.3.9-bin/lib/hive-common-2.3.9.jar!/hive-log4j2.properties Async: true Hive-on-MR is deprecated in Hive 2 and may not be available in the future versions. Consider using a different execution engine (i.e. spark, tez) or using Hive 1.X releases. hive> 测试Hive:

在Hive命令行中输入一些Hive查询语句,测试Hive是否正常工作。

# 查看数据库 hive (default)> show databases; OK database_name default Time taken: 6.772 seconds, Fetched: 1 row(s) # 创建数据表 hive (default)> create table student( > id int > ); OK Time taken: 1.294 seconds # 查看数据表 hive (default)> show tables; OK tab_name student Time taken: 0.06 seconds, Fetched: 1 row(s)


【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3