-
上传安装包到/export/server/文件夹下(listenwind102)
tar zxvf apache-hive-3.1.2-bin.tar.gz
-
解压文件夹(listenwind102)
tar zxvf apache-hive-3.1.2-bin.tar.gz
-
替换guava文件解决Hive与Hadoop之间guava版本差异(listenwind102)
cd /export/server/apache-hive-3.1.2-bin/ rm -rf lib/guava-19.0.jar cp /export/server/hadoop-3.3.0/share/hadoop/common/lib/guava-27.0-jre.jar ./lib/
-
修改配置文件(listenwind102)
cd /export/server/apache-hive-3.1.2-bin/conf mv hive-env.sh.template hive-env.sh vim hive-env.sh
# 新加入的代码 export HADOOP_HOME=/export/server/hadoop-3.3.0 export HIVE_CONF_DIR=/export/server/apache-hive-3.1.2-bin/conf export HIVE_AUX_JARS_PATH=/export/server/apache-hive-3.1.2-bin/lib
vim hive-site.xml
configuration>javax.jdo.option.ConnectionURL jdbc:mysql://listenwind102:3306/hive3?createDatabaseIfNotExist=true&useSSL=false javax.jdo.option.ConnectionDriverName com.mysql.jdbc.Driver javax.jdo.option.ConnectionUserName root javax.jdo.option.ConnectionPassword hadoop hive.server2.thrift.bind.host listenwind102 hive.metastore.uris thrift://listenwind102:9083 hive.metastore.event.db.notification.api.auth false -
上传mysql jdbc驱动到hive安装包lib下(listenwind102)
cd /export/server/apache-hive-3.1.2-bin/lib
mysql-connector-java-5.1.32.jar
-
初始化元数据(listenwind102)
cd /export/server/apache-hive-3.1.2-bin/ bin/schematool -initSchema -dbType mysql -verbos
-
在hdfs创建hive存储目录(listenwind102)
hadoop fs -mkdir /tmp hadoop fs -mkdir -p /user/hive/warehouse hadoop fs -chmod g+w /tmp hadoop fs -chmod g+w /user/hive/warehouse
-
配置环境变量(listenwind102)
vim /etc/profile
# 新加入的代码 export HIVE_HOME=/export/server/apache-hive-3.1.2-bin export PATH=$PATH:$HIVE_HOME/bin:$HIVE_HOME/sbin
-
分发环境变量(listenwind102)
scp /etc/profile listenwind103:/etc/profile scp /etc/profile listenwind104:/etc/profile
-
分发Hive文件(listenwind102)
scp -r /export/server/apache-hive-3.1.2-bin listenwind103:/export/server/apache-hive-3.1.2-bin scp -r /export/server/apache-hive-3.1.2-bin listenwind104:/export/server/apache-hive-3.1.2-bin
-
重置环境变量(listenwind102listenwind103listenwind104)
source /etc/profile
-
三种启动方式
#前台启动 关闭ctrl+c /export/server/apache-hive-3.1.2-bin/bin/hive --service metastore
#前台启动开启debug日志 /export/server/apache-hive-3.1.2-bin/bin/hive --service metastore --hiveconf hive.root.logger=DEBUG,console
#后台启动 进程挂起 关闭使用jps+ kill -9 nohup /export/server/apache-hive-3.1.2-bin/bin/hive --service metastore &
-
启动hiveserver2服务
nohup /export/server/apache-hive-3.1.2-bin/bin/hive --service hiveserver2 & #注意 启动hiveserver2需要一定的时间 不要启动之后立即beeline连接 可能连接不上
-
beeline客户端连接
# 拷贝node1安装包到beeline客户端机器上(listenwind104) scp -r /export/server/apache-hive-3.1.2-bin/ listenwind104:/export/server/
-
连接访问
/export/server/apache-hive-3.1.2-bin/bin/beeline
beeline> ! connect jdbc:hive2://listenwind102:10000 beeline> root beeline> 直接回车



