0


HIVE搭建教程

一、卸载Centos7自带的mariadb

rpm -qa | grep mariadb
rpm -e mariadb-libs-5.5.60-1.el7_5.x86_64 --nodeps
rpm -qa|grep mariadb

二、安装MySQL

# 创建MySQL工作目录
mkdir -p /opt/module/mysql
# 将mysql上传并解压到mysql工作目录下
tar -xvf mysql-5.7.37-1.el7.x86_64.rpm-bundle.tar -C /opt/module/mysql
# 执行安装库
yum -y install libaio
yum install net-tools

# 进行安装mysql
cd /opt/module/mysql
rpm -ivh mysql-community-common-5.7.37-1.el7.x86_64.rpm 
rpm -ivh mysql-community-libs-5.7.37-1.el7.x86_64.rpm 
rpm -ivh mysql-community-client-5.7.37-1.el7.x86_64.rpm 
rpm -ivh mysql-community-server-5.7.37-1.el7.x86_64.rpm 
# 初始化
mysqld --initialize --user=mysql
#更改所属组
chown mysql:mysql /var/lib/mysql -R
# 启动MySQL
systemctl start mysqld.service
# 查看生成的临时密码
cat /var/log/mysqld.log | tail -n 10
# 进入MySQL
mysql -u root -p
输入刚才的临时密码

# 更新root密码 设置为123456
alter user user() identified by "123456";
# 授权
use mysql;
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'hadoop' WITH GRANT OPTION;
# 建议设置为开机自启动服务
systemctl enable  mysqld

# 设置MySQL远程访问
mysql -uroot -p
use mysql
查询用户表,查看已有用户的访问权限
select User,authentication_string,Host from user;
# 修改用户远程访问权限
GRANT ALL PRIVILEGES ON * . * TO "root"@"%" IDENTIFIED BY "123456";
# 刷新数据库
flush privileges;

三、安装hive

#安装hive
tar -zxvf apache-hive-3.1.2-bin.tar.gz -C /opt/module/
# 解决Hive与Hadoop之间的guava版本差异
cd /opt/module/apache-hive-3.1.2-bin/
rm -rf lib/guava-19.0.jar 
rm -rf lib/log4j-slf4j-impl-2.10.0.jar
# 向下兼容配置
cp /opt/module/hadoop-3.3.0/share/hadoop/common/lib/guava-27.0-jre.jar ./lib/
# 修改配置文件
mv hive-env.sh.template hive-env.sh
vi hive-env.sh 
加到文件最后
export HADOOP_HOME=/opt/module/hadoop3.3.0
export HIVE_CONF_DIR=/opt/module/apache-hive-3.1.2-bin/conf
export HIVE_AUX_JARS_PATH=/opt/module/apache-hive-3.1.2-bin/lib

# 修改hive-site.xml(没有此文件直接新建即可)
vi hive-site.xml
<configuration>
<!-- 存储元数据mysql相关配置 -->
<property>
        <name>javax.jdo.option.ConnectionURL</name>
        <value>jdbc:mysql://192.168.88.101:3306/hive3?createDatabaseIfNotExist=true&amp;useSSL=false&amp;useUnicode=true&amp;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>123456</value>
</property>

<!-- H2S运行绑定host -->
<property>
    <name>hive.server2.thrift.bind.host</name>
    <value>master</value>
</property>

<!-- 远程模式部署metastore metastore地址 -->
<property>
    <name>hive.metastore.uris</name>
    <value>thrift://master:9083</value>
</property>

<!-- 关闭元数据存储授权  --> 
<property>
    <name>hive.metastore.event.db.notification.api.auth</name>
    <value>false</value>
</property>
  <property>
    <name>datanucleus.connectionPoolingType</name>
    <value>dbcp</value>
    <description>
      Expects one of [bonecp, dbcp, hikaricp, none].
      Specify connection pool library for datanucleus
    </description>
  </property>
</configuration>

# 上传mysql的jdbc驱动到hive的安装包lib下

# 初始化数据
cd /opt/module/apache-hive-3.1.2-bin
bin/schematool -initSchema -dbType mysql -verbos

# 在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

四、启动hive

# 启动metastore服务
nohup /opt/module/apache-hive-3.1.2-bin/bin/hive --service metastore &
# 启动hiveserver2服务
nohup /opt/module/apache-hive-3.1.2-bin/bin/hive --service  hiveserver2 &

五、beeline客户端链接

拷贝master安装包到beeline客户端机器上(任意一个节点即可)

scp -r /opt/module/apache-hive-3.1.2-bin/ root@slave2 /opt/module

测试链接

/opt/module/apache-hive-3.1.2-bin/bin/beeline
beeline> ! connect jdbc:hive2://master:10000
beeline> root
beeline> 直接回车

本文转载自: https://blog.csdn.net/nanfeng_ttns/article/details/136600287
版权归原作者 裔飍 所有, 如有侵权,请联系我们删除。

“HIVE搭建教程”的评论:

还没有评论