1. 程式人生 > 實用技巧 >Hive的安裝與配置

Hive的安裝與配置

Hive的安裝與配置

1)解壓Hive

clinch@node1:~$   tar -zxvf  apache-hive-2.3.3-bin.tar.gz 

2)建立軟連結

clinch@node1:~$ ln -s apache-hive-2.3.3-bin hive
`clinch@node1:~$ ls`
`apache-hive-2.3.3-bin         jdk`
`apache-hive-2.3.3-bin.tar.gz  jdk1.8.0_171`
`Desktop                       jdk8u171-linux-x64.tar.gz`
`Documents                     Music`
`Downloads                     mysql-connector-java-5.1.46.jar`
`examples.desktop              output`
`hadoop                        Pictures`
`hadoop-2.7.3                  pig`
`hadoop-2.7.3.tar.gz           pig-0.17.0`
`hbase                         pig-0.17.0.tar.gz`
`hbase-1.3.1                   pig_1605225789334.log`
`hbase-1.3.1-bin.tar.gz        Public`
`hive                          Templates`
`input                         Videos`

3)設定環境變數,在檔案最後加入兩行程式碼

clinch@node1:~$ vi ~/.bashrc
export HIVE_HOME=/home/clinch/hive
export PATH=$HIVE_HOME/bin:$PATH
clinch@node1:~$ source ~/.bashrc

4)修改配置檔案

clinch@node1:~$ cd ~/hive/conf/
clinch@node1:~/hive/conf$ vi hive-site.xml 
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<configuration>
<property>
        <name>javax.jdo.option.ConnectionURL</name>
        <value>jdbc:mysql://localhost:3306/hive?useSSL=false</value>
</property>
<property>
        <name>javax.jdo.option.ConnectionDriverName</name>
        <value>com.mysql.jdbc.Driver</value>
</property>
<property>
        <name>javax.jdo.option.ConnectionUserName</name>
        <value>hive</value>
</property>
<property>
        <name>javax.jdo.option.ConnectionPassword</name>
        <value>hive</value>
</property>
</configuration>

5)將MySQL驅動檔案複製到Hive安裝目錄下的lib中

clinch@node1:~$ cp mysql-connector-java-5.1.46.jar ~/hive/lib/
clinch@node1:~$ schematool -dbType mysql -initSchema

6)使用Hive

clinch@node1:~$ hive
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/home/clinch/apache-hive-2.3.3-bin/lib/log4j-slf4j-impl-2.6.2.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/home/clinch/hadoop-2.7.3/share/hadoop/common/lib/slf4j-log4j12-1.7.10.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:/home/clinch/apache-hive-2.3.3-bin/lib/hive-common-2.3.3.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>