文章目录
- 1. 内嵌模式安装
- 2. 本地模式安装
- 2.1 Mysql安装
- 2.2 Hive安装配置
- 3. 远程模式安装
1. 内嵌模式安装
安装准备
- 下载hive:pass
- 将文件复制到安装目录下:
- 解压安装包:
tar zxvf apache-hive-3.1.2-bin.tar.gz
- 修改名字:
mv apache-hive-3.1.2-bin hive
解决hadoop、hive之间guava版本差异
- 进入hive目录:
cd /export/server/hive
- 删除原本jar包:
rm -rf lib/guava-19.0.jar
- 复制新的jar包:
cp /export/server/hadoop-3.3.0/share/hadoop/common/lib/guava-27.0-jre.jar ./lib/
修改hive环境变量文件 添加Hadoop_HOME
- 进入指定目录:
cd /export/server/hive/conf/
- 修改为hive-env.sh:
mv hive-env.sh.template hive-env.sh
- 编辑hive-env.sh:
vim hive-env.sh
i
export HADOOP_HOME=/export/server/hadoop-3.3.0
export HIVE_CONF_DIR=/export/server/hive/conf
export HIVE_AUX_JARS_PATH=/export/server/hive/lib
初始化metadata
- 进入指定目录:
cd /export/server/hive
- 执行初始化命令:
bin/schematool -dbType derby -initSchema
启动hive服务
- 启动命令:
bin/hive
2. 本地模式安装
2.1 Mysql安装
- 卸载Centos7自带mariadb:
rpm -qa|grep mariadb
- 创建mysql安装包存放点:
mkdir /export/software/mysql
- #进入目录、上传mysql-5.7.29安装包到上述文件夹下、解压:
tar xvf mysql-5.7.29-1.el7.x86_64.rpm-bundle.tar
- 执行安装:
yum -y install libaio
rpm -ivh mysql-community-common-5.7.29-1.el7.x86_64.rpm mysql-community-libs-5.7.29-1.el7.x86_64.rpm mysql-community-client-5.7.29-1.el7.x86_64.rpm mysql-community-server-5.7.29-1.el7.x86_64.rpm
- 初始化mysql:
mysqld --initialize
- 更改所属组:
chown mysql:mysql /var/lib/mysql -R
- 启动mysql:
systemctl start mysqld.service
- 查看生成的临时root密码:
cat /var/log/mysqld.log
- 这行日志的最后就是随机生成的临时密码:
- 修改mysql root密码、授权远程访问:
mysql -u root -p
Enter password:
- 更新root密码 设置为123456
alter user user() identified by "123456";
- 授权:
use mysql;
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'hadoop' WITH GRANT OPTION;
FLUSH PRIVILEGES;
- mysql的启动和关闭 状态查看:
systemctl stop mysqld
systemctl status mysqld
systemctl start mysqld
- 设置为开机自启动服务:
systemctl enable mysqld
- 查看是否已经设置自启动成功:
systemctl list-unit-files | grep mysqld
2.2 Hive安装配置
- 上传解压安装包并修改名字
cd /export/server/
tar zxvf apache-hive-3.1.2-bin.tar.gz
mv apache-hive-3.1.2-bin hive
- 解决hadoop、hive之间guava版本差异
cd /export/server/hive
rm -rf lib/guava-19.0.jar
cp /export/server/hadoop-3.3.0/share/hadoop/common/lib/guava-27.0-jre.jar ./lib/
- 添加mysql jdbc驱动到hive安装包lib/文件下:(jar包pass)
- 修改hive环境变量文件 添加Hadoop_HOME:
cd /export/server/hive/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/hive/conf
export HIVE_AUX_JARS_PATH=/export/server/hive/lib
- 新增hive-site.xml 配置mysql等相关信息:
vim hive-site.xml
<configuration>
<!-- 存储元数据mysql相关配置 -->
<property>
<name>javax.jdo.option.ConnectionURL</name>
<value> jdbc:mysql://node1: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>hadoop</value>
</property>
<!-- 关闭元数据存储授权 -->
<property>
<name>hive.metastore.event.db.notification.api.auth</name>
<value>false</value>
</property>
<!-- 关闭元数据存储版本的验证 -->
<property>
<name>hive.metastore.schema.verification</name>
<value>false</value>
</property>
</configuration>
- 初始化metadata:
cd /export/server/hive
bin/schematool -initSchema -dbType mysql -verbos
- 启动hive服务:
bin/hive
- 使用navicat连接mysql验证hive数据中的表数量(74张表):
3. 远程模式安装
基于本地模式的基础上,将hive-site.xml修改为:
<configuration>
<!-- 存储元数据mysql相关配置 -->
<property>
<name>javax.jdo.option.ConnectionURL</name>
<value> jdbc:mysql://node1: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>hadoop</value>
</property>
<!-- H2S运行绑定host -->
<property>
<name>hive.server2.thrift.bind.host</name>
<value>node1</value>
</property>
<!-- 远程模式部署metastore 服务地址 -->
<property>
<name>hive.metastore.uris</name>
<value>thrift://node1:9083</value>
</property>
<!-- 关闭元数据存储授权 -->
<property>
<name>hive.metastore.event.db.notification.api.auth</name>
<value>false</value>
</property>
<!-- 关闭元数据存储版本的验证 -->
<property>
<name>hive.metastore.schema.verification</name>
<value>false</value>
</property>
</configuration>
Metastore Hiveserver2启动
- 前台启动 关闭ctrl+c:
/export/server/hive/bin/hive --service metastore
- 后台启动 进程挂起 关闭使用jps + kill
输入命令回车执行 再次回车 进程将挂起后台:nohup /export/server/hive/bin/hive --service metastore &
- 前台启动开启debug日志:
/export/server/hive/bin/hive --service metastore --hiveconf hive.root.logger=DEBUG,console