Hive Install

1、http://mirror.bit.edu.cn/apache/hive/stable-2/ 下載hive;上傳到linux系統

2、將apache-hive-2.3.3-bin.tar.gz移動到/usr/local目錄,解壓,並重命名爲hive ;如下
[root@hmaster soft]# ls
apache-hive-2.3.3-bin.tar.gz hadoop-2.7.3.tar.gz jdk-8u151-linux-i586.tar.gz
[root@hmaster soft]# mv apache-hive-2.3.3-bin.tar.gz /usr/local/
[root@hmaster soft]# cd /usr/local/
[root@hmaster local]# ls
apache-hive-2.3.3-bin.tar.gz bin etc games hadoop include java lib lib64 libexec sbin share src
[root@hmaster local]# tar -xvf apache-hive-2.3.3-bin.tar.gz
[root@hmaster local]# mv apache-hive-2.3.3-bin hive
[root@hmaster local]# ls
bin etc games hadoop hive include java lib lib64 libexec sbin share src
[root@hmaster local]#
3、配置環境變量

[root@hmaster local]# vim /etc/profile
[root@hmaster local]# ^C
[root@hmaster local]# source /etc/profile
[root@hmaster local]# echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/usr/java/jdk1.8.0_151/bin:/usr/local/hadoop/bin:/usr/local/hadoop/sbin:/root/bin:/usr/java/jdk1.8.0_151/bin:/usr/local/hadoop/bin:/usr/local/hadoop/sbin:/usr/local/hive/bin
[root@hmaster local]#

#set java environment /usr/local/java/jdk1.8.0_151
export JAVA_HOME=/usr/java/jdk1.8.0_151
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export PATH=$PATH:$JAVA_HOME/bin

export PATH=$PATH:/usr/local/hadoop/bin:/usr/local/hadoop/sbin
export PATH=$PATH:/usr/local/hive/bin
4、配置hive-site.xml
[root@hmaster conf]# pwd
/usr/local/hive/conf
[root@hmaster conf]# ll
total 288
-rw-r--r--. 1 root root 1596 Feb 17 2017 beeline-log4j2.properties.template
-rw-r--r--. 1 root root 257573 Mar 28 2018 hive-default.xml.template
-rw-r--r--. 1 root root 2365 Feb 17 2017 hive-env.sh.template
-rw-r--r--. 1 root root 2274 Feb 17 2017 hive-exec-log4j2.properties.template
-rw-r--r--. 1 root root 2925 Mar 7 2018 hive-log4j2.properties.template
-rw-r--r--. 1 root root 2060 Feb 17 2017 ivysettings.xml
-rw-r--r--. 1 root root 2719 Mar 7 2018 llap-cli-log4j2.properties.template
-rw-r--r--. 1 root root 7041 Mar 7 2018 llap-daemon-log4j2.properties.template
-rw-r--r--. 1 root root 2662 Jul 20 2016 parquet-logging.properties
[root@hmaster conf]# cp hive-default.xml.template hive-site.xml

[root@hmaster hive]# pwd
/usr/local/hive
[root@hmaster hive]# mkdir tmp
[root@hmaster hive]# ls
bin binary-package-licenses conf examples hcatalog jdbc lib LICENSE NOTICE RELEASE_NOTES.txt scripts tmp

通過文件傳輸工具將hive-site.xml文件複製到window上編輯

<property>
<name>hive.metastore.schema.verification</name>
<value>false</value>
<description>
Enforce metastore schema version consistency.
True: Verify that version information stored in is compatible with one from Hive jars. Also disable automatic
schema migration attempt. Users are required to manually migrate schema after Hive upgrade which ensures
proper metastore schema migration. (Default)
False: Warn if the version information stored in metastore doesn't match with one from in Hive jars.
</description>
</property>

用創建的 /usr/local/hive/tmp 目錄,替換 ${system:java.io.tmpdir}
替換 ${system:user.name} 爲root
上傳覆蓋文件hive-site.xml

在/usr/local/hive目錄下執行如下命令
[root@hmaster hive]# pwd
/usr/local/hive
[root@hmaster hive]# schematool -initSchema -dbType derby

[root@hmaster hive]# ll
total 60
drwxr-xr-x. 3 root root 133 Oct 9 23:46 bin
drwxr-xr-x. 2 root root 4096 Oct 9 23:46 binary-package-licenses
drwxr-xr-x. 2 root root 4096 Oct 9 23:57 conf
-rw-r--r--. 1 root root 639 Oct 10 02:16 derby.log
drwxr-xr-x. 4 root root 34 Oct 9 23:46 examples
drwxr-xr-x. 7 root root 68 Oct 9 23:46 hcatalog
drwxr-xr-x. 2 root root 44 Oct 9 23:46 jdbc
drwxr-xr-x. 4 root root 12288 Oct 9 23:46 lib
-rw-r--r--. 1 root root 20798 Mar 7 2018 LICENSE
drwxr-xr-x. 5 root root 133 Oct 10 02:16 metastore_db
-rw-r--r--. 1 root root 230 Mar 27 2018 NOTICE
-rw-r--r--. 1 root root 459 Mar 28 2018 RELEASE_NOTES.txt
drwxr-xr-x. 4 root root 35 Oct 9 23:46 scripts
drwxr-xr-x. 2 root root 6 Oct 10 01:33 tmp

啓動hive命令: hive

schematool -initSchema -dbType derby
嘗試當前目錄下初始化 metastore_db的數據庫
注意下次執行hive時應該在同一目錄,默認到當前目錄尋找metastore
遇到問題,把metastore_db 刪除,重新執行命令schematool -initSchema -dbType derby
實際工作環境中,經常使用MySQL作爲metastore的數據庫

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章