Hive安裝:
PS:所有文中涉及到的安裝包,請到鏈接中自取。
下載安裝包合集:
鏈接:https://pan.baidu.com/s/1v2jFM_h46hZK06HH5NBJvA
提取碼:4ae1
第一步:安裝壓縮包
tar -zxf zookeeper-3.4.5-cdh5.14.2.tar.gz
tar -zxf hive-1.1.0-cdh5.14.2.tar.gz
mv zookeeper-3.4.5-cdh5.14.2 soft/zk345
mv hive-1.1.0-cdh5.14.2 soft/hive110
第二步:配置zookeeper
修改zookeeper的配置文件
cd /opt/soft/zk345/conf
cp zoo_sample.cfg zoo.cfg
vi zoo.cfg
# The number of milliseconds of each tick心跳次數
tickTime=2000
# The number of ticks that the initial
# synchronization phase can take
initLimit=10
# The number of ticks that can pass between
# The number of milliseconds of each tick心跳次數
tickTime=2000
# The number of ticks that the initial
# synchronization phase can take
initLimit=10
# The number of ticks that can pass between
# sending a request and getting an acknowledgement異步限制
syncLimit=5
# the directory where the snapshot is stored.
# do not use /tmp for storage, /tmp here is just
# example sakes.文件存放
dataDir=/opt/soft/zk345/tmp
# the port at which the clients will connect端口
clientPort=2181
# the maximum number of client connections.
# increase this if you need to handle more clients
#maxClientCnxns=60
#
# Be sure to read the maintenance section of the
# administrator guide before turning on autopurge.
#
# http://zookeeper.apache.org/doc/current/zookeeperAdmin.html#sc_maintenance
#
# The number of snapshots to retain in dataDir
#autopurge.snapRetainCount=3
# Purge task interval in hours
# Set to "0" to disable auto purge feature
#autopurge.purgeInterval=1
# 2287 領導和跟隨者連接用的,傳遞信息
# 3387 領導掛掉,跟隨者之間選領導使用
server.1=192.168.56.101:2287:3387
修改系統配置文件
vi /etc/profile
添加全局變量
export ZOOKEEPER_HOME=/opt/soft/zk345
export PATH=$PATH:$ZOOKEEPER_HOME/bin
更新配置文件
source /etc/profile
第三步:配置hive
修改hive配置文件
cd /opt/soft/hive110/conf
vi hive-site.xml # 沒有則添加
添加此配置文件
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<configuration>
<!-- 在configuration中加入配置 -->
<property>
<name>hive.metastore.warehouse.dir</name>
<value>/opt/soft/hive110/warehouse</value>
</property>
<!--元數據是否在本地,hive和mysql是否在一個服務器上 -->
<property>
<name>hive.metastore.local</name>
<value>false</value>
</property>
<!-- 如果是遠程mysql數據庫的話需要在這裏寫入遠程的IP或hosts -->
<property>
<name>javax.jdo.option.ConnectionURL</name>
<value>jdbc:mysql://192.168.56.101:3306/hive?createDatabaseIfNotExist=true</value>
</property>
<property>
<name>javax.jdo.option.ConnectionDriverName</name>
<value>com.mysql.jdbc.Driver</value>
</property>
<property>
<name>javax.jdo.option.ConnectionUserName</name>
<value>root</value>
</property>
<property>
<name>javax.jdo.option.ConnectionPassword</name>
<value>123456</value>
</property>
<property>
<name>hive.server2.authentication</name>
<value>NONE</value>
<description>
Expects one of [nosasl, none, ldap, kerberos, pam, custom].
Client authentication types.
NONE: no authentication check
LDAP: LDAP/AD based authentication
KERBEROS: Kerberos/GSSAPI authentication
CUSTOM: Custom authentication provider
(Use with property hive.server2.custom.authentication.class)
PAM: Pluggable authentication module
NOSASL: Raw transport
</description>
</property>
<property>
<name>hive.server2.thrift.client.user</name>
<value>root</value>
<description>Username to use against thrift client</description>
</property>
<property>
<name>hive.server2.thrift.client.password</name>
<value>root</value>
<description>Password to use against thrift client</description>
</property>
</configuration>
修改系統配置文件
export HIVE_HOME=/opt/soft/hive110
export PATH=$PATH:$HIVE_HOME/bin
更新配置文件
source /etc/profile
第四步:啓動HDFS–ZooKeeper–Hive
啓動HDFS
start-all.sh
啓動zookeeper
zkServer.sh start
Hive連接數據庫
需將mysql-connector-java-5.1.38.jar複製到/opt/soft/hive110/lib文件夾下
schematool -dbType mysql initSchema
第五步:啓動Hive黑界面
-
beeline黑界面—jdbc黑界面
開兩個xshell窗口,分別輸入兩段命令
hiveserver2
beeline -u jdbc:hive2://192.168.56.101:10000 -n root
-
mysql黑界面
開兩個xshell窗口,分別輸入兩段命令
啓動Hive元數據存儲
hive --service metastore
hive