1 MetaData(元數據)
2 MetaStore (元數據服務)
3 MetaStore配置方式
3.1 內嵌模式
3.2 本地模式
3.3 遠程模式
4 安裝前準備
<!-- 整合hive --><property><name>hadoop.proxyuser.root.hosts</name><value>*</value></property><property><name>hadoop.proxyuser.root.groups</name><value>*</value></property>
5 遠程模式安裝
5.1 下載
https://hive.apache.org/
5.2 解壓并重命名
tar -zxvf apache-hive-3.1.2-bin.tar.gz -C /opt/module/
cd /opt/module/
mv mv apache-hive-3.1.2-bin hive
5.3 解決hadoop、hive 之間的guava版本差異問題
cd /opt/module/hive/librm -f guava-19.0.jarcp /opt/module/hadoop-3.1.3/share/hadoop/common/lib/guava-27.0-jre.jar ./guava-27.0-jre.jar
5.4 添加環境變量
vi /etc/profile.d/my_env.sh
#HIVE_HOMEexport HIVE_HOME=/opt/module/hiveexport PATH=$PATH:$HIVE_HOME/bin
source /etc/profile
5.5 hive-env.sh 修改Hive環境變量
cd /opt/module/hive/conf
mv hive-env.sh.template hive-env.sh
vim hive-env.sh
# Set HADOOP_HOME to point to a specific hadoop install directory
export HADOOP_HOME=/opt/module/hadoop-3.1.3# Hive Configuration Directory can be controlled by:
export HIVE_CONF_DIR=/opt/module/hive/conf# Folder containing extra libraries required for hive compilation/execution can be controlled by:
export HIVE_AUX_JARS_PATH=/opt/module/hive/lib
5.6 hive-log4j2.properties 日志配置
mkdir -P /opt/module/hive/datas
cd /opt/module/hive/conf
mv hive-log4j2.properties.template hive-log4j2.properties
vim hive-log4j2.properties
property.hive.log.dir = /opt/module/hive/datas
5.7 hive-site.xml 配置MateStore
添加了hive.metastore.uris 配置,則需要手動啟動Matastore服務
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<configuration><!-- 存儲元數據mysql配置 --><property><name>javax.jdo.option.ConnectionURL</name><value>jdbc:mysql://hadoop102:3306/hive?createDatabaseIfNotExist=true&useUnicode=true&useSSL=false&characterEncoding=utf8</value><description>JDBC connect string for a JDBC metastore.To use SSL to encrypt/authenticate the connection, provide database-specific SSL flag in theconnection URL.For example, jdbc:postgresql://myhost/db?ssl=true for postgres database.</description></property><property><name>javax.jdo.option.ConnectionDriverName</name><value>com.mysql.cj.jdbc.Driver</value><description>Driver class name for a JDBC metastore</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>123456</value><description>password to use against metastore database</description></property><!-- H2S運行綁定host --><property><name>hive.server2.thrift.bind.host</name><value>hadoop102</value><description>Bind host on which to run the HiveServer2 Thrift service.</description></property><!-- 遠程模式部署metastore 服務地址 --><property><name>hive.metastore.uris</name><value>thrift://hadoop102:9083</value><description>Thrift URI for the remote metastore. Used by metastore client to connect to remotemetastore.</description></property><!-- 關閉元數據存儲授權 --><property><name>hive.metastore.event.db.notification.api.auth</name><value>false</value><description>Should metastore do authorization against database notification related APIs such asget_next_notification.If set to true, then only the superusers in proxy settings have the permission</description></property><!-- 關閉元數據存儲版本的驗證 --><property><name>hive.metastore.schema.verification</name><value>true</value><description>Enforce metastore schema version consistency.True: Verify that version information stored in is compatible with one from Hive jars. Alsodisable automaticschema migration attempt. Users are required to manually migrate schema after Hive upgradewhich ensuresproper metastore schema migration. (Default)False: Warn if the version information stored in metastore doesn't match with one from in Hivejars.</description></property>
</configuration>
5.8 上傳mysql-connector-java-5.1.27-bin.jar
基于mysql的版本上傳jar
/opt/module/hive/lib/mysql-connector-java-5.1.27-bin.jar
5.9 初始化Matedata
cd /opt/module/hive/bin
./schematool -dbType mysql -initSchema --verbose
3.5.10 啟動MateStore腳本
vim hive_metastore.sh
#!/bin/bash
if [ $# -lt 1 ]; thenecho "No Args Input..."exit
ficase $1 in
"start"){echo "----------------- MetaStore start -----------------"nohup /opt/module/hive/bin/hive --service metastore >> /opt/module/hive/datas/metastore.out 2>&1 &echo "----------------- Hiveserver2 start -----------------"nohup /opt/module/hive/bin/hive --service hiveserver2 >> /opt/module/hive/datas/hiveserver2.out 2>&1 &};;
"stop"){echo "----------------- MetaStore stop -----------------"pidMetaStore=$(ps -ef | grep -v grep | grep "Dproc_metastore" | awk '{printf $2" "}')kill -9 ${pidMetaStore}echo "----------------- Hiveserver2 stop -----------------"pidHiveserver2=$(ps -ef | grep -v grep | grep "Dproc_hiveserver2" | awk '{printf $2" "}')kill -9 ${pidHiveserver2}};;
*)echo "Input Args Error...";;
esac