- 1、下载安装包
下载hive
https://archive.apache.org/dist/hive/
下载MySQL驱动包
https://mirrors.huaweicloud.com/mysql/Downloads/Connector-J/
- 2、上传到Linux并解压
tar -zxvf apache-hive-3.1.2-bin.tar.gz -C ../
- 3、重命名
mv apache-hive-3.1.2-bin hive-3.1.2
- 4、配置环境变量
vim /etc/profile
添加下面内容
export HIVE_HOME=/usr/local/soft/hive-3.1.2
export PATH=$PATH:$HIVE_HOME/bin
- 5、加载环境变量
source /etc/profile
- 6、修改配置文件
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<configuration>
<property>
<name>javax.jdo.option.ConnectionDriverName</name>
<value>com.mysql.cj.jdbc.Driver</value>
</property>
<property>
<name>javax.jdo.option.ConnectionURL</name>
<value>jdbc:mysql://master:3306/hive?useSSL=false&createDatabaseIfNotExist=true&characterEncoding=utf8&useUnicode=true</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.metastore.uris</name>
<value>thrift://master:9083</value>
</property>
<property>
<name>hive.server2.enable.doAs</name>
<value>false</value>
</property>
<property>
<name>hive.querylog.location</name>
<value/>
</property>
(同上)
<property>
<name>hive.exec.local.scratchdir</name>
<value/>
</property>
(同上)
<property>
<name>hive.downloaded.resources.dir</name>
<value/>
</property>
</configuration>
3214行的描述删掉
- 7、创建log4j.properties配置文件
编辑文件添加下面内容
# 将日志级别改成WARN,避免执行sql出现很多日志
log4j.rootLogger=WARN,CA
log4j.appender.CA=org.apache.log4j.ConsoleAppender
log4j.appender.CA.layout=org.apache.log4j.PatternLayout
log4j.appender.CA.layout.ConversionPattern=%-4r [%t] %-5p %c %x - %m%n%
-
8、将nysql驱动包上传到hive的lib目录下
-
9、初始化hive元数据库
初始化hive的元数据(表结构)到mysql中
schematool -dbType mysql -initSchema
- 10、后台启动元数据服务
nohup hive --service metastore >> /usr/local/soft/hive-3.1.2/startlogs/metastore-service.log &
- 11、进入hive命令行
hive
- 12、测试
标签:3.1,hive,javax,mysql,apache,log4j,搭建 From: https://www.cnblogs.com/w-ll/p/18535988查看数据库
show databases;