Hive安装教程
前提条件
已经安装好hadoop集群以及mysql
CentOS7搭建Hadoop3集群教程
CentOS7安装MySQL教程
下载hive
hive3.1.3下载连接:https://archive.apache.org/dist/hive/hive-3.1.3/apache-hive-3.1.3-bin.tar.gz
登录master服务器hadoop,将压缩包上传到/opt/software
解压
tar -zxvf apache-hive-3.1.3-bin.tar.gz -C /opt/module/
将MySQL
的驱动包,放入hive
的lib
目录
下载MySQL
驱动包:
https://repo1.maven.org/maven2/mysql/mysql-connector-java/5.1.34/mysql-connector-java-5.1.34.jar
cd /opt/module/apache-hive-3.1.3-bin/lib
修改配置
修改Hadoop
配置
core-site.xml增加
vim /opt/module/hadoop-3.1.3/etc/hadoop/core-site.xml
<property>
<name>hadoop.proxyuser.hadoop.hosts</name>
<value>*</value>
</property>
<property>
<name>hadoop.proxyuser.hadoop.groups</name>
<value>*</value>
</property>
配置hive
环境变量
cd /opt/module/apache-hive-3.1.3-bin/conf
mv hive-env.sh.template hive-env.sh
vim hive-env.sh
最后面添加
export HIVE_CONF_DIR=/export/server/apache-hive-3.1.3-bin/conf
export HIVE_AUX_JARS_PATH=/export/server/apache-hive-3.1.3-bin/lib
保存退出
配置hive-site.xml
cd /opt/module/apache-hive-3.1.3-bin/conf
vim hive-site.xml
<configuration>
<property>
<name>javax.jdo.option.ConnectionURL</name>
<value>jdbc:mysql://hadoop-master:3306/hive?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>root</value>
</property>
<property>
<name>hive.server2.thrift.bind.host</name>
<value>hadoop-master</value>
</property>
<property>
<name>hive.metastore.uris</name>
<value>thrift://hadoop-master:9083</value>
</property>
<property>
<name>hive.metastore.event.db.notification.api.auth</name>
<value>false</value>
</property>
</configuration>
初始化元数据
CREATE DATABASE hive CHARSET UTF8;
cd /opt/module/hadoop-3.1.3/share/hadoop/common/lib
cp guava-27.0-jre.jar /opt/module/apache-hive-3.1.3-bin/lib/
cd /opt/module/apache-hive-3.1.3-bin/lib
mv guava-19.0.jar guava-19.0.jar.bak
cd /opt/module/apache-hive-3.1.3-bin/bin
./schematool -initSchema -dbType mysql -verbos
启动
cd /opt/module/apache-hive-3.1.3-bin
mkdir logs
cd /opt/module/apache-hive-3.1.3-bin
nohup bin/hive --service metastore >> logs/metastore.log 2>&1 &
tail -f logs/metastore.log
测试
cd /opt/module/apache-hive-3.1.3-bin
bin/hive
show databases