1. 程式人生 > >Hive 安裝配置

Hive 安裝配置

apach require pan tom 初始 tomat -a cti etc


0. 說明

  在安裝好 Hadoop 集群和 ZooKeeper 分布式的基礎上裝好 MySQL,再進行 Hive 安裝配置

  


1. 安裝

  1.1 將 Hive 安裝包通過 Xftp 發送到 /home/centos 目錄

  

  1.2 解壓

tar -xzvf apache-hive-2.1.1-bin.tar.gz -C /soft/

  1.3 創建符號鏈接

cd /soft/

ln -s apache-hive-2.1.1-bin/ hive

  1.4 配置環境變量

# hive環境變量
export HIVE_HOME=/soft/hive
export PATH
=$PATH:$HIVE_HOME/bin

  1.5 生效環境變量

source /etc/profile


2. 修改 Hive 配置文件

  2.1 重命名 /soft/hive/conf 目錄所有的 template 文件後綴去掉

rename .template ‘‘ *.template

  2.2 修改 hive-env.sh 文件,添加

HADOOP_HOME=/soft/hadoop

  2.3 重命名 hive-default.xml 文件為 hive-site.xml

mv hive-default.xml hive-site.xml

  2.4 修改 hive-site.xml

<configuration>
  ...
  <property>
    <name>javax.jdo.option.ConnectionDriverName</name>
    <value>com.mysql.jdbc.Driver</value>
    <description>Driver class name for a JDBC metastore</description>
  </property>
  <property
> <name>javax.jdo.option.ConnectionURL</name> <value>jdbc:mysql://s101:3306/hive</value> <description> JDBC connect string for a JDBC metastore. To use SSL to encrypt/authenticate the connection, provide database-specific SSL flag in the connection URL. For example, jdbc:postgresql://myhost/db?ssl=true for postgres database. </description> </property> <property> <name>javax.jdo.option.ConnectionUserName</name> <value>root</value> <description>Username to use against metastore database</description> </property> <property> <name>javax.jdo.option.ConnectionPassword</name> <value>root</value> <description>password to use against metastore database</description> </property> <property> <name>hive.server2.enable.doAs</name> <value>false</value> <description> Setting this property to true will have HiveServer2 execute Hive operations as the user making the calls to it. </description> </property> <property> <name>hive.metastore.schema.verification</name> <value>false</value> <description> Enforce metastore schema version consistency. True: Verify that version information stored in metastore matches 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> ... </configuration>

  2.5 修改 hive-site.xml 中的 ${system:user.name} 和 ${system:java.io.tmpdir} //可選

sed -i ‘s@${system:user.name}@centos@g‘ hive-site.xml
sed -i ‘s@${system:java.io.tmpdir}@/home/centos/hive@g‘ hive-site.xml

  2.6 拷貝 MySQL 驅動到 Hive 下

cp ~/mysql-connector-java-5.1.44.jar /soft/hive/lib/

  2.7 在 MySQL 中創建數據庫 Hive

create database hive;

  2.8 初始化元數據庫

schematool -initSchema -dbType mysql


3. 啟動 Hive 的順序

  3.1 啟動 ZooKeeper

xzk.sh start

  3.2 啟動 Hadoop(HDFS+MR)

start-all.sh


  3.3 啟動 Hive

hive

技術分享圖片

  3.4 啟動 Hive 2代服務

  hiveserver2 為 Hive 的 JDBC 接口,用戶可以連接此端口來連接 Hive 服務器

# 先啟動
hiveserver2

# 使用新一代客戶端 beeline 連接 hiveserer2
beeline -u jdbc:hive2://s101:10000


Hive 安裝配置