Hive安裝教程


為了方便操作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&amp;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大倉庫安裝配置完成。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM