鲲鹏BigData Pro解决方案中Hive组件的部署

1 介绍

本博文基于《鲲鹏Bigdata pro之Hive集群部署》的实验手册进行,目的是方便Hive学习者重用(从本文复制)相关的指令、配置和代码。同时,会对相关的Bash命令解释,达到增进理解的目的。

2 Hive组件的部署

部署的前提是,启动Hadoop集群。

2.1 在节点1上安装MySQL

步骤 1:添加MySQL用户组合用户

[root@cgznode-0001 ~]# groupadd -r mysql && useradd -r -g mysql -s /sbin/nologin -M mysql

上述命令式通常的Linux命令,意思是,创建一个系统组;若成功,则创建一个用户mysql,其为系统用户,初始组为mysql,且不能登录。

步骤 2:安装MySQL依赖库

yum install -y libaio*

yum是在线安装软件的命令。上述命令安装了libaio.aarch64和libaio-devel.aarch64。

步骤 3 解压并重命名MySQL 安装包

> tar -xvf /home/extend_tools/mysql-5.7.27-aarch64.tar.gz -C /usr/local/
> mv /usr/local/mysql-5.7.27-aarch64 /usr/local/mysql

上述tar命令的选项:x表示解压,v表示观看解压过程的输出,f表示指定的被解压的文件,C表示解压的目标文件夹。

步骤 4 配置MySQL

> mkdir -p /usr/local/mysql/logs
> chown -R mysql:mysql /usr/local/mysql
> ln -sf /usr/local/mysql/my.cnf /etc/my.cnf
> cp -rf /usr/local/mysql/extra/lib* /usr/lib64/
> mv /usr/lib64/libstdc++.so.6 /usr/lib64/libstdc++.so.6.old
> ln -s /usr/lib64/libstdc++.so.6.0.24 /usr/lib64/libstdc++.so.6

上述命令都是基本的Linux命令。其中,ln -sf用于创建软链接文件。

步骤 5 设置MySQL 开机启动

> cp -rf /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
> chmod +x /etc/init.d/mysqld
> /sbin/chkconfig mysqld on

上述命令chmod +x /etc/init.d/mysqld删除也可以,因为文件mysqld本来就具有x权限。命令/sbin/chkconfig mysqld on用于配置mysqld为启动状态。

步骤 6 添加MySQL 环境变量

执行

vim /etc/profile

在上述配置文件的末尾添加:

export MYSQL_HOME=/usr/local/mysql
export PATH=$PATH:$MYSQL_HOME/bin

执行下面指令,使环境变量生效:

source /etc/profile

7 初始化MySQL

mysqld --initialize-insecure --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data

初始化完成后,启动MySQL

> systemctl start mysqld

命令systemctl是系统服务管理命令。可以用systemctl status mysqld查看服务mysqld的状态。

步骤8 MySQL安全配置

> mysql_secure_installation
Securing the MySQL server deployment.
Connecting to MySQL using a blank password.
VALIDATE PASSWORD PLUGIN can be used to test passwords
and improve security. It checks the strength of password
and allows the users to set only those passwords which are
secure enough. Would you like to setup VALIDATE PASSWORD plugin?
### 是否需要安装密码强度检测插件
Press y|Y for Yes, any other key for No: y
There are three levels of password validation policy:
LOW Length >= 8
MEDIUM Length >= 8, numeric, mixed case, and special characters
STRONG Length >= 8, numeric, mixed case, special characters and dictionary
file
### 输入0 表示密码认证策略强度低,1 表示策略强度中,2 表示强度高
Please enter 0 = LOW, 1 = MEDIUM and 2 = STRONG: 0
Please set the password for root here.
### 设置root 自定义用户密码, 设置完成后请做好个人记录
New password:
Re-enter new password:
### 显示自定义root 密码评测结果
Estimated strength of the password: 100

### 是否继续使用上一步设置的密码,输入y 继续使用
Do you wish to continue with the password provided?(Press y|Y for Yes,
any other key for No) : y
By default, a MySQL installation has an anonymous user,
allowing anyone to log into MySQL without having to have
a user account created for them. This is intended only for
testing, and to make the installation go a bit smoother.
You should remove them before moving into a production
environment.
### 是否移除匿名用户,输入Y 移除
Remove anonymous users? (Press y|Y for Yes, any other key for No) : y
Success.

Normally, root should only be allowed to connect from
'localhost'. This ensures that someone cannot guess at
the root password from the network.
### 是否禁止root 用户远程登录权限,输入n 不禁止
Disallow root login remotely? (Press y|Y for Yes, any other key for No) : n

... skipping.
By default, MySQL comes with a database named 'test' that
anyone can access. This is also intended only for testing,
and should be removed before moving into a production
environment.
### 是否删除test 数据库,输入回车键,跳过选择
Remove test database and access to it? (Press y|Y for Yes, any other key
for No) :
... skipping.
Reloading the privilege tables will ensure that all changes
made so far will take effect immediately.
### 是否重新加载权限表,输入回车键,跳过选择
Reload privilege tables now? (Press y|Y for Yes, any other key for No) :
... skipping.
### 完成!
All done!

上面设置的root的密码,要记录在旁边的本子上,后面填写配置文件的时候要用到。
重启MySQL并查看MySQL状态

> systemctl restart mysqld
> systemctl status mysqld

服务mysqld的状态应为:active (running)。

步骤 9 MySQL基本设置

配置MySQL 运行root 远程连接:

> mysql -u root -p
Enter password: 输入步骤8 自定义的root 密码
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.27-log Source distribution
# 切换使用mysql 数据库
mysql> use mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
# 设置远程登录主机与用户名
mysql> update user set host = '%' where user = 'root';
Query OK, 1 row affected (0.01 sec)
Rows matched: 1 Changed: 1 Warnings: 0
# 查看设置结果
mysql> select host, user from user;
+-----------+---------------+
| host | user |
+-----------+---------------+
| % | root |
| localhost | mysql.session |
| localhost | mysql.sys |
+-----------+---------------+
3 rows in set (0.00 sec)
# 刷新配置
mysql> flush privileges;
Query OK, 0 rows affected (0.01 sec)

上面set host = '%'指的是让用户可以远程连接的意思。

步骤10 安装MySQL 的java 连接工具

在MobaXterm中打开一个新的Session,在节点1上安装mysql-connector-java。

[root@cgznode-0001 ~]# yum -y install mysql-connector-java

2.2 部署Hive

步骤 1: 准备Hive组件包

执行下面命令(输出略):

[root@cgznode-0001 ~]# cp /home/extend_tools/apache-hive-2.3.3-bin.tar.gz /home/modules/
[root@cgznode-0001 ~]# cd /home/modules
[root@cgznode-0001 modules]# tar -zvxf apache-hive-2.3.3-bin.tar.gz
[root@cgznode-0001 modules]# mv apache-hive-2.3.3-bin hive-2.3.3
[root@cgznode-0001 modules]# ls
apache-hive-2.3.3-bin.tar.gz  data  hadoop-2.8.3  hbase-2.1.0  hive-2.3.3

步骤2:拷贝jar 连接文件到Hive 指定目录中

cp /usr/share/java/mysql-connector-java.jar /home/modules/hive-2.3.3/lib/

步骤3: 配置hive-site.xml

执行命令:

vim /home/modules/hive-2.3.3/conf/hive-site.xml

录入如下内容:

<configuration>
        <property>
                <name>javax.jdo.option.ConnectionURL</name>
                <value>jdbc:mysql://[你自己的节点1名称]:3306/hive_metadata?createDatabaseIfNotExist=true</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>[你的mysql的root用户密码]</value>
        </property>
        <property>
                <name>hive.strict.checks.cartesian.product</name>
                <value>false</value>
        </property>
</configuration>

步骤 4: 配置hive-env.sh

复制一份hive-env.sh 的模板文件,并修改它:

cp /home/modules/hive-2.3.3/conf/hive-env.sh.template /home/modules/hive-2.3.3/conf/hive-env.sh
vim /home/modules/hive-2.3.3/conf/hive-env.sh

在文件hive-env.sh的末尾添加:

HADOOP_HOME=/home/modules/hadoop-2.8.3

步骤 5: 初始化MySQL数据库

[root@cgznode-0001 modules]# cd /home/modules/hive-2.3.3/bin
[root@cgznode-0001 bin]# ./schematool -initSchema -dbType mysql
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/home/modules/hive-2.3.3/lib/log4j-slf4j-impl-2.6.2.jar!/org/slfass]
SLF4J: Found binding in [jar:file:/home/modules/hadoop-2.8.3/share/hadoop/common/lib/slf4j-log4j12taticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.apache.logging.slf4j.Log4jLoggerFactory]
Metastore connection URL:        jdbc:mysql://cgzNode-0001:3306/hive_metadata?createDatabaseIfNotE
Metastore Connection Driver :    com.mysql.jdbc.Driver
Metastore connection User:       root
Starting metastore schema initialization to 2.3.0
Initialization script hive-schema-2.3.0.mysql.sql
Initialization script completed
schemaTool completed

步骤6: 分发Hive组件

当然,须在节点1下执行:

[root@cgznode-0001 bin]# for i in {2..4};do scp -r /home/modules/hive-2.3.3 root@cgzNode-000${i}:/home/modules/;done

上述命令是一个Bash shell的脚本命令,执行了一个循环。注意:

root@cgzNode-000${i}

一定要替换成你自己的节点名称模式。比如说,你的节点为zs-0001,zs-0002,zs-0003和zs-0004这四个名称,则上面应替换成:

root@zs-000${i}

步骤7 配置环境变量

4个节点上都要分别配置

[root@cgznode-0001 bin]# vim /etc/profile

在/etc/profile的文件末尾,添加:

export HIVE_HOME=/home/modules/hive-2.3.3
export PATH=$HIVE_HOME/bin:$PATH

4个节点上都要分别配置执行命令,使环境变量生效:

[root@cgznode-0001 bin]# source /etc/profile

2.3 启动Hive并验证基本功能

如下图:
启动Hive并验证基本功能
注意:要退出Hive环境,请在hive提示符后输入:exit;。不要忘记加英文分号。

3 总结

从上面的安装部署过程中可以看出,1) 对于MySQL来说,基本上解压缩文件包后,就是相关的设置、服务启动、账号设置、远程连接设置等,这是与Windows系统中安装软件不一样的地方;2)对于Hive来说,解压缩,然后配置、初始化MySQL、 Hive分发、设置环境变量等。整个部署过程与通常情况下的(Windows系统)安装很不一样,希望大家适应。同时,也能感受到,在Linux下,软件的安装是很便利的,都是自动化的指令,避免了界面的手工操作,但也对不会Linux的同学带来了障碍。如何克服障碍,那就是学习。

  • 2
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值