CentOS 7系统环境准备
本文仅以hdp-01为例:
1、修改hosts文件(hdp-01、hdp-02、hdp-03)
vi /etc/hosts
192.168.31.131 hdp-01
192.168.31.132 hdp-02
192.168.31.133 hdp-03
2、查看并关闭防火墙(hdp-01、hdp-02、hdp-03)
查看防火墙状态命令:systemctl status firewalld
active(running)就意味着防火墙打开了
关闭命令:
- systemctl stop firewalld(临时关闭,立即生效,重启后开启)
- systemctl disable firewalld(永久关闭,重启后生效)
打开防火墙命令: - systemctl start firewalld(临时打开,立即生效,重启后关闭)
- systemctl enable firewalld(永久开启,重启后生效)
这里我们采用永久关闭的方式:
执行systemctl disable firewalld
再执行systemctl stop firewalld
这样不用重启直接生效
执行后状态变为inactive(dead)说明防火墙已关闭
3、关闭SELINUX(hdp-01、hdp-02、hdp-03)
vi /etc/selinux/config
修改SELINUX=enforcing为SELINUX=disabled
重启后生效
4、时钟同步(hdp-01、hdp-02、hdp-03)
方式一:从国内通用时间服务器同步时间(本文用此方法)
安装配置ntp同步阿里云时间服务器
yum -y install ntp
ntpdate cn.pool.ntp.org 从国内通用时间服务器同步时间
crontab定时同步时间
crontab -e 后加入以下文本
*/5 * * * * /usr/sbin/ntpdate cn.pool.ntp.org 每5分钟定时执行ntpdate命令同步时间
其他ntp常用时间服务器:
- NTP服务器(上海) :ntp.api.bz
- 中国国家授时中心:210.72.145.44
- 美国:time.nist.gov
- 复旦:ntp.fudan.edu.cn
- 微软公司授时主机(美国) :time.windows.com
- 台警大授时中心(台湾):asia.pool.ntp.org
关闭ntp:
systemctl stop ntpd
启动ntp:
systemctl start ntpd
systemctl enable ntpd --开机自动启动,重启生效
查看crontab是否执行
tail -f /var/log/cron
方式二:hdp-02、hdp-03同步hdp-01时间
#hdp-01
yum install -y ntp
vi /etc/ntp.conf
server 127.127.1.0
fudge 127.127.1.0 stratum 10
systemctl start ntpd
systemctl enbale ntpd
#hdp-02
yum install -y ntpdate
ntpdate hdp-01
#hdp-03
yum install -y ntpdate
ntpdate hdp-01
5、添加hadoop用户及设置sudo权限(hdp-01、hdp-02、hdp-03)
5.1.添加用户组hadoop
groupadd hadoop
5.2.添加hadoop用户,并归属于hadoop组
useradd -g hadoop hadoop 第一个hadoop是组
5.3.给hadoop用户修改密码
passwd hadoop
[root@hdp-01 ~]# groupadd hadoop
[root@hdp-01 ~]# useradd -g hadoop hadoop
[root@hdp-01 ~]# passwd hadoop
Changing password for user hadoop.
New password:
BAD PASSWORD: The password is shorter than 8 characters
Retype new password:
passwd: all authentication tokens updated successfully.
[root@hdp-01 ~]#
5.4.给用户组或用户添加sudo权限
先给sudoers文件添加写权限
chmod -v u+w /etc/sudoers
[root@hdp-01 etc]# chmod -v u+w /etc/sudoers
mode of ‘/etc/sudoers’ changed from 0440 (r--r-----) to 0640 (rw-r-----)
[root@hdp-01 etc]# vi /etc/sudoers
sudoers文件末尾加上
hadoop ALL=(ALL) NOPASSWD: ALL
最后取消sudoers 文件可写权限
chmod -v u-w /etc/sudoers
扩展:
- 组内所有用户都可以执行sudo,且不用密码:%dev ALL=(ALL) NOPASSWD: ALL
- 用户可以执行sudo,且不用密码:hadoop ALL=(ALL) NOPASSWD: ALL
- 用户可以执行sudo:hadoop ALL=(ALL) ALL
6、免密登录设置(hdp-01、hdp-02、hdp-03)
方式一(本文用此方法)
ssh-keygen //执行命令一路回车,生成秘钥
[hadoop@hdp-01 .ssh]$ ll
-rw------- 1 hadoop hadoop 1679 Dec 8 16:18 id_rsa
-rw------- 1 hadoop hadoop 395 Dec 8 16:18 id_rsa.pub
-rw------- 1 hadoop hadoop 549 Dec 8 16:50 known_hosts
[hadoop@hdp-01 .ssh]$ cat id_rsa.pub >> .ssh/authorized_keys
[hadoop@hdp-03 .ssh]$ ll
-rw-------. 1 hadoop hadoop 1185 Dec 8 16:50 authorized_keys
-rw-------. 1 hadoop hadoop 1679 Dec 8 16:41 id_rsa
-rw-------. 1 hadoop hadoop 395 Dec 8 16:41 id_rsa.pub
权限设置
[hadoop@hdp-01 .ssh]$ chmod 700 .ssh
[hadoop@hdp-01 .ssh]$ chmod 600 .ssh/*
- PS:这个权限很关键,严格按照这个分配,安装过程将hdp-01的authorized_keys文件的权限设置为664,结果hdp-01能免密登录hdp-02、hdp-03,hdp-02与hdp-03也可以相互免密登录,但hdp-02和hdp-03无法免密登录hdp-01,折腾了我一天@_@
将hdp-02和hdp-03的id_rsa.pub拷贝到hdp-01的authorized_keys文件
[hadoop@hdp-02 .ssh]$ cat ~/.ssh/id_rsa.pub| ssh hadoop@hdp-01 'cat >> ~/.ssh/authorized_keys'
[hadoop@hdp-03 .ssh]$ cat ~/.ssh/id_rsa.pub| ssh hadoop@hdp-01 'cat >> ~/.ssh/authorized_keys'
然后将hdp-01的authorized_keys拷贝到hdp-02和hdp-03
[hadoop@hdp-01 .ssh]$ scp ~/.ssh/authorized_keyshadoop@hdp-02:~/.ssh/authorized_keys
[hadoop@hdp-01 .ssh]$ scp ~/.ssh/authorized_keyshadoop@hdp-03:~/.ssh/authorized_keys
免密登录设置成功,第一次登录需要输入yes
[hadoop@hdp-01 .ssh]$ ssh hdp-02
Last login: Thu Dec 10 10:18:42 2020
[hadoop@hdp-02 ~]$ ssh hdp-03
Last login: Thu Dec 10 10:19:01 2020
[hadoop@hdp-03 ~]$ exit;
logout
Connection to hdp-03 closed.
[hadoop@hdp-02 ~]$ exit;
logout
Connection to hdp-02 closed.
[hadoop@hdp-01 .ssh]$
方式二
#hpd-01
ssh-keygen
ssh-copy-id hdp-01
ssh-copy-id hdp-02
ssh-copy-id hdp-03
#hdp-02
ssh-keygen
ssh-copy-id hdp-01
ssh-copy-id hdp-02
ssh-copy-id hdp-03
#hdp-03
ssh-keygen
ssh-copy-id hdp-01
ssh-copy-id hdp-02
ssh-copy-id hdp-03
7、安装rz/sz命令(hdp-01)
[root@hdp-01 ~]# rz
-bash: rz: command not found
[root@hdp-01 ~]# yum install -y lrzsz
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.163.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
base | 3.6 kB 00:00:00
extras | 2.9 kB 00:00:00
updates | 2.9 kB 00:00:00
Resolving Dependencies
--> Running transaction check
---> Package lrzsz.x86_64 0:0.12.20-36.el7 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
=========================================================================================================================================================
Package Arch Version Repository Size
=========================================================================================================================================================
Installing:
lrzsz x86_64 0.12.20-36.el7 base 78 k
Transaction Summary
=========================================================================================================================================================
Install 1 Package
Total download size: 78 k
Installed size: 181 k
Downloading packages:
lrzsz-0.12.20-36.el7.x86_64.rpm | 78 kB 00:00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : lrzsz-0.12.20-36.el7.x86_64 1/1
Verifying : lrzsz-0.12.20-36.el7.x86_64 1/1
Installed:
lrzsz.x86_64 0:0.12.20-36.el7
Complete!
[root@hdp-01 ~]#
8、JDK安装(hdp-01、hdp-02、hdp-03)
将JDK安装包上传到服务器,比如:/root
[root@hdp-01 ~]# mkdir /usr/java
[root@hdp-01 ~]# mv /root/jdk-8u141-linux-x64.tar.gz /usr/java/
[root@hdp-01 ~]# cd /usr/java
[root@hdp-01 java]# tar -zxvf jdk-8u141-linux-x64.tar.gz
[root@hdp-01 java]# ll
total 181172
drwxr-xr-x 8 10 143 255 Jul 12 2017 jdk1.8.0_141
-rw-r--r-- 1 root root 185516505 Nov 30 11:55 jdk-8u141-linux-x64.tar.gz
[root@hdp-01 java]# vi /etc/profile
//在最后添加:
#java
export JAVA_HOME=/usr/java/jdk1.8.0_141
export CLASSPATH=.:${JAVA_HOME}/jre/lib/rt.jar:${JAVA_HOME}/lib/dt.jar:${JAVA_HOME}/lib/tools.jar
export PATH=$PATH:${JAVA_HOME}/bin
[root@hdp-01 java]# source /etc/profile //使环境变量生效
[root@hdp-01 java]# java -version
java version "1.8.0_141"
Java(TM) SE Runtime Environment (build 1.8.0_141-b15)
Java HotSpot(TM) 64-Bit Server VM (build 25.141-b15, mixed mode)
完成之后删除jdk安装包
[root@hdp-01 java]# rm -f jdk-8u141-linux-x64.tar.gz
[root@hdp-01 java]# ll
total 0
drwxr-xr-x 8 10 143 255 Jul 12 2017 jdk1.8.0_141
直接将jdk1.8.0_141文件夹拷贝到hdp-02和hdp-03;然后修改/etc/profile配置即可完成hdp-02和hdp-03的jdk安装
[root@hdp-01 java]# scp -r /usr/java/jdk1.8.0_141 root@hdp-02:/usr/java/
[root@hdp-01 java]# scp -r /usr/java/jdk1.8.0_141 root@hdp-03:/usr/java/
9、安装http服务(hdp-01)
[root@hdp-01 ~]# yum install -y httpd
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.163.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
base | 3.6 kB 00:00:00
extras | 2.9 kB 00:00:00
updates | 2.9 kB 00:00:00
Resolving Dependencies
--> Running transaction check
---> Package httpd.x86_64 0:2.4.6-97.el7.centos will be installed
--> Processing Dependency: httpd-tools = 2.4.6-97.el7.centos for package: httpd-2.4.6-97.el7.centos.x86_64
--> Processing Dependency: /etc/mime.types for package: httpd-2.4.6-97.el7.centos.x86_64
--> Processing Dependency: libaprutil-1.so.0()(64bit) for package: httpd-2.4.6-97.el7.centos.x86_64
--> Processing Dependency: libapr-1.so.0()(64bit) for package: httpd-2.4.6-97.el7.centos.x86_64
--> Running transaction check
---> Package apr.x86_64 0:1.4.8-7.el7 will be installed
---> Package apr-util.x86_64 0:1.5.2-6.el7 will be installed
---> Package httpd-tools.x86_64 0:2.4.6-97.el7.centos will be installed
---> Package mailcap.noarch 0:2.1.41-2.el7 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
=========================================================================================================================================================
Package Arch Version Repository Size
=========================================================================================================================================================
Installing:
httpd x86_64 2.4.6-97.el7.centos updates 2.7 M
Installing for dependencies:
apr x86_64 1.4.8-7.el7 base 104 k
apr-util x86_64 1.5.2-6.el7 base 92 k
httpd-tools x86_64 2.4.6-97.el7.centos updates 93 k
mailcap noarch 2.1.41-2.el7 base 31 k
Transaction Summary
=========================================================================================================================================================
Install 1 Package (+4 Dependent packages)
Total download size: 3.0 M
Installed size: 10 M
Downloading packages:
(1/5): httpd-tools-2.4.6-97.el7.centos.x86_64.rpm | 93 kB 00:00:00
(2/5): apr-util-1.5.2-6.el7.x86_64.rpm | 92 kB 00:00:00
(3/5): apr-1.4.8-7.el7.x86_64.rpm | 104 kB 00:00:00
(4/5): mailcap-2.1.41-2.el7.noarch.rpm | 31 kB 00:00:00
(5/5): httpd-2.4.6-97.el7.centos.x86_64.rpm | 2.7 MB 00:00:01
---------------------------------------------------------------------------------------------------------------------------------------------------------
Total 2.2 MB/s | 3.0 MB 00:00:01
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : apr-1.4.8-7.el7.x86_64 1/5
Installing : apr-util-1.5.2-6.el7.x86_64 2/5
Installing : httpd-tools-2.4.6-97.el7.centos.x86_64 3/5
Installing : mailcap-2.1.41-2.el7.noarch 4/5
Installing : httpd-2.4.6-97.el7.centos.x86_64 5/5
Verifying : httpd-2.4.6-97.el7.centos.x86_64 1/5
Verifying : apr-1.4.8-7.el7.x86_64 2/5
Verifying : mailcap-2.1.41-2.el7.noarch 3/5
Verifying : httpd-tools-2.4.6-97.el7.centos.x86_64 4/5
Verifying : apr-util-1.5.2-6.el7.x86_64 5/5
Installed:
httpd.x86_64 0:2.4.6-97.el7.centos
Dependency Installed:
apr.x86_64 0:1.4.8-7.el7 apr-util.x86_64 0:1.5.2-6.el7 httpd-tools.x86_64 0:2.4.6-97.el7.centos mailcap.noarch 0:2.1.41-2.el7
Complete!
[root@hdp-01 ~]# systemctl start httpd
相关命令如下:
第一、启动、终止、重启
systemctl start httpd.service #启动
systemctl stop httpd.service #停止
systemctl restart httpd.service #重启
第二、设置开机启动/关闭
systemctl enable httpd.service #开机启动
systemctl disable httpd.service #开机不启动
第三、检查httpd状态
systemctl status httpd.service
10、本地yum
[root@hdp-01 ~]# mkdir /var/www/html/{ambari-2.7,hdp3.0,hdp-utils-1.1.0.22}
[root@hdp-01 ~]# tar -zxvf HDP-UTILS-1.1.0.22-centos7.tar.gz -C /var/www/html/hdp-utils-1.1.0.22
[root@hdp-01 ~]# tar -zxvf ambari-2.7.4.0-centos7.tar.gz -C /var/www/html/ambari-2.7/
[root@hdp-01 ~]# tar -zxvf HDP-3.0.0.0-centos7-rpm.tar.gz -C /var/www/html/hdp3.0
[root@hdp-01 ~]# yum install -y wget
[root@hdp-01 ~]# wget http://public-repo-1.hortonworks.com/ambari/centos7/2.x/updates/2.7.1.0/ambari.repo
配置ambari的yum源
[root@hdp-01 ~]# vi /etc/yum.repos.d/ambari.repo
#输入如下内容
[ambari]
name=ambari
baseurl=http://192.168.31.131/ambari/centos7/2.7.1.0-169/
gpgcheck=0
[HDP]
name=HDP
baseurl=http://192.168.31.131/hdp3.0/HDP/centos7/3.0.0.0-1634/
gpgcheck=0
[HDP-UTILS]
name=HDP_UTILS
baseurl=http://192.168.31.131/HDP-UTILS/centos7/1.1.0.22/
gpgcheck=0
[HDP-GPL]
name=HDP-GPL
baseurl=http://192.168.31.131/HDP-GPL/centos7/3.0.0.0-1634/
gpgcheck=0
验证
[root@hdp-01 yum.repos.d]# yum repolist
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.163.com
* extras: mirrors.nju.edu.cn
* updates: mirrors.aliyun.com
HDP | 2.9 kB 00:00:00
http://192.168.31.131/hdp-utils-1.1.0.21/HDP-UTILS/centos7/1.1.0.22/repodata/repomd.xml: [Errno 14] HTTP Error 404 - Not Found
Trying other mirror.
To address this issue please refer to the below wiki article
https://wiki.centos.org/yum-errors
If above article doesn't help to resolve this issue please use https://bugs.centos.org/.
HDP/primary_db | 88 kB 00:00:00
http://192.168.31.131/hdp-utils-1.1.0.21/HDP-UTILS/centos7/1.1.0.22/repodata/repomd.xml: [Errno 14] HTTP Error 404 - Not Found
Trying other mirror.
http://192.168.31.131/ambari/ambari-2.7/centos7/2.7.0.0-897/repodata/repomd.xml: [Errno 14] HTTP Error 404 - Not Found
Trying other mirror.
repo id repo name status
HDP HDP 195
HDP-UTILS HDP_UTILS 0
ambari ambari 0
base/7/x86_64 CentOS-7 - Base 10,072
extras/7/x86_64 CentOS-7 - Extras 448
updates/7/x86_64 CentOS-7 - Updates 778
repolist: 11,493
将yum文件使用scp发送到其它节点
[root@hdp-01 ~]# scp /etc/yum.repos.d/ambari.repo hdp-02:/etc/yum.repos.d/
[root@hdp-01 ~]# scp /etc/yum.repos.d/ambari.repo hdp-03:/etc/yum.repos.d/
11、MYSQL安装
安装wget
[root@hdp-01 etc]# yum install wget
下载MySQL YUM源rpm安装包
[root@hdp-01 etc]# wget https://repo.mysql.com//mysql57-community-release-el7-11.noarch.rpm
安装MySQL 源
[root@hdp-01 etc]# yum localinstall mysql57-community-release-el7-11.noarch.rpm
Loaded plugins: fastestmirror
Examining mysql57-community-release-el7-11.noarch.rpm: mysql57-community-release-el7-11.noarch
Marking mysql57-community-release-el7-11.noarch.rpm to be installed
Resolving Dependencies
--> Running transaction check
---> Package mysql57-community-release.noarch 0:el7-11 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
============================================================================================================================================================================
Package Arch Version Repository Size
============================================================================================================================================================================
Installing:
mysql57-community-release noarch el7-11 /mysql57-community-release-el7-11.noarch 31 k
Transaction Summary
============================================================================================================================================================================
Install 1 Package
Total size: 31 k
Installed size: 31 k
Is this ok [y/d/N]: y
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : mysql57-community-release-el7-11.noarch 1/1
Verifying : mysql57-community-release-el7-11.noarch 1/1
Installed:
mysql57-community-release.noarch 0:el7-11
Complete!
安装MySQL
[root@hdp-01 etc]# yum install mysql-community-server
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
HDP | 2.9 kB 00:00:00
HDP-GPL | 2.9 kB 00:00:00
HDP-UTILS | 2.9 kB 00:00:00
ambari | 2.9 kB 00:00:00
base | 3.6 kB 00:00:00
extras | 2.9 kB 00:00:00
mysql-connectors-community | 2.6 kB 00:00:00
mysql-tools-community | 2.6 kB 00:00:00
mysql57-community | 2.6 kB 00:00:00
updates | 2.9 kB 00:00:00
(1/3): mysql-connectors-community/x86_64/primary_db | 68 kB 00:00:00
(2/3): mysql-tools-community/x86_64/primary_db | 83 kB 00:00:01
(3/3): mysql57-community/x86_64/primary_db | 247 kB 00:00:01
Resolving Dependencies
--> Running transaction check
---> Package mysql-community-server.x86_64 0:5.7.32-1.el7 will be installed
--> Processing Dependency: mysql-community-common(x86-64) = 5.7.32-1.el7 for package: mysql-community-server-5.7.32-1.el7.x86_64
--> Processing Dependency: mysql-community-client(x86-64) >= 5.7.9 for package: mysql-community-server-5.7.32-1.el7.x86_64
--> Running transaction check
---> Package mysql-community-client.x86_64 0:5.7.32-1.el7 will be installed
--> Processing Dependency: mysql-community-libs(x86-64) >= 5.7.9 for package: mysql-community-client-5.7.32-1.el7.x86_64
---> Package mysql-community-common.x86_64 0:5.7.32-1.el7 will be installed
--> Running transaction check
---> Package mariadb-libs.x86_64 1:5.5.60-1.el7_5 will be obsoleted
--> Processing Dependency: libmysqlclient.so.18()(64bit) for package: 2:postfix-2.10.1-7.el7.x86_64
--> Processing Dependency: libmysqlclient.so.18(libmysqlclient_18)(64bit) for package: 2:postfix-2.10.1-7.el7.x86_64
---> Package mysql-community-libs.x86_64 0:5.7.32-1.el7 will be obsoleting
--> Running transaction check
---> Package mysql-community-libs-compat.x86_64 0:5.7.32-1.el7 will be obsoleting
---> Package postfix.x86_64 2:2.10.1-7.el7 will be updated
---> Package postfix.x86_64 2:2.10.1-9.el7 will be an update
--> Finished Dependency Resolution
Dependencies Resolved
============================================================================================================================================================================
Package Arch Version Repository Size
============================================================================================================================================================================
Installing:
mysql-community-libs x86_64 5.7.32-1.el7 mysql57-community 2.3 M
replacing mariadb-libs.x86_64 1:5.5.60-1.el7_5
mysql-community-libs-compat x86_64 5.7.32-1.el7 mysql57-community 1.2 M
replacing mariadb-libs.x86_64 1:5.5.60-1.el7_5
mysql-community-server x86_64 5.7.32-1.el7 mysql57-community 173 M
Installing for dependencies:
mysql-community-client x86_64 5.7.32-1.el7 mysql57-community 25 M
mysql-community-common x86_64 5.7.32-1.el7 mysql57-community 308 k
Updating for dependencies:
postfix x86_64 2:2.10.1-9.el7 base 2.4 M
Transaction Summary
============================================================================================================================================================================
Install 3 Packages (+2 Dependent packages)
Upgrade ( 1 Dependent package)
Total download size: 205 M
Is this ok [y/d/N]: y
Downloading packages:
Delta RPMs disabled because /usr/bin/applydeltarpm not installed.
warning: /var/cache/yum/x86_64/7/mysql57-community/packages/mysql-community-common-5.7.32-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY0:02:51 ETA
Public key for mysql-community-common-5.7.32-1.el7.x86_64.rpm is not installed
(1/6): mysql-community-common-5.7.32-1.el7.x86_64.rpm | 308 kB 00:00:03
(2/6): mysql-community-client-5.7.32-1.el7.x86_64.rpm | 25 MB 00:00:09
(3/6): mysql-community-libs-compat-5.7.32-1.el7.x86_64.rpm | 1.2 MB 00:00:00
(4/6): mysql-community-libs-5.7.32-1.el7.x86_64.rpm | 2.3 MB 00:00:07
(5/6): postfix-2.10.1-9.el7.x86_64.rpm | 2.4 MB 00:00:01
(6/6): mysql-community-server-5.7.32-1.el7.x86_64.rpm | 173 MB 00:00:36
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total 4.4 MB/s | 205 MB 00:00:46
Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
Importing GPG key 0x5072E1F5:
Userid : "MySQL Release Engineering <mysql-build@oss.oracle.com>"
Fingerprint: a4a9 4068 76fc bd3c 4567 70c8 8c71 8d3b 5072 e1f5
Package : mysql57-community-release-el7-11.noarch (installed)
From : /etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
Is this ok [y/N]: y
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : mysql-community-common-5.7.32-1.el7.x86_64 1/8
Installing : mysql-community-libs-5.7.32-1.el7.x86_64 2/8
Installing : mysql-community-client-5.7.32-1.el7.x86_64 3/8
Installing : mysql-community-libs-compat-5.7.32-1.el7.x86_64 4/8
Updating : 2:postfix-2.10.1-9.el7.x86_64 5/8
Installing : mysql-community-server-5.7.32-1.el7.x86_64 6/8
Cleanup : 2:postfix-2.10.1-7.el7.x86_64 7/8
Erasing : 1:mariadb-libs-5.5.60-1.el7_5.x86_64 8/8
Verifying : 2:postfix-2.10.1-9.el7.x86_64 1/8
Verifying : mysql-community-client-5.7.32-1.el7.x86_64 2/8
Verifying : mysql-community-libs-compat-5.7.32-1.el7.x86_64 3/8
Verifying : mysql-community-libs-5.7.32-1.el7.x86_64 4/8
Verifying : mysql-community-server-5.7.32-1.el7.x86_64 5/8
Verifying : mysql-community-common-5.7.32-1.el7.x86_64 6/8
Verifying : 2:postfix-2.10.1-7.el7.x86_64 7/8
Verifying : 1:mariadb-libs-5.5.60-1.el7_5.x86_64 8/8
Installed:
mysql-community-libs.x86_64 0:5.7.32-1.el7 mysql-community-libs-compat.x86_64 0:5.7.32-1.el7 mysql-community-server.x86_64 0:5.7.32-1.el7
Dependency Installed:
mysql-community-client.x86_64 0:5.7.32-1.el7 mysql-community-common.x86_64 0:5.7.32-1.el7
Dependency Updated:
postfix.x86_64 2:2.10.1-9.el7
Replaced:
mariadb-libs.x86_64 1:5.5.60-1.el7_5
Complete!
安装jdbc驱动
[root@hdp-01 ~]# yum install mysql-connector-java
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.163.com
* extras: mirrors.163.com
* updates: mirrors.163.com
Resolving Dependencies
--> Running transaction check
---> Package mysql-connector-java.noarch 1:8.0.22-1.el7 will be installed
--> Processing Dependency: java-headless >= 1:1.8.0 for package: 1:mysql-connector-java-8.0.22-1.el7.noarch
--> Running transaction check
---> Package java-1.8.0-openjdk-headless.x86_64 1:1.8.0.275.b01-0.el7_9 will be installed
--> Processing Dependency: tzdata-java >= 2020a for package: 1:java-1.8.0-openjdk-headless-1.8.0.275.b01-0.el7_9.x86_64
--> Processing Dependency: copy-jdk-configs >= 3.3 for package: 1:java-1.8.0-openjdk-headless-1.8.0.275.b01-0.el7_9.x86_64
--> Processing Dependency: pcsc-lite-libs(x86-64) for package: 1:java-1.8.0-openjdk-headless-1.8.0.275.b01-0.el7_9.x86_64
--> Processing Dependency: lksctp-tools(x86-64) for package: 1:java-1.8.0-openjdk-headless-1.8.0.275.b01-0.el7_9.x86_64
--> Processing Dependency: jpackage-utils for package: 1:java-1.8.0-openjdk-headless-1.8.0.275.b01-0.el7_9.x86_64
--> Processing Dependency: cups-libs(x86-64) for package: 1:java-1.8.0-openjdk-headless-1.8.0.275.b01-0.el7_9.x86_64
--> Running transaction check
---> Package copy-jdk-configs.noarch 0:3.3-10.el7_5 will be installed
---> Package cups-libs.x86_64 1:1.6.3-51.el7 will be installed
---> Package javapackages-tools.noarch 0:3.4.1-11.el7 will be installed
--> Processing Dependency: python-javapackages = 3.4.1-11.el7 for package: javapackages-tools-3.4.1-11.el7.noarch
---> Package lksctp-tools.x86_64 0:1.0.17-2.el7 will be installed
---> Package pcsc-lite-libs.x86_64 0:1.8.8-8.el7 will be installed
---> Package tzdata-java.noarch 0:2020d-2.el7 will be installed
--> Running transaction check
---> Package python-javapackages.noarch 0:3.4.1-11.el7 will be installed
--> Processing Dependency: python-lxml for package: python-javapackages-3.4.1-11.el7.noarch
--> Running transaction check
---> Package python-lxml.x86_64 0:3.2.1-4.el7 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
============================================================================================================================================================================
Package Arch Version Repository Size
============================================================================================================================================================================
Installing:
mysql-connector-java noarch 1:8.0.22-1.el7 mysql-connectors-community 2.2 M
Installing for dependencies:
copy-jdk-configs noarch 3.3-10.el7_5 base 21 k
cups-libs x86_64 1:1.6.3-51.el7 base 359 k
java-1.8.0-openjdk-headless x86_64 1:1.8.0.275.b01-0.el7_9 updates 33 M
javapackages-tools noarch 3.4.1-11.el7 base 73 k
lksctp-tools x86_64 1.0.17-2.el7 base 88 k
pcsc-lite-libs x86_64 1.8.8-8.el7 base 34 k
python-javapackages noarch 3.4.1-11.el7 base 31 k
python-lxml x86_64 3.2.1-4.el7 base 758 k
tzdata-java noarch 2020d-2.el7 updates 189 k
Transaction Summary
============================================================================================================================================================================
Install 1 Package (+9 Dependent packages)
Total download size: 37 M
Installed size: 117 M
Is this ok [y/d/N]: y
Downloading packages:
(1/10): copy-jdk-configs-3.3-10.el7_5.noarch.rpm | 21 kB 00:00:00
(2/10): javapackages-tools-3.4.1-11.el7.noarch.rpm | 73 kB 00:00:00
(3/10): pcsc-lite-libs-1.8.8-8.el7.x86_64.rpm | 34 kB 00:00:00
(4/10): python-javapackages-3.4.1-11.el7.noarch.rpm | 31 kB 00:00:00
(5/10): cups-libs-1.6.3-51.el7.x86_64.rpm | 359 kB 00:00:00
(6/10): python-lxml-3.2.1-4.el7.x86_64.rpm | 758 kB 00:00:00
(7/10): tzdata-java-2020d-2.el7.noarch.rpm | 189 kB 00:00:00
(8/10): lksctp-tools-1.0.17-2.el7.x86_64.rpm | 88 kB 00:00:01
(9/10): java-1.8.0-openjdk-headless-1.8.0.275.b01-0.el7_9.x86_64.rpm | 33 MB 00:00:06
(10/10): mysql-connector-java-8.0.22-1.el7.noarch.rpm | 2.2 MB 00:03:50
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total 163 kB/s | 37 MB 00:03:51
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : pcsc-lite-libs-1.8.8-8.el7.x86_64 1/10
Installing : tzdata-java-2020d-2.el7.noarch 2/10
Installing : lksctp-tools-1.0.17-2.el7.x86_64 3/10
Installing : python-lxml-3.2.1-4.el7.x86_64 4/10
Installing : python-javapackages-3.4.1-11.el7.noarch 5/10
Installing : javapackages-tools-3.4.1-11.el7.noarch 6/10
Installing : copy-jdk-configs-3.3-10.el7_5.noarch 7/10
Installing : 1:cups-libs-1.6.3-51.el7.x86_64 8/10
Installing : 1:java-1.8.0-openjdk-headless-1.8.0.275.b01-0.el7_9.x86_64 9/10
Installing : 1:mysql-connector-java-8.0.22-1.el7.noarch 10/10
Verifying : 1:cups-libs-1.6.3-51.el7.x86_64 1/10
Verifying : 1:java-1.8.0-openjdk-headless-1.8.0.275.b01-0.el7_9.x86_64 2/10
Verifying : copy-jdk-configs-3.3-10.el7_5.noarch 3/10
Verifying : python-javapackages-3.4.1-11.el7.noarch 4/10
Verifying : python-lxml-3.2.1-4.el7.x86_64 5/10
Verifying : 1:mysql-connector-java-8.0.22-1.el7.noarch 6/10
Verifying : javapackages-tools-3.4.1-11.el7.noarch 7/10
Verifying : lksctp-tools-1.0.17-2.el7.x86_64 8/10
Verifying : tzdata-java-2020d-2.el7.noarch 9/10
Verifying : pcsc-lite-libs-1.8.8-8.el7.x86_64 10/10
Installed:
mysql-connector-java.noarch 1:8.0.22-1.el7
Dependency Installed:
copy-jdk-configs.noarch 0:3.3-10.el7_5 cups-libs.x86_64 1:1.6.3-51.el7 java-1.8.0-openjdk-headless.x86_64 1:1.8.0.275.b01-0.el7_9
javapackages-tools.noarch 0:3.4.1-11.el7 lksctp-tools.x86_64 0:1.0.17-2.el7 pcsc-lite-libs.x86_64 0:1.8.8-8.el7
python-javapackages.noarch 0:3.4.1-11.el7 python-lxml.x86_64 0:3.2.1-4.el7 tzdata-java.noarch 0:2020d-2.el7
Complete!
You have new mail in /var/spool/mail/root
启动
[root@hdp-01 etc]# systemctl start mysqld
[root@hdp-01 etc]# systemctl status mysqld
● mysqld.service - MySQL Server
Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
Active: active (running) since Fri 2020-12-11 13:56:42 CST; 20s ago
Docs: man:mysqld(8)
http://dev.mysql.com/doc/refman/en/using-systemd.html
Process: 2308 ExecStart=/usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid $MYSQLD_OPTS (code=exited, status=0/SUCCESS)
Process: 2257 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS)
Main PID: 2310 (mysqld)
CGroup: /system.slice/mysqld.service
└─2310 /usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid
Dec 11 13:56:38 hdp-01 systemd[1]: Starting MySQL Server...
Dec 11 13:56:42 hdp-01 systemd[1]: Started MySQL Server.
查看默认密码
[root@hdp-01 etc]# cat /var/log/mysqld.log |grep password
2020-12-11T05:56:40.118990Z 1 [Note] A temporary password is generated for root@localhost: y>tQqlJJ042F
2020-12-11T05:58:25.236069Z 2 [Note] Access denied for user 'root'@'localhost' (using password: NO)
2020-12-11T05:59:09.535613Z 3 [Note] Access denied for user 'root'@'localhost' (using password: NO)
[root@hdp-01 etc]# mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.7.32
Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> alter user 'root'@'localhost' identified by 'mysql';
ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
解决报错
修改两个全局参数:
首先,修改validate_password_policy参数的值
mysql> set global validate_password_policy=0;
再修改密码的长度
set global validate_password_length=1;
mysql> set global validate_password_policy=0;
Query OK, 0 rows affected (0.00 sec)
mysql> set global validate_password_length=1;
Query OK, 0 rows affected (0.00 sec)
mysql> alter user 'root'@'localhost' identified by 'root';
Query OK, 0 rows affected (0.00 sec)
mysql> use mysql;
Database changed
mysql> create database ambari default charset utf8 collate utf8_general_ci;#新建ambari数据库
Query OK, 1 row affected (0.00 sec)
mysql> create user 'ambari'@'%' identified by 'ambari';#新建ambari用户
Query OK, 0 rows affected (0.00 sec)
mysql> grant all privileges on ambari.* to 'ambari'@'%';#分配ambari权限
Query OK, 0 rows affected (0.00 sec)
mysql> flush privileges;#刷新系统权限表
创建Hive Oozie数据库和用户
mysql> create database hive default charset utf8 collate utf8_general_ci;
Query OK, 1 row affected (0.00 sec)
mysql> create user 'hive'@'%' identified by 'hive';
Query OK, 0 rows affected (0.00 sec)
mysql> grant all privileges on hive.* to 'hive'@'%';
Query OK, 0 rows affected (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
mysql> create database Oozie default charset utf8 collate utf8_general_ci;
Query OK, 1 row affected (0.00 sec)
mysql> create user 'Oozie'@'%' identified by 'Oozie';
Query OK, 0 rows affected (0.00 sec)
mysql> grant all privileges on Oozie.* to 'Oozie'@'%';
Query OK, 0 rows affected (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)