为了方便操作Hive的服务端和客户端均安装在master节点上
下载地址:http://mirrors.hust.edu.cn/apache/hive/
上传并解压
1 #创建Hive目录 2 [root@master ~]# mkdir /opt/SoftWare/Hive 3 #进入到Hive目录 4 [root@master ~]# cd /opt/SoftWare/Hive 5 #通过xshell工具上传至master主机 6 [root@master Hive]# rz 7 #解压 8 [root@master Hive]# tar ‐zxvf apache‐hive‐2.3.2‐bin.tar.gz 9 #修改文件夹的名字 10 [root@master Hive]# mv apache‐hive‐2.3.2‐bin hive‐2.3.2
配置环境变量
1 #打开配置文件 2 [root@master Hive]# vi /etc/profile 3 #在后面追加以下内容 4 export HIVE_HOME=/opt/SoftWare/Hive/hive‐2.3.2 5 export PATH=$PATH:$HIVE_HOME/bin 6 #使设置生效 7 [root@master Hive]# source /etc/profile
修改配置文件hive-site.xml
该文件不存在,需要复制hive-default.xml.template来创建
1 #进入到hive‐2.3.2目录 2 [root@master Hive]# cd hive‐2.3.2/ 3 #创建hive‐site.xml文件 4 [root@master hive‐2.3.2]# cp conf/hive‐default.xml.template conf/hive‐site.xml 5 [root@master hive‐2.3.2]# vi conf/hive‐site.xml 6 #创建指定目录 7 [root@master hive‐2.3.2]# hadoop fs ‐mkdir ‐p /hive/tmp 8 [root@master hive‐2.3.2]# hadoop fs ‐mkdir ‐p /hive/logs 9 [root@master hive‐2.3.2]# hadoop fs ‐mkdir ‐p /hive/warehouse
修改配置如下:
1 <property><!‐‐数据库连接地址,使用MySQL存储元数据信息‐‐> 2 <name>javax.jdo.option.ConnectionURL</name> 3 <value>jdbc:mysql://master:3306/metastore? 4 createDatabaseIfNotExist=true&useSSL=false</value> 5 </property> 6 <property><!‐‐数据库驱动‐‐> 7 <name>javax.jdo.option.ConnectionDriverName</name> 8 <value>com.mysql.jdbc.Driver</value> 9 </property> 10 <property><!‐‐数据库用户名‐‐> 11 <name>javax.jdo.option.ConnectionUserName</name> 12 <value>root</value> 13 <description>Username to use against metastore database</description> 14 </property> 15 <property><!‐‐密码‐‐> 16 <name>javax.jdo.option.ConnectionPassword</name> 17 <value>123456</value> 18 <description>password to use against metastore database</description> 19 </property> 20 <property><!‐‐HDFS路径,用于存储不同 map/reduce 阶段的执行计划和这些阶段的中间输出结 21 果。‐‐> 22 <name>hive.exec.local.scratchdir</name> 23 <value>/hive/tmp</value> 24 </property> 25 <property><!‐‐Hive 查询日志所在的目录,如果该值为空,将不创建查询日志。‐‐> 26 <name>hive.querylog.location</name> 27 <value>/hive/logs</value> 28 </property> 29 <property><!‐‐本地表的默认位置‐‐> 30 <name>hive.metastore.warehouse.dir</name> 31 <value>/hive/warehouse</value> 32 </property> 33 <property> 34 <name>hive.metastore.uris</name><!‐‐Hive连接到该URI请求远程元存储的元数据‐‐> 35 <value>thrift://master:9083</value> 36 </property> 37 <property><!‐‐关闭本地模式,此项不存在,需要自己添加‐‐> 38 <name>hive.metastore.local</name> 39 <value>false</value> 40 </property> 41 <property> 42 <name>hive.server2.logging.operation.log.location</name> 43 <value>/hive/logs</value> 44 </property> 45 <property> 46 <name>hive.downloaded.resources.dir</name> 47 <value>/hive/tmp/${hive.session.id}_resources</value> 48 </property>
修改配置文件
1 [root@master hive‐2.3.2]# vi bin/hive‐config.sh 2 #添加以下内容 3 export JAVA_HOME=/opt/SoftWare/Java/jdk1.8.0_152 4 export HADOOP_HOME=/opt/SoftWare/Hadoop/hadoop‐2.7.5 5 export HIVE_HOME=/opt/SoftWare/Hive/hive‐2.3.2
复制MySQL的驱动jar到hive/lib目录
1 [root@master hive‐2.3.2]# cd lib 2 [root@master lib]# rz
对Hive进行初始化并启动Hive
1 [root@master lib]# cd $HIVE_HOME/bin 2 [root@master bin]# schematool ‐initSchema ‐dbType mysql 3 #出现以下信息代表初始化成功 4 SLF4J: Class path contains multiple SLF4J bindings. 5 SLF4J: Found binding in [jar:file:/opt/SoftWare/Hive/hive‐2.3.2/lib/log4j‐slf4j‐ 6 impl‐2.6.2.jar!/org/slf4j/impl/StaticLoggerBinder.class] 7 SLF4J: Found binding in [jar:file:/opt/SoftWare/Hadoop/hadoop‐ 8 2.7.5/share/hadoop/common/lib/slf4j‐log4j12‐ 9 1.7.10.jar!/org/slf4j/impl/StaticLoggerBinder.class] 10 SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation. 11 SLF4J: Actual binding is of type [org.apache.logging.slf4j.Log4jLoggerFactory] 12 Metastore connection URL: jdbc:mysql://master:3306/metastore? 13 createDatabaseIfNotExist=true 14 Metastore Connection Driver : com.mysql.jdbc.Driver 15 Metastore connection User: root 16 Sun Mar 04 15:30:33 CST 2018 WARN: Establishing SSL connection without server's 17 identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 18 5.7.6+ requirements SSL connection must be established by default if explicit optionisn't set. For compliance with existing applications not using SSL the 19 verifyServerCertificate property is set to 'false'. You need either to explicitly 20 disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for 21 server certificate verification. 22 Starting metastore schema initialization to 2.3.0 23 Initialization script hive‐schema‐2.3.0.mysql.sql 24 Sun Mar 04 15:30:34 CST 2018 WARN: Establishing SSL connection without server's 25 identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 26 5.7.6+ requirements SSL connection must be established by default if explicit option 27 isn't set. For compliance with existing applications not using SSL the 28 verifyServerCertificate property is set to 'false'. You need either to explicitly 29 disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for 30 server certificate verification. 31 Initialization script completed 32 Sun Mar 04 15:30:36 CST 2018 WARN: Establishing SSL connection without server's 33 identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 34 5.7.6+ requirements SSL connection must be established by default if explicit option 35 isn't set. For compliance with existing applications not using SSL the 36 verifyServerCertificate property is set to 'false'. You need either to explicitly 37 disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for 38 server certificate verification. 39 schemaTool completed 40 #启动hive服务端 41 [root@master bin]# hive ‐‐service metastore 42 #启动Hive客户端 43 [root@master bin]# hive 44 #输入show tables;显示以下信息,说明Hive已经启动 45 hive> show tables; 46 OK 47 Time taken: 1.594 seconds
至此,Hive大仓库安装配置完成。