如遇到特殊情况 请安装
yum install -y unzip zip
yum install net-tools
yum install perl
#解压hive包
tar -zxvf /opt/software/apache-hive-2.0.0-bin.tar.gz -C /opt
#改名
mv /opt/apache-hive-2.0.0-bin /opt/hive
# 关闭防火墙服务
[root@master ~]# systemctl stop firewalld
# 设置防火墙服务开机不启动
[root@master ~]# systemctl disable firewalld
# 查询已安装的mariadb软件包
[root@ master ~]# rpm -qa | grep mariadb
# 卸载mariadb软件包
[root@master ~]# rpm -e --nodeps mariadb-libs-5.5.56-2.el7.x86_64
#安装
[root@master ~]# rpm -ivh mysql-community-common-5.7.32-1.el7.x86_64.rpm --nodeps --force
[root@master ~]# rpm -ivh mysql-community-libs-5.7.32-1.el7.x86_64.rpm --nodeps --force
[root@master ~]# rpm -ivh mysql-community-libs-compat-5.7.32-1.el7.x86_64.rpm --nodeps --force
[root@master ~]# rpm -ivh mysql-community-client-5.7.32-1.el7.x86_64.rpm --nodeps --force
[root@master ~]# rpm -ivh mysql-community-server-5.7.32-1.el7.x86_64.rpm --nodeps --force
2.配置/etc/my.cnf文件
vi /etc/my.cnf
default-storage-engine=innodb
innodb_file_per_table
collation-server=utf8_general_ci
init-connect='SET NAMES utf8'
character-set-server=utf8
启动mysql
(4)启动 MySQL 数据库。
[root@master ~]# systemctl start mysqld
(5)查看数据库状态
[root@master ~]# systemctl status mysqld
(6)查询 MySQL 数据库默认密码。
MySQL 数据库安装后的默认密码保存在/var/log/mysqld.log 文件中,在该文件中以
password 关键字搜索默认密码。
[root@master ~]# cat /var/log/mysqld.log | grep password
2020-05-07T02:34:03.336724Z 1 [Note] A temporary password is
generated for root@localhost: MPg5lhk4?>Ui # 默 认 密 码 为
MPg5lhk4?>Ui
(7)MySQL 数据库初始化。
MySQL 数据库是安装后随机生成的,所以每次安装后生成的默认密码不相同。
(7)MySQL 数据库初始化。
执行 mysql_secure_installation 命令初始化 MySQL 数据库,初始化过程中需要设定
数据库 root 用户登录密码,密码需符合安全规则,包括大小写字符、数字和特殊符号,
可设定密码为 Password123$。
在进行 MySQL 数据库初始化过程中会出现以下交互确认信息:
1)Change the password for root ? ((Press y|Y for Yes, any other key for
No)表示是否更改 root 用户密码,在键盘输入 y 和回车。
2)Do you wish to continue with the password provided?(Press y|Y for Yes,
any other key for No)表示是否使用设定的密码继续,在键盘输入 y 和回车。
3)Remove anonymous users? (Press y|Y for Yes, any other key for No)表示是
否删除匿名用户,在键盘输入 y 和回车。
4)Disallow root login remotely? (Press y|Y for Yes, any other key for No)
表示是否拒绝 root 用户远程登录,在键盘输入 n 和回车,表示允许 root 用户远程登录。
5)Remove test database and access to it? (Press y|Y for Yes, any other key
for No)表示是否删除测试数据库,在键盘输入 y 和回车。
6)Reload privilege tables now? (Press y|Y for Yes, any other key for No)
表示是否重新加载授权表,在键盘输入 y 和回车。
mysql_secure_installation 命令执行过程如下:
执行命令如下
mysql_secure_installation 命令执行过程如下:
[root@master ~]# mysql_secure_installation
Securing the MySQL server deployment.
Enter password for user root: # 输入/var/log/mysqld.log 文件中查询
到的默认 root 用户登录密码
The 'validate_password' plugin is installed on the server.
The subsequent steps will run with the existing configuration
of the plugin.
Using existing password for root.
Estimated strength of the password: 100
Change the password for root ? ((Press y|Y for Yes, any other
key for No) : y
New password: # 输入新密码 Password123$
Re-enter new password: # 再次输入新密码 Password123$
Estimated strength of the password: 100
Do you wish to continue with the password provided?(Press y|Y
for Yes, any other key for No) : y # 输入 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.
Remove anonymous users? (Press y|Y for Yes, any other key for
No) : y # 输入 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.
Disallow root login remotely? (Press y|Y for Yes, any other key
for No) : n # 输入 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.
Remove test database and access to it? (Press y|Y for Yes, any
other key for No) : y # 输入 y
- Dropping test database...
Success.
- Removing privileges on test database...
Success.
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) : y # 输入 y
Success.
All done!
(8)添加 root 用户从本地和远程访问 MySQL 数据库表单的授权。
[root@master ~]# mysql -uroot -p
#添加root用户本地访问授权
grant all privileges on *.* to root@'master' identified by 'ioRu:g9tHwMe'; 自己设定的密码
grant all privileges on *.* to root@'master' identified by 'Password123$';
# 添加root用户远程访问授权
grant all privileges on *.* to root@'%' identified by 'ioRu:g9tHwMe';
grant all privileges on *.* to root@'%' identified by 'Password123$';
# 刷新授权
flush privileges;
# 查询root用户授权情况
select user,host from mysql.user where user='root';
修改 Hive 组件配置文件。
corf文件中 cp hive-env.sh.template hive-env.sh
export HADOOP_HOME=/opt/hadoop
export HIVE_CONF_DIR=/opt/hive/conf
export HIVE_AUX_JARS_PATH=/opt/hive/lib
vi /etc/profile
export HIVE_HOME=/usr/local/src/hive
export PATH=$PATH:$HIVE_HOME/bin
#更新配置
[root@master ~]# source /etc/profile
将/opt/hive/conf 文件夹下 hive-default.xml.template 文件,更名为 hive-site.xml。
cd /opt/hive/conf/
cp hive-default.xml.template hive-site.xml
[root@master hive] mkdir tmp
vi /opt/hive/conf/hive-site.xml
#搜索javax.jdo.option.ConnectionURL,将该name对应的value修改为MySQL的地址
<name>javax.jdo.option.ConnectionURL</name>
<value>jdbc:mysql://master:3306/hive?createDatabaseIfNotExist=true&useSSL=false</value>
<description>JDBC connect string for a JDBC metastore</description>
#搜索javax.jdo.option.ConnectionDriverName,将该name对应的value修改为MySQL驱动类路径
<name>javax.jdo.option.ConnectionDriverName</name>
<value>com.mysql.jdbc.Driver</value>
#搜索javax.jdo.option.ConnectionUserName,将对应的value修改为MySQL数据库登录名
<name>javax.jdo.option.ConnectionUserName</name>
<value>root</value>
#搜索javax.jdo.option.ConnectionPassword
<name>javax.jdo.option.ConnectionPassword</name>
<value>ioRu:g9tHwMe</value> Password123$
#搜索hive.metastore.schema.verification
<name>hive.metastore.schema.verification</name>
<value>false</value>
#配置4处
<name>hive.querylog.location</name>
<value>/opt/hive/tmp</value>
<name>hive.exec.local.scratchdir</name>
<value>/opt/hive/tmp</value>
<name>hive.downloaded.resources.dir</name>
<value>/opt/hive/tmp/resources</value>
<name>hive.server2.logging.operation.log.location</name>
<value>/opt/hive/tmp/operation_logs</value>
将 MySQL 数据库驱动(/opt/mysql-connector-java-5.1.46.jar)拷贝到 Hive 安装目录的 lib 下;
cp /opt/mysql-connector-java-5.1.46.jar /opt/hive/lib/
重启hadoop 启动hive
#重启hadoop
[hadoop@master lib]$ stop-all.sh
[hadoop@master lib]$ start-all.sh
#进入到hive的bin目录执行命令:
cd /opt/hive/bin
# 对数据库进行初始化,执行命令:
schematool -initSchema -dbType mysql
[hadoop@master ~]$schematool -initSchema -dbType mysql
# 执行hive脚本
./hive