1、下载安装包
地址:http://archive.apache.org/dist/hive/
2、安装mysql
参考:https://www.cnblogs.com/jpxjx/p/16817724.html
3、上传安装包并解压
tar zxvf apache-hive-3.1.2-bin.tar.gz
4、解决Hive与Hadoop之间guava版本差异
cd /root/export/server/apache-hive-3.1.2-bin/ rm -rf lib/guava-19.0.jar cp /root/export/server/hadoop-3.3.5/share/hadoop/common/lib/guava-27.0-jre.jar ./lib/
5、修改配置文件
5.1、hive-env.sh
cd /root/export/server/apache-hive-3.1.2-bin/conf mv hive-env.sh.template hive-env.sh vi hive-env.sh export HADOOP_HOME=/root/export/server/hadoop-3.3.5 export HIVE_CONF_DIR=/root/export/server/apache-hive-3.1.2-bin/conf export HIVE_AUX_JARS_PATH=/root/export/server/apache-hive-3.1.2-bin/lib
5.2、hive-site.xml
touch hive-site.xml
vi hive-site.xml
<configuration> <!-- 存储元数据mysql相关配置 --> <property> <name>javax.jdo.option.ConnectionURL</name> <value>jdbc:mysql://hadoop:3306/hive3?createDatabaseIfNotExist=true&useSSL=false&useUnicode=true&characterEncoding=UTF-8</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>hadoop</value> </property> <!-- H2S运行绑定host --> <property> <name>hive.server2.thrift.bind.host</name> <value>hadoop</value> </property> <!-- 远程模式部署metastore metastore地址 --> <property> <name>hive.metastore.uris</name> <value>thrift://hadoop:9083</value> </property> <!-- 关闭元数据存储授权 --> <property> <name>hive.metastore.event.db.notification.api.auth</name> <value>false</value> </property> </configuration>
5.3、上传mysql jdbc驱动到hive安装包lib下
mysql-connector-j-8.0.32.jar
5.4、初始化元数据
cd /root/export/server/apache-hive-3.1.2-bin/ bin/schematool -initSchema -dbType mysql -verbos #初始化成功会在mysql中创建74张表
6、在hdfs创建hive存储目录(如存在则不用操作)
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
7、启动hive
7.1、启动metastore服务
#前台启动 关闭ctrl+c /root/export/server/apache-hive-3.1.2-bin/bin/hive --service metastore #前台启动开启debug日志 /root/export/server/apache-hive-3.1.2-bin/bin/hive --service metastore --hiveconf hive.root.logger=DEBUG,console #后台启动 进程挂起 关闭使用jps+ kill -9 nohup /root/export/server/apache-hive-3.1.2-bin/bin/hive --service metastore &
7.2、启动hiveserver2服务
nohup /root/export/server/apache-hive-3.1.2-bin/bin/hive --service hiveserver2 & #注意 启动hiveserver2需要一定的时间 不要启动之后立即beeline连接 可能连接不上
8、beeline客户端连接
8.1、拷贝hadoop安装包到beeline客户端机器上(hadoop02)
scp -r /root/export/server/apache-hive-3.1.2-bin/ hadoop02:/root/export/server/
8.2、连接访问
/root/export/server/apache-hive-3.1.2-bin/bin/beeline beeline> ! connect jdbc:hive2://hadoop:10000 beeline> root beeline> 直接回车
标签:bin,Hive3,root,hive,server,export,apache,安装 From: https://www.cnblogs.com/jpxjx/p/17304551.html