部署Ambari Server实战案例

                            作者:尹正杰

版权声明:原创作品,谢绝转载!否则将追究法律责任。

一.准备三台虚拟机(需要自行安装jdk环境)

1>.角色分配

  NameNode节点:
    hdp101.yinzhengjie.org.cn   DataNode节点:
    hdp101.yinzhengjie.org.cn
    hdp102.yinzhengjie.org.cn
    hdp103.yinzhengjie.org.cn   MySQL服务器:
    hdp101.yinzhengjie.org.cn
    
  YUM源仓库服务器:
    hdp101.yinzhengjie.org.cn

2>.内存分配(根据物理机情况合理分配即可)

hdp101.yinzhengjie.org.cn:
10G-16G,推荐12G hdp102.yinzhengjie.org.cn:
3G-6G,推荐6G hdp103.yinzhengjie.org.cn:
3G-6G,推荐6G

 

二.配置SSH免密码登录

1>.生成秘钥并配置与本机的免密登录

[root@hdp101.yinzhengjie.org.cn ~]# ssh-keygen -t rsa -P '' -f ~/.ssh/id_rsa
Generating public/private rsa key pair.
Created directory '/root/.ssh'.
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:1q/IHVpogVivEj03C8ef3kUpJuDsGgaPT+PU5m8aycY root@hdp101.yinzhengjie.org.cn
The key's randomart image is:
+---[RSA ]----+
| |
| |
| . . |
| + * o . |
| + = S o o o |
| = % B = o |
| o O E = . . |
| B X B.+ . |
| + *+= . |
+----[SHA256]-----+
[root@hdp101.yinzhengjie.org.cn ~]#
[root@hdp101.yinzhengjie.org.cn ~]# ll ~/.ssh/id_rsa
-rw------- root root Jan : /root/.ssh/id_rsa
[root@hdp101.yinzhengjie.org.cn ~]#
[root@hdp101.yinzhengjie.org.cn ~]#

2>.配置hdp101.yinzhengjie.org.cn节点到其他节点免密登陆

[root@hdp101.yinzhengjie.org.cn ~]# ssh-copy-id root@hdp101.yinzhengjie.org.cn
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/root/.ssh/id_rsa.pub"
The authenticity of host 'hdp101.yinzhengjie.org.cn (172.200.1.101)' can't be established.
ECDSA key fingerprint is SHA256:y6iS5ipSyWSGRmgcjivbWhd78pKfrcuQHeBPd5H9/U8.
ECDSA key fingerprint is MD5:da:0f:2a::c0:d4:6e:7e::::f1::a7::.
Are you sure you want to continue connecting (yes/no)? yes
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/usr/bin/ssh-copy-id: INFO: key(s) remain to be installed -- if you are prompted now it is to install the new keys
root@hdp101.yinzhengjie.org.cn's password: Number of key(s) added: Now try logging into the machine, with: "ssh 'root@hdp101.yinzhengjie.org.cn'"
and check to make sure that only the key(s) you wanted were added. [root@hdp101.yinzhengjie.org.cn ~]#
[root@hdp101.yinzhengjie.org.cn ~]# who
root tty1 -- :
root pts/ -- : (172.200.0.1)
[root@hdp101.yinzhengjie.org.cn ~]#
[root@hdp101.yinzhengjie.org.cn ~]# ssh hdp101.yinzhengjie.org.cn
Last login: Tue Jan :: from 172.200.0.1
[root@hdp101.yinzhengjie.org.cn ~]#
[root@hdp101.yinzhengjie.org.cn ~]# who
root tty1 -- :
root pts/ -- : (172.200.0.1)
root pts/ -- : (172.200.1.101)
[root@hdp101.yinzhengjie.org.cn ~]#
[root@hdp101.yinzhengjie.org.cn ~]# exit
logout
Connection to hdp101.yinzhengjie.org.cn closed.
[root@hdp101.yinzhengjie.org.cn ~]#
[root@hdp101.yinzhengjie.org.cn ~]#

[root@hdp101.yinzhengjie.org.cn ~]# ssh-copy-id root@hdp101.yinzhengjie.org.cn

[root@hdp101.yinzhengjie.org.cn ~]# ssh-copy-id root@hdp102.yinzhengjie.org.cn
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/root/.ssh/id_rsa.pub"
The authenticity of host 'hdp102.yinzhengjie.org.cn (172.200.1.102)' can't be established.
ECDSA key fingerprint is SHA256:y6iS5ipSyWSGRmgcjivbWhd78pKfrcuQHeBPd5H9/U8.
ECDSA key fingerprint is MD5:da:0f:2a::c0:d4:6e:7e::::f1::a7::.
Are you sure you want to continue connecting (yes/no)? yes
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/usr/bin/ssh-copy-id: INFO: key(s) remain to be installed -- if you are prompted now it is to install the new keys
root@hdp102.yinzhengjie.org.cn's password: Number of key(s) added: Now try logging into the machine, with: "ssh 'root@hdp102.yinzhengjie.org.cn'"
and check to make sure that only the key(s) you wanted were added. [root@hdp101.yinzhengjie.org.cn ~]#
[root@hdp101.yinzhengjie.org.cn ~]#
[root@hdp101.yinzhengjie.org.cn ~]# who
root tty1 -- :
root pts/ -- : (172.200.0.1)
[root@hdp101.yinzhengjie.org.cn ~]#
[root@hdp101.yinzhengjie.org.cn ~]# ssh hdp102.yinzhengjie.org.cn
Last login: Tue Jan :: from 172.200.0.1
[root@hdp102.yinzhengjie.org.cn ~]#
[root@hdp102.yinzhengjie.org.cn ~]# who
root tty1 -- :
root pts/ -- : (172.200.0.1)
root pts/ -- : (172.200.1.101)
[root@hdp102.yinzhengjie.org.cn ~]#
[root@hdp102.yinzhengjie.org.cn ~]# exit
logout
Connection to hdp102.yinzhengjie.org.cn closed.
[root@hdp101.yinzhengjie.org.cn ~]#
[root@hdp101.yinzhengjie.org.cn ~]# who
root tty1 -- :
root pts/ -- : (172.200.0.1)
[root@hdp101.yinzhengjie.org.cn ~]#
[root@hdp101.yinzhengjie.org.cn ~]#

[root@hdp101.yinzhengjie.org.cn ~]# ssh-copy-id root@hdp102.yinzhengjie.org.cn

[root@hdp101.yinzhengjie.org.cn ~]# ssh-copy-id root@hdp103.yinzhengjie.org.cn
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/root/.ssh/id_rsa.pub"
The authenticity of host 'hdp103.yinzhengjie.org.cn (172.200.1.103)' can't be established.
ECDSA key fingerprint is SHA256:y6iS5ipSyWSGRmgcjivbWhd78pKfrcuQHeBPd5H9/U8.
ECDSA key fingerprint is MD5:da:0f:2a::c0:d4:6e:7e::::f1::a7::.
Are you sure you want to continue connecting (yes/no)? yes
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/usr/bin/ssh-copy-id: INFO: key(s) remain to be installed -- if you are prompted now it is to install the new keys
root@hdp103.yinzhengjie.org.cn's password: Number of key(s) added: Now try logging into the machine, with: "ssh 'root@hdp103.yinzhengjie.org.cn'"
and check to make sure that only the key(s) you wanted were added. [root@hdp101.yinzhengjie.org.cn ~]#
[root@hdp101.yinzhengjie.org.cn ~]# who
root tty1 -- :
root pts/ -- : (172.200.0.1)
[root@hdp101.yinzhengjie.org.cn ~]#
[root@hdp101.yinzhengjie.org.cn ~]# ssh hdp103.yinzhengjie.org.cn
Last login: Tue Jan :: from 172.200.0.1
[root@hdp103.yinzhengjie.org.cn ~]#
[root@hdp103.yinzhengjie.org.cn ~]# who
root tty1 -- :
root pts/ -- : (172.200.0.1)
root pts/ -- : (172.200.1.101)
[root@hdp103.yinzhengjie.org.cn ~]#
[root@hdp103.yinzhengjie.org.cn ~]# exit
logout
Connection to hdp103.yinzhengjie.org.cn closed.
[root@hdp101.yinzhengjie.org.cn ~]#
[root@hdp101.yinzhengjie.org.cn ~]# who
root tty1 -- :
root pts/ -- : (172.200.0.1)
[root@hdp101.yinzhengjie.org.cn ~]#
[root@hdp101.yinzhengjie.org.cn ~]#

[root@hdp101.yinzhengjie.org.cn ~]# ssh-copy-id root@hdp103.yinzhengjie.org.cn

3>.如果配置高可用的话,我们需要备用节点也需要到其它服务器进行免密登录(比如,我们选择hdp103.yinzhengjie.org.cn作为备用节点,则重复以上2个步骤即可)

[root@hdp103.yinzhengjie.org.cn ~]# ll ~/.ssh/
total
-rw------- root root Jan : authorized_keys
[root@hdp103.yinzhengjie.org.cn ~]#
[root@hdp103.yinzhengjie.org.cn ~]# ssh-keygen -t rsa -P '' -f ~/.ssh/id_rsa
Generating public/private rsa key pair.
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:Z4CmAntTl08/PU8yLhCE2baL8P2visnOmTrjY8iB7Fo root@hdp103.yinzhengjie.org.cn
The key's randomart image is:
+---[RSA ]----+
| +. |
| o+o |
|. . =.+. |
| o ..+ o.+ . |
|o.+ .o oS.= = . |
|.o.o o o+ o * |
|..Eo .. . . |
| oo =o = .. |
|o oo*O ...o. |
+----[SHA256]-----+
[root@hdp103.yinzhengjie.org.cn ~]#
[root@hdp103.yinzhengjie.org.cn ~]# ll ~/.ssh/
total
-rw------- root root Jan : authorized_keys
-rw------- root root Jan : id_rsa
-rw-r--r-- root root Jan : id_rsa.pub
[root@hdp103.yinzhengjie.org.cn ~]#
[root@hdp103.yinzhengjie.org.cn ~]#

[root@hdp103.yinzhengjie.org.cn ~]# ssh-keygen -t rsa -P '' -f ~/.ssh/id_rsa

[root@hdp103.yinzhengjie.org.cn ~]# ssh-copy-id root@hdp101.yinzhengjie.org.cn
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/root/.ssh/id_rsa.pub"
The authenticity of host 'hdp101.yinzhengjie.org.cn (172.200.1.101)' can't be established.
ECDSA key fingerprint is SHA256:y6iS5ipSyWSGRmgcjivbWhd78pKfrcuQHeBPd5H9/U8.
ECDSA key fingerprint is MD5:da:0f:2a::c0:d4:6e:7e::::f1::a7::.
Are you sure you want to continue connecting (yes/no)? yes
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/usr/bin/ssh-copy-id: INFO: key(s) remain to be installed -- if you are prompted now it is to install the new keys
root@hdp101.yinzhengjie.org.cn's password: Number of key(s) added: Now try logging into the machine, with: "ssh 'root@hdp101.yinzhengjie.org.cn'"
and check to make sure that only the key(s) you wanted were added. [root@hdp103.yinzhengjie.org.cn ~]#
[root@hdp103.yinzhengjie.org.cn ~]# who
root tty1 -- :
root pts/ -- : (172.200.0.1)
[root@hdp103.yinzhengjie.org.cn ~]#
[root@hdp103.yinzhengjie.org.cn ~]# ssh hdp101.yinzhengjie.org.cn
Last login: Tue Jan :: from 172.200.1.101
[root@hdp101.yinzhengjie.org.cn ~]#
[root@hdp101.yinzhengjie.org.cn ~]# who
root tty1 -- :
root pts/ -- : (172.200.0.1)
root pts/ -- : (172.200.1.103)
[root@hdp101.yinzhengjie.org.cn ~]#
[root@hdp101.yinzhengjie.org.cn ~]# exit
logout
Connection to hdp101.yinzhengjie.org.cn closed.
[root@hdp103.yinzhengjie.org.cn ~]#
[root@hdp103.yinzhengjie.org.cn ~]# who
root tty1 -- :
root pts/ -- : (172.200.0.1)
[root@hdp103.yinzhengjie.org.cn ~]#
[root@hdp103.yinzhengjie.org.cn ~]#

[root@hdp103.yinzhengjie.org.cn ~]# ssh-copy-id root@hdp101.yinzhengjie.org.cn

[root@hdp103.yinzhengjie.org.cn ~]# who
root tty1 -- :
root pts/ -- : (172.200.0.1)
[root@hdp103.yinzhengjie.org.cn ~]#
[root@hdp103.yinzhengjie.org.cn ~]# ssh-copy-id root@hdp102.yinzhengjie.org.cn
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/root/.ssh/id_rsa.pub"
The authenticity of host 'hdp102.yinzhengjie.org.cn (172.200.1.102)' can't be established.
ECDSA key fingerprint is SHA256:y6iS5ipSyWSGRmgcjivbWhd78pKfrcuQHeBPd5H9/U8.
ECDSA key fingerprint is MD5:da:0f:2a::c0:d4:6e:7e::::f1::a7::.
Are you sure you want to continue connecting (yes/no)? yes
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/usr/bin/ssh-copy-id: INFO: key(s) remain to be installed -- if you are prompted now it is to install the new keys
root@hdp102.yinzhengjie.org.cn's password: Number of key(s) added: Now try logging into the machine, with: "ssh 'root@hdp102.yinzhengjie.org.cn'"
and check to make sure that only the key(s) you wanted were added. [root@hdp103.yinzhengjie.org.cn ~]#
[root@hdp103.yinzhengjie.org.cn ~]# ssh hdp102.yinzhengjie.org.cn
Last login: Tue Jan :: from 172.200.1.101
[root@hdp102.yinzhengjie.org.cn ~]#
[root@hdp102.yinzhengjie.org.cn ~]# who
root tty1 -- :
root pts/ -- : (172.200.0.1)
root pts/ -- : (172.200.1.103)
[root@hdp102.yinzhengjie.org.cn ~]#
[root@hdp102.yinzhengjie.org.cn ~]# exit
logout
Connection to hdp102.yinzhengjie.org.cn closed.
[root@hdp103.yinzhengjie.org.cn ~]#
[root@hdp103.yinzhengjie.org.cn ~]# who
root tty1 -- :
root pts/ -- : (172.200.0.1)
[root@hdp103.yinzhengjie.org.cn ~]#
[root@hdp103.yinzhengjie.org.cn ~]#

[root@hdp103.yinzhengjie.org.cn ~]# ssh-copy-id root@hdp102.yinzhengjie.org.cn

[root@hdp103.yinzhengjie.org.cn ~]# ssh-copy-id root@hdp103.yinzhengjie.org.cn
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/root/.ssh/id_rsa.pub"
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/usr/bin/ssh-copy-id: INFO: key(s) remain to be installed -- if you are prompted now it is to install the new keys
root@hdp103.yinzhengjie.org.cn's password: Number of key(s) added: Now try logging into the machine, with: "ssh 'root@hdp103.yinzhengjie.org.cn'"
and check to make sure that only the key(s) you wanted were added. [root@hdp103.yinzhengjie.org.cn ~]#
[root@hdp103.yinzhengjie.org.cn ~]# who
root tty1 -- :
root pts/ -- : (172.200.0.1)
[root@hdp103.yinzhengjie.org.cn ~]#
[root@hdp103.yinzhengjie.org.cn ~]# ssh hdp103.yinzhengjie.org.cn
Last login: Tue Jan :: from 172.200.1.101
[root@hdp103.yinzhengjie.org.cn ~]#
[root@hdp103.yinzhengjie.org.cn ~]# who
root tty1 -- :
root pts/ -- : (172.200.0.1)
root pts/ -- : (172.200.1.103)
[root@hdp103.yinzhengjie.org.cn ~]#
[root@hdp103.yinzhengjie.org.cn ~]# exit
logout
Connection to hdp103.yinzhengjie.org.cn closed.
[root@hdp103.yinzhengjie.org.cn ~]#
[root@hdp103.yinzhengjie.org.cn ~]# who
root tty1 -- :
root pts/ -- : (172.200.0.1)
[root@hdp103.yinzhengjie.org.cn ~]#
[root@hdp103.yinzhengjie.org.cn ~]#

[root@hdp103.yinzhengjie.org.cn ~]# ssh-copy-id root@hdp103.yinzhengjie.org.cn

4>.安装ansible

[root@hdp101.yinzhengjie.org.cn ~]# yum -y install ansible
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirror.bit.edu.cn
* extras: mirrors.tuna.tsinghua.edu.cn
* updates: mirror.bit.edu.cn
Resolving Dependencies
--> Running transaction check
---> Package ansible.noarch :2.4.2.0-.el7 will be installed
--> Processing Dependency: sshpass for package: ansible-2.4.2.0-.el7.noarch
--> Processing Dependency: python2-jmespath for package: ansible-2.4.2.0-.el7.noarch
--> Processing Dependency: python-six for package: ansible-2.4.2.0-.el7.noarch
--> Processing Dependency: python-setuptools for package: ansible-2.4.2.0-.el7.noarch
--> Processing Dependency: python-passlib for package: ansible-2.4.2.0-.el7.noarch
--> Processing Dependency: python-paramiko for package: ansible-2.4.2.0-.el7.noarch
--> Processing Dependency: python-jinja2 for package: ansible-2.4.2.0-.el7.noarch
--> Processing Dependency: python-httplib2 for package: ansible-2.4.2.0-.el7.noarch
--> Processing Dependency: python-cryptography for package: ansible-2.4.2.0-.el7.noarch
--> Processing Dependency: PyYAML for package: ansible-2.4.2.0-.el7.noarch
--> Running transaction check
---> Package PyYAML.x86_64 :3.10-.el7 will be installed
--> Processing Dependency: libyaml-.so.()(64bit) for package: PyYAML-3.10-.el7.x86_64
---> Package python-httplib2.noarch :0.9.-.el7 will be installed
---> Package python-jinja2.noarch :2.7.-.el7 will be installed
--> Processing Dependency: python-babel >= 0.8 for package: python-jinja2-2.7.-.el7.noarch
--> Processing Dependency: python-markupsafe for package: python-jinja2-2.7.-.el7.noarch
---> Package python-paramiko.noarch :2.1.-.el7 will be installed
--> Processing Dependency: python2-pyasn1 for package: python-paramiko-2.1.-.el7.noarch
---> Package python-passlib.noarch :1.6.-.el7 will be installed
---> Package python-setuptools.noarch :0.9.-.el7 will be installed
--> Processing Dependency: python-backports-ssl_match_hostname for package: python-setuptools-0.9.-.el7.noarch
---> Package python-six.noarch :1.9.-.el7 will be installed
---> Package python2-cryptography.x86_64 :1.7.-.el7 will be installed
--> Processing Dependency: python-idna >= 2.0 for package: python2-cryptography-1.7.-.el7.x86_64
--> Processing Dependency: python-cffi >= 1.4. for package: python2-cryptography-1.7.-.el7.x86_64
--> Processing Dependency: python-ipaddress for package: python2-cryptography-1.7.-.el7.x86_64
--> Processing Dependency: python-enum34 for package: python2-cryptography-1.7.-.el7.x86_64
---> Package python2-jmespath.noarch :0.9.-.el7 will be installed
---> Package sshpass.x86_64 :1.06-.el7 will be installed
--> Running transaction check
---> Package libyaml.x86_64 :0.1.-.el7_0 will be installed
---> Package python-babel.noarch :0.9.-.el7 will be installed
---> Package python-backports-ssl_match_hostname.noarch :3.5.0.1-.el7 will be installed
--> Processing Dependency: python-backports for package: python-backports-ssl_match_hostname-3.5.0.1-.el7.noarch
---> Package python-cffi.x86_64 :1.6.-.el7 will be installed
--> Processing Dependency: python-pycparser for package: python-cffi-1.6.-.el7.x86_64
---> Package python-enum34.noarch :1.0.-.el7 will be installed
---> Package python-idna.noarch :2.4-.el7 will be installed
---> Package python-ipaddress.noarch :1.0.-.el7 will be installed
---> Package python-markupsafe.x86_64 :0.11-.el7 will be installed
---> Package python2-pyasn1.noarch :0.1.-.el7 will be installed
--> Running transaction check
---> Package python-backports.x86_64 :1.0-.el7 will be installed
---> Package python-pycparser.noarch :2.14-.el7 will be installed
--> Processing Dependency: python-ply for package: python-pycparser-2.14-.el7.noarch
--> Running transaction check
---> Package python-ply.noarch :3.4-.el7 will be installed
--> Finished Dependency Resolution Dependencies Resolved =======================================================================================================================================================
Package Arch Version Repository Size
=======================================================================================================================================================
Installing:
ansible noarch 2.4.2.0-.el7 extras 7.6 M
Installing for dependencies:
PyYAML x86_64 3.10-.el7 base k
libyaml x86_64 0.1.-.el7_0 base k
python-babel noarch 0.9.-.el7 base 1.4 M
python-backports x86_64 1.0-.el7 base 5.8 k
python-backports-ssl_match_hostname noarch 3.5.0.1-.el7 base k
python-cffi x86_64 1.6.-.el7 base k
python-enum34 noarch 1.0.-.el7 base k
python-httplib2 noarch 0.9.-.el7 extras k
python-idna noarch 2.4-.el7 base k
python-ipaddress noarch 1.0.-.el7 base k
python-jinja2 noarch 2.7.-.el7 base k
python-markupsafe x86_64 0.11-.el7 base k
python-paramiko noarch 2.1.-.el7 base k
python-passlib noarch 1.6.-.el7 extras k
python-ply noarch 3.4-.el7 base k
python-pycparser noarch 2.14-.el7 base k
python-setuptools noarch 0.9.-.el7 base k
python-six noarch 1.9.-.el7 base k
python2-cryptography x86_64 1.7.-.el7 base k
python2-jmespath noarch 0.9.-.el7 extras k
python2-pyasn1 noarch 0.1.-.el7 base k
sshpass x86_64 1.06-.el7 extras k Transaction Summary
=======================================================================================================================================================
Install Package (+ Dependent packages) Total download size: M
Installed size: M
Downloading packages:
(/): PyYAML-3.10-.el7.x86_64.rpm | kB ::
(/): libyaml-0.1.-.el7_0.x86_64.rpm | kB ::
(/): python-backports-1.0-.el7.x86_64.rpm | 5.8 kB ::
(/): python-backports-ssl_match_hostname-3.5.0.1-.el7.noarch.rpm | kB ::
(/): python-cffi-1.6.-.el7.x86_64.rpm | kB ::
(/): python-enum34-1.0.-.el7.noarch.rpm | kB ::
(/): python-idna-2.4-.el7.noarch.rpm | kB ::
(/): python-ipaddress-1.0.-.el7.noarch.rpm | kB ::
(/): python-babel-0.9.-.el7.noarch.rpm | 1.4 MB ::
(/): python-markupsafe-0.11-.el7.x86_64.rpm | kB ::
(/): python-httplib2-0.9.-.el7.noarch.rpm | kB ::
(/): python-passlib-1.6.-.el7.noarch.rpm | kB ::
(/): python-pycparser-2.14-.el7.noarch.rpm | kB ::
(/): python-paramiko-2.1.-.el7.noarch.rpm | kB ::
(/): python-jinja2-2.7.-.el7.noarch.rpm | kB ::
(/): python-setuptools-0.9.-.el7.noarch.rpm | kB ::
(/): python-six-1.9.-.el7.noarch.rpm | kB ::
(/): python-ply-3.4-.el7.noarch.rpm | kB ::
(/): python2-pyasn1-0.1.-.el7.noarch.rpm | kB ::
(/): python2-jmespath-0.9.-.el7.noarch.rpm | kB ::
(/): python2-cryptography-1.7.-.el7.x86_64.rpm | kB ::
(/): sshpass-1.06-.el7.x86_64.rpm | kB ::
(/): ansible-2.4.2.0-.el7.noarch.rpm | 7.6 MB ::
-------------------------------------------------------------------------------------------------------------------------------------------------------
Total 3.7 MB/s | MB ::
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : python2-pyasn1-0.1.-.el7.noarch /
Installing : python-ipaddress-1.0.-.el7.noarch /
Installing : python-six-1.9.-.el7.noarch /
Installing : python-httplib2-0.9.-.el7.noarch /
Installing : sshpass-1.06-.el7.x86_64 /
Installing : libyaml-0.1.-.el7_0.x86_64 /
Installing : PyYAML-3.10-.el7.x86_64 /
Installing : python-backports-1.0-.el7.x86_64 /
Installing : python-backports-ssl_match_hostname-3.5.0.1-.el7.noarch /
Installing : python-setuptools-0.9.-.el7.noarch /
Installing : python-babel-0.9.-.el7.noarch /
Installing : python-passlib-1.6.-.el7.noarch /
Installing : python-ply-3.4-.el7.noarch /
Installing : python-pycparser-2.14-.el7.noarch /
Installing : python-cffi-1.6.-.el7.x86_64 /
Installing : python-markupsafe-0.11-.el7.x86_64 /
Installing : python-jinja2-2.7.-.el7.noarch /
Installing : python-idna-2.4-.el7.noarch /
Installing : python-enum34-1.0.-.el7.noarch /
Installing : python2-cryptography-1.7.-.el7.x86_64 /
Installing : python-paramiko-2.1.-.el7.noarch /
Installing : python2-jmespath-0.9.-.el7.noarch /
Installing : ansible-2.4.2.0-.el7.noarch /
Verifying : python-backports-ssl_match_hostname-3.5.0.1-.el7.noarch /
Verifying : python2-jmespath-0.9.-.el7.noarch /
Verifying : python-enum34-1.0.-.el7.noarch /
Verifying : python-setuptools-0.9.-.el7.noarch /
Verifying : python-jinja2-2.7.-.el7.noarch /
Verifying : python-six-1.9.-.el7.noarch /
Verifying : python-idna-2.4-.el7.noarch /
Verifying : python-markupsafe-0.11-.el7.x86_64 /
Verifying : python-ply-3.4-.el7.noarch /
Verifying : python-passlib-1.6.-.el7.noarch /
Verifying : python-paramiko-2.1.-.el7.noarch /
Verifying : python-babel-0.9.-.el7.noarch /
Verifying : python-backports-1.0-.el7.x86_64 /
Verifying : python-cffi-1.6.-.el7.x86_64 /
Verifying : python-pycparser-2.14-.el7.noarch /
Verifying : libyaml-0.1.-.el7_0.x86_64 /
Verifying : ansible-2.4.2.0-.el7.noarch /
Verifying : python-ipaddress-1.0.-.el7.noarch /
Verifying : sshpass-1.06-.el7.x86_64 /
Verifying : python-httplib2-0.9.-.el7.noarch /
Verifying : python2-pyasn1-0.1.-.el7.noarch /
Verifying : PyYAML-3.10-.el7.x86_64 /
Verifying : python2-cryptography-1.7.-.el7.x86_64 / Installed:
ansible.noarch :2.4.2.0-.el7 Dependency Installed:
PyYAML.x86_64 :3.10-.el7 libyaml.x86_64 :0.1.-.el7_0 python-babel.noarch :0.9.-.el7
python-backports.x86_64 :1.0-.el7 python-backports-ssl_match_hostname.noarch :3.5.0.1-.el7 python-cffi.x86_64 :1.6.-.el7
python-enum34.noarch :1.0.-.el7 python-httplib2.noarch :0.9.-.el7 python-idna.noarch :2.4-.el7
python-ipaddress.noarch :1.0.-.el7 python-jinja2.noarch :2.7.-.el7 python-markupsafe.x86_64 :0.11-.el7
python-paramiko.noarch :2.1.-.el7 python-passlib.noarch :1.6.-.el7 python-ply.noarch :3.4-.el7
python-pycparser.noarch :2.14-.el7 python-setuptools.noarch :0.9.-.el7 python-six.noarch :1.9.-.el7
python2-cryptography.x86_64 :1.7.-.el7 python2-jmespath.noarch :0.9.-.el7 python2-pyasn1.noarch :0.1.-.el7
sshpass.x86_64 :1.06-.el7 Complete!
[root@hdp101.yinzhengjie.org.cn ~]#

[root@hdp101.yinzhengjie.org.cn ~]# yum -y install ansible

  ansible基础命令使用可参考:
    https://www.cnblogs.com/yinzhengjie/p/10447587.html

5>.使用ansible工具验证免密配置

[root@hdp101.yinzhengjie.org.cn ~]# egrep -v "^#|^$" /etc/ansible/hosts
[hdp]
hdp[:].yinzhengjie.org.cn
[root@hdp101.yinzhengjie.org.cn ~]#
[root@hdp101.yinzhengjie.org.cn ~]#
[root@hdp101.yinzhengjie.org.cn ~]# ansible hdp -m ping
hdp102.yinzhengjie.org.cn | SUCCESS => {
"changed": false,
"ping": "pong"
}
hdp103.yinzhengjie.org.cn | SUCCESS => {
"changed": false,
"ping": "pong"
}
hdp101.yinzhengjie.org.cn | SUCCESS => {
"changed": false,
"ping": "pong"
}
[root@hdp101.yinzhengjie.org.cn ~]#
[root@hdp101.yinzhengjie.org.cn ~]# ansible hdp -m shell -a 'ln -s /yinzhengjie/softwares/jdk1.8.0_201/bin/jps /usr/local/bin/'
[WARNING]: Consider using file module with state=link rather than running ln hdp102.yinzhengjie.org.cn | SUCCESS | rc= >> hdp101.yinzhengjie.org.cn | SUCCESS | rc= >> hdp103.yinzhengjie.org.cn | SUCCESS | rc= >> [root@hdp101.yinzhengjie.org.cn ~]#

[root@hdp101.yinzhengjie.org.cn ~]# ansible hdp -m shell -a 'ln -s /yinzhengjie/softwares/jdk1.8.0_201/bin/jps /usr/local/bin/'

[root@hdp101.yinzhengjie.org.cn ~]# ansible hdp -m shell -a 'jps'
hdp102.yinzhengjie.org.cn | SUCCESS | rc= >>
Jps hdp103.yinzhengjie.org.cn | SUCCESS | rc= >>
Jps hdp101.yinzhengjie.org.cn | SUCCESS | rc= >>
Jps [root@hdp101.yinzhengjie.org.cn ~]#

[root@hdp101.yinzhengjie.org.cn ~]# ansible hdp -m shell -a 'jps'

三. 部署MySQL

1>.启用yum缓存(可以保存下载的安装包便于后期自制yum仓库)

[root@hdp101.yinzhengjie.org.cn ~]# grep keepcache /etc/yum.conf
keepcache=
[root@hdp101.yinzhengjie.org.cn ~]#
[root@hdp101.yinzhengjie.org.cn ~]# sed -r -i 's#(keepcache=)0#\11#g' /etc/yum.conf
[root@hdp101.yinzhengjie.org.cn ~]#
[root@hdp101.yinzhengjie.org.cn ~]# grep keepcache /etc/yum.conf
keepcache=
[root@hdp101.yinzhengjie.org.cn ~]#
[root@hdp101.yinzhengjie.org.cn ~]#

2>.安装MySQL8.0软件源

[root@hdp101.yinzhengjie.org.cn ~]# ll
total
[root@hdp101.yinzhengjie.org.cn ~]#
[root@hdp101.yinzhengjie.org.cn ~]# wget https://dev.mysql.com/get/mysql80-community-release-el7-3.noarch.rpm
---- ::-- https://dev.mysql.com/get/mysql80-community-release-el7-3.noarch.rpm
Resolving dev.mysql.com (dev.mysql.com)... 137.254.60.11
Connecting to dev.mysql.com (dev.mysql.com)|137.254.60.11|:... connected.
HTTP request sent, awaiting response... Found
Location: https://repo.mysql.com//mysql80-community-release-el7-3.noarch.rpm [following]
---- ::-- https://repo.mysql.com//mysql80-community-release-el7-3.noarch.rpm
Resolving repo.mysql.com (repo.mysql.com)... 23.60.72.128
Connecting to repo.mysql.com (repo.mysql.com)|23.60.72.128|:... connected.
HTTP request sent, awaiting response... OK
Length: (25K) [application/x-redhat-package-manager]
Saving to: ‘mysql80-community-release-el7-.noarch.rpm’ %[====================================================================================================================================================================================================================================>] , 152KB/s in .2s -- :: ( KB/s) - ‘mysql80-community-release-el7-.noarch.rpm’ saved [/] [root@hdp101.yinzhengjie.org.cn ~]#
[root@hdp101.yinzhengjie.org.cn ~]# ll
total
-rw-r--r-- root root Apr mysql80-community-release-el7-.noarch.rpm
[root@hdp101.yinzhengjie.org.cn ~]#
[root@hdp101.yinzhengjie.org.cn ~]#

[root@hdp101.yinzhengjie.org.cn ~]# wget https://dev.mysql.com/get/mysql80-community-release-el7-3.noarch.rpm          #下载软件源安装包

[root@hdp101.yinzhengjie.org.cn ~]# ll /etc/yum.repos.d/
total
-rw-r--r--. root root Nov CentOS-Base.repo
-rw-r--r--. root root Nov CentOS-CR.repo
-rw-r--r--. root root Nov CentOS-Debuginfo.repo
-rw-r--r--. root root Nov CentOS-fasttrack.repo
-rw-r--r--. root root Nov CentOS-Media.repo
-rw-r--r--. root root Nov CentOS-Sources.repo
-rw-r--r--. root root Nov CentOS-Vault.repo
[root@hdp101.yinzhengjie.org.cn ~]#
[root@hdp101.yinzhengjie.org.cn ~]# ll
total
-rw-r--r-- root root Apr mysql80-community-release-el7-.noarch.rpm
[root@hdp101.yinzhengjie.org.cn ~]#
[root@hdp101.yinzhengjie.org.cn ~]# rpm -ivh mysql80-community-release-el7-3.noarch.rpm
warning: mysql80-community-release-el7-.noarch.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing... ################################# [%]
Updating / installing...
:mysql80-community-release-el7- ################################# [%]
[root@hdp101.yinzhengjie.org.cn ~]#
[root@hdp101.yinzhengjie.org.cn ~]# ll /etc/yum.repos.d/
total
-rw-r--r--. root root Nov CentOS-Base.repo
-rw-r--r--. root root Nov CentOS-CR.repo
-rw-r--r--. root root Nov CentOS-Debuginfo.repo
-rw-r--r--. root root Nov CentOS-fasttrack.repo
-rw-r--r--. root root Nov CentOS-Media.repo
-rw-r--r--. root root Nov CentOS-Sources.repo
-rw-r--r--. root root Nov CentOS-Vault.repo
-rw-r--r-- 1 root root 2076 Apr 25 2019 mysql-community.repo
-rw-r--r-- 1 root root 2108 Apr 25 2019 mysql-community-source.repo
[root@hdp101.yinzhengjie.org.cn ~]#

3>.安装MySQL服务

[root@hdp101.yinzhengjie.org.cn ~]#  yum -y install  mysql-community-server
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirror.bit.edu.cn
* extras: mirror.bit.edu.cn
* updates: mirrors.tuna.tsinghua.edu.cn
base | 3.6 kB ::
extras | 2.9 kB ::
mysql-connectors-community | 2.5 kB ::
mysql-tools-community | 2.5 kB ::
mysql80-community | 2.5 kB ::
updates | 2.9 kB ::
(/): mysql80-community/x86_64/primary_db | kB ::
(/): mysql-connectors-community/x86_64/primary_db | kB ::
(/): mysql-tools-community/x86_64/primary_db | kB ::
Resolving Dependencies
--> Running transaction check
---> Package mysql-community-server.x86_64 :8.0.-.el7 will be installed
--> Processing Dependency: mysql-community-common(x86-) = 8.0.-.el7 for package: mysql-community-server-8.0.-.el7.x86_64
--> Processing Dependency: mysql-community-client(x86-) >= 8.0. for package: mysql-community-server-8.0.-.el7.x86_64
--> Running transaction check
---> Package mysql-community-client.x86_64 :8.0.-.el7 will be installed
--> Processing Dependency: mysql-community-libs(x86-) >= 8.0. for package: mysql-community-client-8.0.-.el7.x86_64
---> Package mysql-community-common.x86_64 :8.0.-.el7 will be installed
--> Running transaction check
---> Package mariadb-libs.x86_64 :5.5.-.el7_5 will be obsoleted
--> Processing Dependency: libmysqlclient.so.()(64bit) for package: :postfix-2.10.-.el7.x86_64
--> Processing Dependency: libmysqlclient.so.(libmysqlclient_18)(64bit) for package: :postfix-2.10.-.el7.x86_64
---> Package mysql-community-libs.x86_64 :8.0.-.el7 will be obsoleting
--> Running transaction check
---> Package mysql-community-libs-compat.x86_64 :8.0.-.el7 will be obsoleting
--> Finished Dependency Resolution Dependencies Resolved ==============================================================================================================================================================================================================================================================================
Package Arch Version Repository Size
==============================================================================================================================================================================================================================================================================
Installing:
mysql-community-libs x86_64 8.0.-.el7 mysql80-community 4.0 M
replacing mariadb-libs.x86_64 :5.5.-.el7_5
mysql-community-libs-compat x86_64 8.0.-.el7 mysql80-community 1.3 M
replacing mariadb-libs.x86_64 :5.5.-.el7_5
mysql-community-server x86_64 8.0.-.el7 mysql80-community M
Installing for dependencies:
mysql-community-client x86_64 8.0.-.el7 mysql80-community M
mysql-community-common x86_64 8.0.-.el7 mysql80-community k Transaction Summary
==============================================================================================================================================================================================================================================================================
Install Packages (+ Dependent packages) Total download size: M
Downloading packages:
warning: /var/cache/yum/x86_64//mysql80-community/packages/mysql-community-common-8.0.-.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY ] kB/s | kB :: ETA
Public key for mysql-community-common-8.0.-.el7.x86_64.rpm is not installed
(/): mysql-community-common-8.0.-.el7.x86_64.rpm | kB ::
(/): mysql-community-libs-8.0.-.el7.x86_64.rpm | 4.0 MB ::
(/): mysql-community-libs-compat-8.0.-.el7.x86_64.rpm | 1.3 MB ::
(/): mysql-community-client-8.0.-.el7.x86_64.rpm | MB ::
(/): mysql-community-server-8.0.-.el7.x86_64.rpm | MB ::
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total MB/s | MB ::
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 76fc bd3c 70c8 8c71 8d3b e1f5
Package : mysql80-community-release-el7-.noarch (installed)
From : /etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Warning: RPMDB altered outside of yum.
Installing : mysql-community-common-8.0.-.el7.x86_64 /
Installing : mysql-community-libs-8.0.-.el7.x86_64 /
Installing : mysql-community-client-8.0.-.el7.x86_64 /
Installing : mysql-community-server-8.0.-.el7.x86_64 /
Installing : mysql-community-libs-compat-8.0.-.el7.x86_64 /
Erasing : :mariadb-libs-5.5.-.el7_5.x86_64 /
Verifying : mysql-community-libs-8.0.-.el7.x86_64 /
Verifying : mysql-community-libs-compat-8.0.-.el7.x86_64 /
Verifying : mysql-community-client-8.0.-.el7.x86_64 /
Verifying : mysql-community-common-8.0.-.el7.x86_64 /
Verifying : mysql-community-server-8.0.-.el7.x86_64 /
Verifying : :mariadb-libs-5.5.-.el7_5.x86_64 / Installed:
mysql-community-libs.x86_64 :8.0.-.el7 mysql-community-libs-compat.x86_64 :8.0.-.el7 mysql-community-server.x86_64 :8.0.-.el7 Dependency Installed:
mysql-community-client.x86_64 :8.0.-.el7 mysql-community-common.x86_64 :8.0.-.el7 Replaced:
mariadb-libs.x86_64 :5.5.-.el7_5 Complete!
[root@hdp101.yinzhengjie.org.cn ~]#

[root@hdp101.yinzhengjie.org.cn ~]# yum -y install mysql-community-server

[root@hdp101.yinzhengjie.org.cn ~]# grep cachedir /etc/yum.conf
cachedir=/var/cache/yum/$basearch/$releasever
[root@hdp101.yinzhengjie.org.cn ~]#
[root@hdp101.yinzhengjie.org.cn ~]# ll /var/cache/yum/$basearch/$releasever
total
drwxr-xr-x. root root Jan : x86_64
[root@hdp101.yinzhengjie.org.cn ~]#
[root@hdp101.yinzhengjie.org.cn ~]# ll /var/cache/yum/$basearch/$releasever/x86_64
total
drwxr-xr-x. root root Jan :
[root@hdp101.yinzhengjie.org.cn ~]#
[root@hdp101.yinzhengjie.org.cn ~]# ll /var/cache/yum/$basearch/$releasever/x86_64/
total
drwxr-xr-x. root root Jan : base
drwxr-xr-x. root root Jan : extras
drwxr-xr-x root root Jan : mysql80-community
drwxr-xr-x root root Jan : mysql-connectors-community
drwxr-xr-x root root Jan : mysql-tools-community
-rw-r--r-- root root Jan : timedhosts
-rw-r--r--. root root Jan : timedhosts.txt
drwxr-xr-x. root root Jan : updates
[root@hdp101.yinzhengjie.org.cn ~]#
[root@hdp101.yinzhengjie.org.cn ~]#
[root@hdp101.yinzhengjie.org.cn ~]# ll /var/cache/yum/$basearch/$releasever/x86_64//mysql80-community
total
-rw-r--r-- root root Jan : 1fd8234d262afcc83f200d02b90b12d38fc3f59b-primary.sqlite.bz2
-rw-r--r-- root root Jan : cachecookie
drwxr-xr-x root root Jan : gen
drwxr-xr-x root root Jan : packages
-rw-r--r-- root root Jan : repomd.xml
[root@hdp101.yinzhengjie.org.cn ~]#
[root@hdp101.yinzhengjie.org.cn ~]# ll /var/cache/yum/$basearch/$releasever/x86_64//mysql80-community/packages        #安装MySQL的rpm包会存在这里,我们可以直接拷贝到生产服务器上安装。
total
-rw-r--r-- root root Jan : mysql-community-client-8.0.-.el7.x86_64.rpm
-rw-r--r-- root root Jan : mysql-community-common-8.0.-.el7.x86_64.rpm
-rw-r--r-- root root Jan : mysql-community-libs-8.0.-.el7.x86_64.rpm
-rw-r--r-- root root Jan : mysql-community-libs-compat-8.0.-.el7.x86_64.rpm
-rw-r--r-- root root Jan : mysql-community-server-8.0.-.el7.x86_64.rpm
[root@hdp101.yinzhengjie.org.cn ~]#

4>.启动MySQL并设置为开机自启

[root@hdp101.yinzhengjie.org.cn ~]# systemctl status mysqld
● mysqld.service - MySQL Server
Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
Active: inactive (dead)
Docs: man:mysqld()
http://dev.mysql.com/doc/refman/en/using-systemd.html
[root@hdp101.yinzhengjie.org.cn ~]#
[root@hdp101.yinzhengjie.org.cn ~]#
[root@hdp101.yinzhengjie.org.cn ~]# systemctl start mysqld
[root@hdp101.yinzhengjie.org.cn ~]#
[root@hdp101.yinzhengjie.org.cn ~]#
[root@hdp101.yinzhengjie.org.cn ~]# systemctl status mysqld
● mysqld.service - MySQL Server
Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
Active: active (running) since Tue -- :: CST; 8s ago
Docs: man:mysqld()
http://dev.mysql.com/doc/refman/en/using-systemd.html
Process: ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=/SUCCESS)
Main PID: (mysqld)
Status: "Server is operational"
CGroup: /system.slice/mysqld.service
└─ /usr/sbin/mysqld Jan :: hdp101.yinzhengjie.org.cn systemd[]: Starting MySQL Server...
Jan :: hdp101.yinzhengjie.org.cn systemd[]: Started MySQL Server.
[root@hdp101.yinzhengjie.org.cn ~]#
[root@hdp101.yinzhengjie.org.cn ~]#

[root@hdp101.yinzhengjie.org.cn ~]# systemctl start mysqld

[root@hdp101.yinzhengjie.org.cn ~]# systemctl enable mysqld            #设置MySQL服务开机自启动,若没有输出说明该服务已经是开机自启状态啦。
[root@hdp101.yinzhengjie.org.cn ~]#   
[root@hdp101.yinzhengjie.org.cn ~]# systemctl list-unit-files | grep mysql
mysqld.service enabled
mysqld@.service disabled
[root@hdp101.yinzhengjie.org.cn ~]#

5>.查看mysql的日志使用临时密码登录数据库并初始化密码

[root@hdp101.yinzhengjie.org.cn ~]# tail /var/log/mysqld.log
--20T19::.259360Z [System] [MY-] [Server] /usr/sbin/mysqld (mysqld 8.0.) initializing of server in progress as process
--20T19::.310721Z [Note] [MY-] [Server] A temporary password is generated for root@localhost: tW-l9!YS_R<
--20T19::.011165Z [System] [MY-] [Server] /usr/sbin/mysqld (mysqld 8.0.) starting as process
--20T19::.880394Z [Warning] [MY-] [Server] CA certificate ca.pem is self signed.
--20T19::.899499Z [System] [MY-] [Server] /usr/sbin/mysqld: ready for connections. Version: '8.0.19' socket: '/var/lib/mysql/mysql.s
ock' port: 3306 MySQL Community Server - GPL.2020-01-20T19:29:33.920466Z 0 [System] [MY-011323] [Server] X Plugin ready for connections. Socket: '/var/run/mysqld/mysqlx.sock' bind-address: '::' po
rt: [root@hdp101.yinzhengjie.org.cn ~]#
[root@hdp101.yinzhengjie.org.cn ~]# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is
Server version: 8.0. Copyright (c) , , 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 user() identified by 'yzj@2019MySQL';
Query OK, rows affected (0.00 sec) mysql> quit
Bye
[root@hdp101.yinzhengjie.org.cn ~]#
[root@hdp101.yinzhengjie.org.cn ~]# mysql -uroot -pyzj@2019MySQL
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is
Server version: 8.0. MySQL Community Server - GPL Copyright (c) , , 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> set GLOBAL validate_password.policy=;
Query OK, rows affected (0.00 sec) mysql> alter user user() identified by 'yinzhengjie';
Query OK, rows affected (0.00 sec) mysql> quit
Bye
[root@hdp101.yinzhengjie.org.cn ~]#
[root@hdp101.yinzhengjie.org.cn ~]# mysql -uroot -pyinzhengjie
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is
Server version: 8.0. MySQL Community Server - GPL Copyright (c) , , 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> show variables like '%validate_password_policy%';
+--------------------------+-------+
| Variable_name | Value |
+--------------------------+-------+
| validate_password.policy | LOW |
+--------------------------+-------+
row in set (0.00 sec) mysql>

[root@hdp101.yinzhengjie.org.cn ~]# tail /var/log/mysqld.log

6>.创建ambari数据库并授权给ambari用户

[root@hdp101.yinzhengjie.org.cn ~]# mysql -uroot -pyinzhengjie
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is
Server version: 8.0. MySQL Community Server - GPL Copyright (c) , , 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>
mysql> CREATE DATABASE ambari DEFAULT CHARACTER SET UTF8;
Query OK, row affected, warning (0.00 sec) mysql>
mysql> CREATE USER ambari@'%' IDENTIFIED WITH mysql_native_password BY 'yinzhengjie';
Query OK, rows affected (0.00 sec) mysql>
mysql> GRANT ALL PRIVILEGES ON ambari.* TO ambari@'%';
Query OK, rows affected (0.01 sec) mysql>
mysql> SHOW GRANTS FOR ambari@'%';
+----------------------------------------------------+
| Grants for ambari@% |
+----------------------------------------------------+
| GRANT USAGE ON *.* TO `ambari`@`%` |
| GRANT ALL PRIVILEGES ON `ambari`.* TO `ambari`@`%` |
+----------------------------------------------------+
rows in set (0.00 sec) mysql>
mysql> FLUSH PRIVILEGES;
Query OK, rows affected (0.01 sec) mysql>
mysql> QUIT
Bye
[root@hdp101.yinzhengjie.org.cn ~]#
[root@hdp101.yinzhengjie.org.cn ~]#

7>.博主推荐阅读

  yum方式部署MySQL:
    https://www.cnblogs.com/yinzhengjie/p/10212038.html   二进制方式部署MySQL:
    https://www.cnblogs.com/yinzhengjie/p/10192668.html

四.安装MySQL Connector

1>.在官方下载MySQL Connector(https://dev.mysql.com/downloads/connector/j/5.1.html)

[root@hdp101.yinzhengjie.org.cn ~]# ll
total
[root@hdp101.yinzhengjie.org.cn ~]#
[root@hdp101.yinzhengjie.org.cn ~]# wget https://dev.mysql.com/get/Downloads/Connector-J/mysql-connector-java-8.0.19.tar.gz
---- ::-- https://dev.mysql.com/get/Downloads/Connector-J/mysql-connector-java-8.0.19.tar.gz
Resolving dev.mysql.com (dev.mysql.com)... 137.254.60.11
Connecting to dev.mysql.com (dev.mysql.com)|137.254.60.11|:... connected.
HTTP request sent, awaiting response... Found
Location: https://cdn.mysql.com//Downloads/Connector-J/mysql-connector-java-8.0.19.tar.gz [following]
---- ::-- https://cdn.mysql.com//Downloads/Connector-J/mysql-connector-java-8.0.19.tar.gz
Resolving cdn.mysql.com (cdn.mysql.com)... 104.86.185.42
Connecting to cdn.mysql.com (cdn.mysql.com)|104.86.185.42|:... connected.
HTTP request sent, awaiting response... OK
Length: (3.7M) [application/x-tar-gz]
Saving to: ‘mysql-connector-java-8.0..tar.gz’ %[=============================================================================================================>] ,, .05MB/s in .8s -- :: (2.05 MB/s) - ‘mysql-connector-java-8.0..tar.gz’ saved [/] [root@hdp101.yinzhengjie.org.cn ~]#
[root@hdp101.yinzhengjie.org.cn ~]# ll
total
-rw-r--r-- root root Dec : mysql-connector-java-8.0..tar.gz
[root@hdp101.yinzhengjie.org.cn ~]#
[root@hdp101.yinzhengjie.org.cn ~]#

[root@hdp101.yinzhengjie.org.cn ~]# wget https://dev.mysql.com/get/Downloads/Connector-J/mysql-connector-java-8.0.19.tar.gz

2>.加压下载的归档文件

[root@hdp101.yinzhengjie.org.cn ~]# ll
total
-rw-r--r-- root root Dec : mysql-connector-java-8.0..tar.gz
[root@hdp101.yinzhengjie.org.cn ~]#
[root@hdp101.yinzhengjie.org.cn ~]# tar zxf mysql-connector-java-8.0..tar.gz
[root@hdp101.yinzhengjie.org.cn ~]#
[root@hdp101.yinzhengjie.org.cn ~]# ll
total
drwxr-xr-x root root Dec : mysql-connector-java-8.0.
-rw-r--r-- root root Dec : mysql-connector-java-8.0..tar.gz
[root@hdp101.yinzhengjie.org.cn ~]#
[root@hdp101.yinzhengjie.org.cn ~]# ll mysql-connector-java-8.0.
total
-rw-r--r-- root root Dec : build.xml
-rw-r--r-- root root Dec : CHANGES
-rw-r--r-- root root Dec : INFO_BIN
-rw-r--r-- root root Dec : INFO_SRC
-rw-r--r-- root root Dec : LICENSE
-rw-r--r-- root root Dec : mysql-connector-java-8.0..jar
-rw-r--r-- root root Dec : README
drwxr-xr-x root root Dec : src
[root@hdp101.yinzhengjie.org.cn ~]#
[root@hdp101.yinzhengjie.org.cn ~]#

[root@hdp101.yinzhengjie.org.cn ~]# tar zxf mysql-connector-java-8.0.19.tar.gz

3>.将解压后的MySQL连接器拷贝到指定目录

[root@hdp101.yinzhengjie.org.cn ~]# ll mysql-connector-java-8.0.
total
-rw-r--r-- root root Dec : build.xml
-rw-r--r-- root root Dec : CHANGES
-rw-r--r-- root root Dec : INFO_BIN
-rw-r--r-- root root Dec : INFO_SRC
-rw-r--r-- root root Dec : LICENSE
-rw-r--r-- root root Dec : mysql-connector-java-8.0..jar
-rw-r--r-- root root Dec : README
drwxr-xr-x root root Dec : src
[root@hdp101.yinzhengjie.org.cn ~]#
[root@hdp101.yinzhengjie.org.cn ~]# mkdir -p /usr/share/java
[root@hdp101.yinzhengjie.org.cn ~]#
[root@hdp101.yinzhengjie.org.cn ~]# mv ~/mysql-connector-java-8.0./mysql-connector-java-8.0..jar /usr/share/java
[root@hdp101.yinzhengjie.org.cn ~]#
[root@hdp101.yinzhengjie.org.cn ~]# cd /usr/share/java
[root@hdp101.yinzhengjie.org.cn /usr/share/java]#
[root@hdp101.yinzhengjie.org.cn /usr/share/java]# ll
total
-rw-r--r-- root root Dec : mysql-connector-java-8.0..jar
[root@hdp101.yinzhengjie.org.cn /usr/share/java]#
[root@hdp101.yinzhengjie.org.cn /usr/share/java]# ln -s mysql-connector-java-8.0..jar mysql-connector-java.jar
[root@hdp101.yinzhengjie.org.cn /usr/share/java]#
[root@hdp101.yinzhengjie.org.cn /usr/share/java]# ll
total
-rw-r--r-- root root Dec : mysql-connector-java-8.0..jar
lrwxrwxrwx root root Jan : mysql-connector-java.jar -> mysql-connector-java-8.0..jar
[root@hdp101.yinzhengjie.org.cn /usr/share/java]#
[root@hdp101.yinzhengjie.org.cn /usr/share/java]#

五.配置Ambari的yum源

1>.下载Ambari安装包(http://public-repo-1.hortonworks.com/ambari/centos7/2.x/updates/2.7.4.0/ambari-2.7.4.0-centos7.tar.gz)

[root@hdp101.yinzhengjie.org.cn ~]# ll
total
[root@hdp101.yinzhengjie.org.cn ~]#
[root@hdp101.yinzhengjie.org.cn ~]# wget http://public-repo-1.hortonworks.com/ambari/centos7/2.x/updates/2.7.4.0/ambari-2.7.4.0-centos7.tar.gz
---- ::-- http://public-repo-1.hortonworks.com/ambari/centos7/2.x/updates/2.7.4.0/ambari-2.7.4.0-centos7.tar.gz
Resolving public-repo-.hortonworks.com (public-repo-.hortonworks.com)... 143.204.83.25, 143.204.83.47, 143.204.83.107, ...
Connecting to public-repo-.hortonworks.com (public-repo-.hortonworks.com)|143.204.83.25|:... connected.
HTTP request sent, awaiting response... OK
Length: (.9G) [application/x-tar]
Saving to: ‘ambari-2.7.4.0-centos7.tar.gz’ %[===========================================================================================================>] ,,, .7MB/s in 2m 59s -- :: (10.8 MB/s) - ‘ambari-2.7.4.0-centos7.tar.gz’ saved [/] [root@hdp101.yinzhengjie.org.cn ~]#
[root@hdp101.yinzhengjie.org.cn ~]# ll
total
-rw-r--r-- root root Aug : ambari-2.7.4.0-centos7.tar.gz
[root@hdp101.yinzhengjie.org.cn ~]#

[root@hdp101.yinzhengjie.org.cn ~]# wget http://public-repo-1.hortonworks.com/ambari/centos7/2.x/updates/2.7.4.0/ambari-2.7.4.0-centos7.tar.gz

2>.下边HDP安装包(http://public-repo-1.hortonworks.com/HDP/centos7/3.x/updates/3.1.4.0/HDP-3.1.4.0-centos7-rpm.tar.gz)

[root@hdp101.yinzhengjie.org.cn ~]# ll
total
-rw-r--r-- root root Aug : ambari-2.7.4.0-centos7.tar.gz
[root@hdp101.yinzhengjie.org.cn ~]#
[root@hdp101.yinzhengjie.org.cn ~]# wget http://public-repo-1.hortonworks.com/HDP/centos7/3.x/updates/3.1.4.0/HDP-3.1.4.0-centos7-rpm.tar.gz
---- ::-- http://public-repo-1.hortonworks.com/HDP/centos7/3.x/updates/3.1.4.0/HDP-3.1.4.0-centos7-rpm.tar.gz
Resolving public-repo-.hortonworks.com (public-repo-.hortonworks.com)... 13.225.166.14, 13.225.166.74, 13.225.166.21, ...
Connecting to public-repo-.hortonworks.com (public-repo-.hortonworks.com)|13.225.166.14|:... connected.
HTTP request sent, awaiting response... OK
Length: (.9G) [application/x-tar]
Saving to: ‘HDP-3.1.4.0-centos7-rpm.tar.gz’ %[===========================================================================================================>] ,,, .2MB/s in 13m 56s -- :: (10.8 MB/s) - ‘HDP-3.1.4.0-centos7-rpm.tar.gz’ saved [/] [root@hdp101.yinzhengjie.org.cn ~]#
[root@hdp101.yinzhengjie.org.cn ~]# ll
total
-rw-r--r-- root root Aug : ambari-2.7.4.0-centos7.tar.gz
-rw-r--r-- root root Aug : HDP-3.1.4.0-centos7-rpm.tar.gz
[root@hdp101.yinzhengjie.org.cn ~]#

[root@hdp101.yinzhengjie.org.cn ~]# wget http://public-repo-1.hortonworks.com/HDP/centos7/3.x/updates/3.1.4.0/HDP-3.1.4.0-centos7-rpm.tar.gz

3>.下载HDP-UTIL安装包(http://public-repo-1.hortonworks.com/HDP-UTILS-1.1.0.22/repos/centos7/HDP-UTILS-1.1.0.22-centos7.tar.gz)

[root@hdp101.yinzhengjie.org.cn ~]# ll -h
total 11G
-rw-r--r-- root root .9G Aug : ambari-2.7.4.0-centos7.tar.gz
-rw-r--r-- root root .9G Aug : HDP-3.1.4.0-centos7-rpm.tar.gz
[root@hdp101.yinzhengjie.org.cn ~]#
[root@hdp101.yinzhengjie.org.cn ~]# wget http://public-repo-1.hortonworks.com/HDP-UTILS-1.1.0.22/repos/centos7/HDP-UTILS-1.1.0.22-centos7.tar.gz
---- ::-- http://public-repo-1.hortonworks.com/HDP-UTILS-1.1.0.22/repos/centos7/HDP-UTILS-1.1.0.22-centos7.tar.gz
Resolving public-repo-.hortonworks.com (public-repo-.hortonworks.com)... 13.249.171.70, 13.249.171.122, 13.249.171.64, ...
Connecting to public-repo-.hortonworks.com (public-repo-.hortonworks.com)|13.249.171.70|:... connected.
HTTP request sent, awaiting response... OK
Length: (86M) [application/x-tar]
Saving to: ‘HDP-UTILS-1.1.0.22-centos7.tar.gz’ %[=============================================================================================================>] ,, .3MB/s in .3s -- :: (10.4 MB/s) - ‘HDP-UTILS-1.1.0.22-centos7.tar.gz’ saved [/] [root@hdp101.yinzhengjie.org.cn ~]#
[root@hdp101.yinzhengjie.org.cn ~]# ll -h
total 11G
-rw-r--r-- root root .9G Aug : ambari-2.7.4.0-centos7.tar.gz
-rw-r--r-- root root .9G Aug : HDP-3.1.4.0-centos7-rpm.tar.gz
-rw-r--r-- root root 87M Aug HDP-UTILS-1.1.0.22-centos7.tar.gz
[root@hdp101.yinzhengjie.org.cn ~]#
[root@hdp101.yinzhengjie.org.cn ~]#

[root@hdp101.yinzhengjie.org.cn ~]# wget http://public-repo-1.hortonworks.com/HDP-UTILS-1.1.0.22/repos/centos7/HDP-UTILS-1.1.0.22-centos7.tar.gz

4>.下载HDP-GPL文件(http://public-repo-1.hortonworks.com/HDP-GPL/centos7/3.x/updates/3.1.4.0/HDP-GPL-3.1.4.0-centos7-gpl.tar.gz)

[root@hdp101.yinzhengjie.org.cn ~]# ll -h
total 11G
-rw-r--r-- root root .9G Aug : ambari-2.7.4.0-centos7.tar.gz
-rw-r--r-- root root .9G Aug : HDP-3.1.4.0-centos7-rpm.tar.gz
-rw-r--r-- root root 87M Aug HDP-UTILS-1.1.0.22-centos7.tar.gz
[root@hdp101.yinzhengjie.org.cn ~]#
[root@hdp101.yinzhengjie.org.cn ~]# wget http://public-repo-1.hortonworks.com/HDP-GPL/centos7/3.x/updates/3.1.4.0/HDP-GPL-3.1.4.0-centos7-gpl.tar.gz
---- ::-- http://public-repo-1.hortonworks.com/HDP-GPL/centos7/3.x/updates/3.1.4.0/HDP-GPL-3.1.4.0-centos7-gpl.tar.gz
Resolving public-repo-.hortonworks.com (public-repo-.hortonworks.com)... 13.249.171.64, 13.249.171.122, 13.249.171.43, ...
Connecting to public-repo-.hortonworks.com (public-repo-.hortonworks.com)|13.249.171.64|:... connected.
HTTP request sent, awaiting response... OK
Length: (158K) [application/x-tar]
Saving to: ‘HDP-GPL-3.1.4.0-centos7-gpl.tar.gz’ %[=============================================================================================================>] , 712KB/s in .2s -- :: ( KB/s) - ‘HDP-GPL-3.1.4.0-centos7-gpl.tar.gz’ saved [/] [root@hdp101.yinzhengjie.org.cn ~]#
[root@hdp101.yinzhengjie.org.cn ~]# ll -h
total 11G
-rw-r--r-- root root .9G Aug : ambari-2.7.4.0-centos7.tar.gz
-rw-r--r-- root root .9G Aug : HDP-3.1.4.0-centos7-rpm.tar.gz
-rw-r--r-- root root 159K Aug : HDP-GPL-3.1.4.0-centos7-gpl.tar.gz
-rw-r--r-- root root 87M Aug HDP-UTILS-1.1.0.22-centos7.tar.gz
[root@hdp101.yinzhengjie.org.cn ~]#
[root@hdp101.yinzhengjie.org.cn ~]#

[root@hdp101.yinzhengjie.org.cn ~]# wget http://public-repo-1.hortonworks.com/HDP-GPL/centos7/3.x/updates/3.1.4.0/HDP-GPL-3.1.4.0-centos7-gpl.tar.gz

5>.安装apache httpd web服务并启动

[root@hdp101.yinzhengjie.org.cn ~]# yum info httpd
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirror.bit.edu.cn
* extras: mirror.bit.edu.cn
* updates: mirrors.tuna.tsinghua.edu.cn
Installed Packages
Name : httpd
Arch : x86_64
Version : 2.4.
Release : .el7.centos
Size : 9.4 M
Repo : installed
From repo : base
Summary : Apache HTTP Server
URL : http://httpd.apache.org/
License : ASL 2.0
Description : The Apache HTTP Server is a powerful, efficient, and extensible
: web server. [root@hdp101.yinzhengjie.org.cn ~]#

[root@hdp101.yinzhengjie.org.cn ~]# yum info httpd

[root@hdp101.yinzhengjie.org.cn ~]# yum -y install httpd
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirror.bit.edu.cn
* extras: mirror.bit.edu.cn
* updates: mirrors.tuna.tsinghua.edu.cn
Resolving Dependencies
--> Running transaction check
---> Package httpd.x86_64 :2.4.-.el7.centos will be installed
--> Processing Dependency: httpd-tools = 2.4.-.el7.centos for package: httpd-2.4.-.el7.centos.x86_64
--> Processing Dependency: /etc/mime.types for package: httpd-2.4.-.el7.centos.x86_64
--> Processing Dependency: libaprutil-.so.()(64bit) for package: httpd-2.4.-.el7.centos.x86_64
--> Processing Dependency: libapr-.so.()(64bit) for package: httpd-2.4.-.el7.centos.x86_64
--> Running transaction check
---> Package apr.x86_64 :1.4.-.el7 will be installed
---> Package apr-util.x86_64 :1.5.-.el7 will be installed
---> Package httpd-tools.x86_64 :2.4.-.el7.centos will be installed
---> Package mailcap.noarch :2.1.-.el7 will be installed
--> Finished Dependency Resolution Dependencies Resolved =======================================================================================================================================================
Package Arch Version Repository Size
=======================================================================================================================================================
Installing:
httpd x86_64 2.4.-.el7.centos base 2.7 M
Installing for dependencies:
apr x86_64 1.4.-.el7 base k
apr-util x86_64 1.5.-.el7 base k
httpd-tools x86_64 2.4.-.el7.centos base k
mailcap noarch 2.1.-.el7 base k Transaction Summary
=======================================================================================================================================================
Install Package (+ Dependent packages) Total download size: 3.0 M
Installed size: M
Downloading packages:
(/): apr-util-1.5.-.el7.x86_64.rpm | kB ::
(/): apr-1.4.-.el7.x86_64.rpm | kB ::
(/): httpd-tools-2.4.-.el7.centos.x86_64.rpm | kB ::
(/): mailcap-2.1.-.el7.noarch.rpm | kB ::
(/): httpd-2.4.-.el7.centos.x86_64.rpm | 2.7 MB ::
-------------------------------------------------------------------------------------------------------------------------------------------------------
Total 4.7 MB/s | 3.0 MB ::
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : apr-1.4.-.el7.x86_64 /
Installing : apr-util-1.5.-.el7.x86_64 /
Installing : httpd-tools-2.4.-.el7.centos.x86_64 /
Installing : mailcap-2.1.-.el7.noarch /
Installing : httpd-2.4.-.el7.centos.x86_64 /
Verifying : apr-1.4.-.el7.x86_64 /
Verifying : mailcap-2.1.-.el7.noarch /
Verifying : httpd-tools-2.4.-.el7.centos.x86_64 /
Verifying : apr-util-1.5.-.el7.x86_64 /
Verifying : httpd-2.4.-.el7.centos.x86_64 / Installed:
httpd.x86_64 :2.4.-.el7.centos Dependency Installed:
apr.x86_64 :1.4.-.el7 apr-util.x86_64 :1.5.-.el7 httpd-tools.x86_64 :2.4.-.el7.centos mailcap.noarch :2.1.-.el7 Complete!
[root@hdp101.yinzhengjie.org.cn ~]#

[root@hdp101.yinzhengjie.org.cn ~]# yum -y install httpd

[root@hdp101.yinzhengjie.org.cn ~]# systemctl list-unit-files | grep httpd
httpd.service disabled
[root@hdp101.yinzhengjie.org.cn ~]#
[root@hdp101.yinzhengjie.org.cn ~]# systemctl enable httpd
Created symlink from /etc/systemd/system/multi-user.target.wants/httpd.service to /usr/lib/systemd/system/httpd.service.
[root@hdp101.yinzhengjie.org.cn ~]#
[root@hdp101.yinzhengjie.org.cn ~]# systemctl list-unit-files | grep httpd
httpd.service enabled
[root@hdp101.yinzhengjie.org.cn ~]#
[root@hdp101.yinzhengjie.org.cn ~]#

[root@hdp101.yinzhengjie.org.cn ~]# systemctl enable httpd

[root@hdp101.yinzhengjie.org.cn ~]# systemctl status httpd
● httpd.service - The Apache HTTP Server
Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor preset: disabled)
Active: inactive (dead)
Docs: man:httpd()
man:apachectl()
[root@hdp101.yinzhengjie.org.cn ~]#
[root@hdp101.yinzhengjie.org.cn ~]# systemctl start httpd
[root@hdp101.yinzhengjie.org.cn ~]#
[root@hdp101.yinzhengjie.org.cn ~]# systemctl status httpd
● httpd.service - The Apache HTTP Server
Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor preset: disabled)
Active: active (running) since Tue -- :: CST; 1s ago
Docs: man:httpd()
man:apachectl()
Main PID: (httpd)
Status: "Processing requests..."
CGroup: /system.slice/httpd.service
├─ /usr/sbin/httpd -DFOREGROUND
├─ /usr/sbin/httpd -DFOREGROUND
├─ /usr/sbin/httpd -DFOREGROUND
├─ /usr/sbin/httpd -DFOREGROUND
├─ /usr/sbin/httpd -DFOREGROUND
└─ /usr/sbin/httpd -DFOREGROUND Jan :: hdp101.yinzhengjie.org.cn systemd[]: Starting The Apache HTTP Server...
Jan :: hdp101.yinzhengjie.org.cn systemd[]: Started The Apache HTTP Server.
[root@hdp101.yinzhengjie.org.cn ~]#
[root@hdp101.yinzhengjie.org.cn ~]#

[root@hdp101.yinzhengjie.org.cn ~]# systemctl start httpd

6>.解压下载的文件到对应的"web"目录

[root@hdp101.yinzhengjie.org.cn ~]# ll
total
-rw-r--r-- root root Aug : ambari-2.7.4.0-centos7.tar.gz
-rw-r--r-- root root Aug : HDP-3.1.4.0-centos7-rpm.tar.gz
-rw-r--r-- root root Aug : HDP-GPL-3.1.4.0-centos7-gpl.tar.gz
-rw-r--r-- root root Aug HDP-UTILS-1.1.0.22-centos7.tar.gz
[root@hdp101.yinzhengjie.org.cn ~]#
[root@hdp101.yinzhengjie.org.cn ~]#
[root@hdp101.yinzhengjie.org.cn ~]# tar -zxf ambari-2.7.4.0-centos7.tar.gz -C /var/www/html/
[root@hdp101.yinzhengjie.org.cn ~]#
[root@hdp101.yinzhengjie.org.cn ~]# tar -zxf HDP-3.1.4.0-centos7-rpm.tar.gz -C /var/www/html/
[root@hdp101.yinzhengjie.org.cn ~]#
[root@hdp101.yinzhengjie.org.cn ~]# tar -zxf HDP-GPL-3.1.4.0-centos7-gpl.tar.gz -C /var/www/html/
[root@hdp101.yinzhengjie.org.cn ~]#
[root@hdp101.yinzhengjie.org.cn ~]# tar -zxf HDP-UTILS-1.1.0.22-centos7.tar.gz -C /var/www/html/
[root@hdp101.yinzhengjie.org.cn ~]#
[root@hdp101.yinzhengjie.org.cn ~]# ll /var/www/html/
total
drwxr-xr-x root root Jan : ambari
drwxr-xr-x users Aug : HDP
drwxr-xr-x users Aug : HDP-GPL
drwxr-xr-x users Aug HDP-UTILS
[root@hdp101.yinzhengjie.org.cn ~]#
[root@hdp101.yinzhengjie.org.cn ~]# chmod -R a+rx /var/www/html/
[root@hdp101.yinzhengjie.org.cn ~]#

[root@hdp101.yinzhengjie.org.cn ~]# ll /var/www/html/

7>.本地配置yum源进行验证

[root@hdp101.yinzhengjie.org.cn ~]# cat /etc/yum.repos.d/ambari.repo
[ambari-repo]
name=ambari
baseurl=http://hdp101.yinzhengjie.org.cn/ambari/centos7/2.7.4.0-118/
enable=
gpgcheck=
[root@hdp101.yinzhengjie.org.cn ~]#
[root@hdp101.yinzhengjie.org.cn ~]# yum repolist
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirror.bit.edu.cn
* extras: mirror.bit.edu.cn
* updates: mirrors.tuna.tsinghua.edu.cn
repo id repo name status
ambari-repo ambari
base//x86_64 CentOS- - Base ,
extras//x86_64 CentOS- - Extras
mysql-connectors-community/x86_64 MySQL Connectors Community
mysql-tools-community/x86_64 MySQL Tools Community
mysql80-community/x86_64 MySQL 8.0 Community Server
updates//x86_64 CentOS- - Updates ,
repolist: ,
[root@hdp101.yinzhengjie.org.cn ~]#

[root@hdp101.yinzhengjie.org.cn ~]# yum repolist

六.部署Ambari Server实战案例

1>.安装ambari-server

[root@hdp101.yinzhengjie.org.cn ~]# yum -y install ambari-server
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirror.bit.edu.cn
* extras: mirror.bit.edu.cn
* updates: mirrors.tuna.tsinghua.edu.cn
Resolving Dependencies
--> Running transaction check
---> Package ambari-server.x86_64 :2.7.4.0- will be installed
--> Processing Dependency: postgresql-server >= 8.1 for package: ambari-server-2.7.4.0-.x86_64
--> Running transaction check
---> Package postgresql-server.x86_64 :9.2.-.el7_5 will be installed
--> Processing Dependency: postgresql-libs(x86-) = 9.2.-.el7_5 for package: postgresql-server-9.2.-.el7_5.x86_64
--> Processing Dependency: postgresql(x86-) = 9.2.-.el7_5 for package: postgresql-server-9.2.-.el7_5.x86_64
--> Processing Dependency: libpq.so.()(64bit) for package: postgresql-server-9.2.-.el7_5.x86_64
--> Running transaction check
---> Package postgresql.x86_64 :9.2.-.el7_5 will be installed
---> Package postgresql-libs.x86_64 :9.2.-.el7_5 will be installed
--> Finished Dependency Resolution Dependencies Resolved =======================================================================================================================================================
Package Arch Version Repository Size
=======================================================================================================================================================
Installing:
ambari-server x86_64 2.7.4.0- ambari-repo M
Installing for dependencies:
postgresql x86_64 9.2.-.el7_5 base 3.0 M
postgresql-libs x86_64 9.2.-.el7_5 base k
postgresql-server x86_64 9.2.-.el7_5 base 3.8 M Transaction Summary
=======================================================================================================================================================
Install Package (+ Dependent packages) Total download size: M
Installed size: M
Downloading packages:
(/): postgresql-libs-9.2.-.el7_5.x86_64.rpm | kB ::
(/): postgresql-server-9.2.-.el7_5.x86_64.rpm | 3.8 MB ::
(/): ambari-server-2.7.4.0-.x86_64.rpm | MB ::
(/): postgresql-9.2.-.el7_5.x86_64.rpm | 3.0 MB ::
-------------------------------------------------------------------------------------------------------------------------------------------------------
Total MB/s | MB ::
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : postgresql-libs-9.2.-.el7_5.x86_64 /
Installing : postgresql-9.2.-.el7_5.x86_64 /
Installing : postgresql-server-9.2.-.el7_5.x86_64 /
Installing : ambari-server-2.7.4.0-.x86_64 /
Verifying : postgresql-server-9.2.-.el7_5.x86_64 /
Verifying : postgresql-libs-9.2.-.el7_5.x86_64 /
Verifying : ambari-server-2.7.4.0-.x86_64 /
Verifying : postgresql-9.2.-.el7_5.x86_64 / Installed:
ambari-server.x86_64 :2.7.4.0- Dependency Installed:
postgresql.x86_64 :9.2.-.el7_5 postgresql-libs.x86_64 :9.2.-.el7_5 postgresql-server.x86_64 :9.2.-.el7_5 Complete!
[root@hdp101.yinzhengjie.org.cn ~]#

[root@hdp101.yinzhengjie.org.cn ~]# yum -y install ambari-server

[root@hdp101.yinzhengjie.org.cn ~]# rpm -ql ambari-server | grep "Ambari-DDL-MySQL-CREATE.sql"        #安装ambari-server会自动安装MySQL相关的DDL语句。
/var/lib/ambari-server/resources/Ambari-DDL-MySQL-CREATE.sql
[root@hdp101.yinzhengjie.org.cn ~]#

2>.导入Ambari在配置的时候需要MySQL来存储元数据信息,因此我们来创建相关数据库资源

[root@hdp101.yinzhengjie.org.cn ~]# mysql -u ambari -pyinzhengjie
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is
Server version: 8.0. MySQL Community Server - GPL Copyright (c) , , 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>
mysql> SHOW DATABASES;
+--------------------+
| Database |
+--------------------+
| ambari |
| information_schema |
+--------------------+
rows in set (0.02 sec) mysql>
mysql> USE ambari
Database changed
mysql>
mysql> SHOW TABLES;
Empty set (0.00 sec) mysql>
mysql> SOURCE /var/lib/ambari-server/resources/Ambari-DDL-MySQL-CREATE.sql;
...... Query OK, rows affected (0.01 sec)
Records: Duplicates: Warnings: Query OK, rows affected (0.01 sec)
Records: Duplicates: Warnings: Query OK, rows affected (0.01 sec)
Records: Duplicates: Warnings: Query OK, rows affected (0.01 sec)
Records: Duplicates: Warnings: Query OK, rows affected (0.00 sec) mysql>
mysql> SHOW TABLES;
+-------------------------------+
| Tables_in_ambari |
+-------------------------------+
| ClusterHostMapping |
| QRTZ_BLOB_TRIGGERS |
| QRTZ_CALENDARS |
| QRTZ_CRON_TRIGGERS |
| QRTZ_FIRED_TRIGGERS |
| QRTZ_JOB_DETAILS |
| QRTZ_LOCKS |
| QRTZ_PAUSED_TRIGGER_GRPS |
| QRTZ_SCHEDULER_STATE |
| QRTZ_SIMPLE_TRIGGERS |
| QRTZ_SIMPROP_TRIGGERS |
| QRTZ_TRIGGERS |
| adminpermission |
| adminprincipal |
| adminprincipaltype |
| adminprivilege |
| adminresource |
| adminresourcetype |
| alert_current |
| alert_definition |
| alert_group |
| alert_group_target |
| alert_grouping |
| alert_history |
| alert_notice |
| alert_target |
| alert_target_states |
| ambari_configuration |
| ambari_operation_history |
| ambari_sequences |
| artifact |
| blueprint |
| blueprint_configuration |
| blueprint_setting |
| clusterconfig |
| clusters |
| clusterservices |
| clusterstate |
| confgroupclusterconfigmapping |
| configgroup |
| configgrouphostmapping |
| execution_command |
| extension |
| extensionlink |
| host_role_command |
| host_version |
| hostcomponentdesiredstate |
| hostcomponentstate |
| hostconfigmapping |
| hostgroup |
| hostgroup_component |
| hostgroup_configuration |
| hosts |
| hoststate |
| kerberos_descriptor |
| kerberos_keytab |
| kerberos_keytab_principal |
| kerberos_principal |
| key_value_store |
| kkp_mapping_service |
| metainfo |
| permission_roleauthorization |
| remoteambaricluster |
| remoteambariclusterservice |
| repo_applicable_services |
| repo_definition |
| repo_os |
| repo_tags |
| repo_version |
| request |
| requestoperationlevel |
| requestresourcefilter |
| requestschedule |
| requestschedulebatchrequest |
| role_success_criteria |
| roleauthorization |
| servicecomponent_version |
| servicecomponentdesiredstate |
| serviceconfig |
| serviceconfighosts |
| serviceconfigmapping |
| servicedesiredstate |
| setting |
| stack |
| stage |
| topology_host_info |
| topology_host_request |
| topology_host_task |
| topology_hostgroup |
| topology_logical_request |
| topology_logical_task |
| topology_request |
| upgrade |
| upgrade_group |
| upgrade_history |
| upgrade_item |
| user_authentication |
| users |
| viewentity |
| viewinstance |
| viewinstancedata |
| viewinstanceproperty |
| viewmain |
| viewparameter |
| viewresource |
| viewurl |
| widget |
| widget_layout |
| widget_layout_user_widget |
+-------------------------------+
rows in set (0.00 sec) mysql>

3>.配置Ambari Server

[root@hdp101.yinzhengjie.org.cn ~]# ambari-server setup
Using python /usr/bin/python        #看到这里的数据,同学们估计已经猜到了,没错Ambari-Server会通过Python脚本启动一个交互式的shell程序来引导用户完成配置,这和CDH几乎是如出一辙啊!!!
Setup ambari-server
Checking SELinux...
SELinux status is 'disabled'    #咱们再看看这个输出,说明程序配置首先会检查是否已经禁用了SELinux,这项配置在之前步骤已经设置过了,所以下面价差的状态为“disabled”
Customize user account for ambari-server daemon [y/n] (n)? n       #紧接着,出现了一个交互的场景,问咱们是否要指定Ambari服务器后台应用程序的用户,输入字母“n”,或者直接按回车即可。
Adjusting ambari-server permissions and ownership...
Checking firewall status...
Checking JDK...             #看到没有,上面检查了selinux的状态,现在又开始检查防火墙的状态啦!下面有紧接着检查JDK环境
[] Oracle JDK 1.8 + Java Cryptography Extension (JCE) Policy Files
[] Custom JDK
==============================================================================
Enter choice (): 2               #看到没?让你从上面选择对应的数字,是JDK8还是JDK7,还是咱们自定义安装的jdk,我这里是自定义自定义安装JDK环境的,因此我输入了数字”2”,下面会要求我们指定安装JDK的路径。
WARNING: JDK must be installed on all hosts and JAVA_HOME must be valid on all hosts.
WARNING: JCE Policy files are required for configuring Kerberos security. If you plan to use Kerberos,please make sure JCE Unlimited Strength Jurisdict
ion Policy Files are valid on all hosts.Path to JAVA_HOME: /yinzhengjie/softwares/jdk1.8.0_201    #既然上面我们选择的是自定义JDK环境的,那么我们得告诉它我们的JAVA_HOME路径在哪。实事求是,按照你安装的路径输入进去即可。
Validating JDK on Ambari Server...done.
Check JDK version for Ambari Server...
JDK version found:
Minimum JDK version is for Ambari. Skipping to setup different JDK for Ambari Server.
Checking GPL software agreement...
GPL License for LZO: https://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html
Enable Ambari Server to download and install GPL Licensed LZO packages [y/n] (n)? y
Completing setup...
Configuring database...
Enter advanced database configuration [y/n] (n)? y              #进入高级数据库设置
Configuring database...
==============================================================================
Choose one of the following options:
[] - PostgreSQL (Embedded)
[] - Oracle
[] - MySQL / MariaDB
[] - PostgreSQL
[] - Microsoft SQL Server (Tech Preview)
[] - SQL Anywhere
[] - BDB
==============================================================================
Enter choice (): 3                #由于咱们安装的MySQL数据库,选择对应的数字3即可,接下来配置数据库信息即可,如果不设置则使用默认的配置。
Hostname (localhost):
Port ():
Database name (ambari):
Username (ambari):
Enter Database Password (bigdata):       #由于我密码不是使用的"bigdata",因此我在这一步骤需要输入密码"yinzhengjie",需要输入2次。
Re-enter password:
Configuring ambari database...
Should ambari use existing default jdbc /usr/share/java/mysql-connector-java.jar [y/n] (y)? y        #直接输入回车即可,因为我们配置了软连接
Configuring remote database connection properties...
WARNING: Before starting Ambari Server, you must run the following DDL directly from the database shell to create the schema: /var/lib/ambari-server/resources/Ambari-DDL-MySQL-CREATE.sql
Proceed with configuring remote database connection properties [y/n] (y)? y                   #输入"y"或者直接回车即可,即默认允许远程连接该数据的。
Extracting system views...
ambari-admin-2.7.4.0..jar
....
Ambari repo file doesn't contain latest json url, skipping repoinfos modification
Adjusting ambari-server permissions and ownership...
Ambari Server 'setup' completed successfully.
[root@hdp101.yinzhengjie.org.cn ~]#

4>.启动Ambari Server

[root@hdp101.yinzhengjie.org.cn ~]# ambari-server start

5>.Ambari启动成功后就可以访问其Web UI啦(http://hdp101.yinzhengjie.org.cn:8080/#/login)

6>.登录Ambari Server的管理界面

7>.部署Ambari Agent

  博主推荐阅读:
    https://www.cnblogs.com/yinzhengjie2020/p/12227503.html

七.故障排除

1>.登录时报错如下图所示

2>.真是有点小气氛,都最后一步了竟然给我报错啦!二话不说直接看日志,如下图所示,快速定位问题,应该是建表时缺表啦

[root@hdp101.yinzhengjie.org.cn ~]# tail -10f /var/log/ambari-server/ambari-server.log          #查看ambari服务器端日志

3>.定位原因是缺少了"ambari.members"这张表

[root@hdp101.yinzhengjie.org.cn ~]# sz /var/lib/ambari-server/resources/Ambari-DDL-MySQL-CREATE.sql        #我手动将"memebers"建表语句创建失败,如下图所示,但语法上并没有错误~

4>.最终定位原因是"缺少groups"表

  如下图所示,我发现创建members表依赖于groups和users表,纵观全局,发现users表是存在的,但groups表是不存在的哟。

5>.将修改groups和members表的见表语句(如下图所示,已经解决了建表的问题)

CREATE TABLE groups2 (
group_id INTEGER,
principal_id BIGINT NOT NULL,
group_name VARCHAR(255) NOT NULL,
ldap_group INTEGER NOT NULL DEFAULT 0,
group_type VARCHAR(255) NOT NULL DEFAULT 'LOCAL',
CONSTRAINT PK_groups PRIMARY KEY (group_id),
CONSTRAINT FK_groups_principal_id FOREIGN KEY (principal_id) REFERENCES adminprincipal(principal_id),
CONSTRAINT UNQ_groups_0 UNIQUE (group_name, ldap_group)); CREATE TABLE members (
member_id INTEGER,
group_id INTEGER NOT NULL,
user_id INTEGER NOT NULL,
CONSTRAINT PK_members PRIMARY KEY (member_id),
CONSTRAINT FK_members_group_id FOREIGN KEY (group_id) REFERENCES groups2 (group_id),
CONSTRAINT FK_members_user_id FOREIGN KEY (user_id) REFERENCES users (user_id),
CONSTRAINT UNQ_members_0 UNIQUE (group_id, user_id));

6>.故障原因

  登录失败是由于数据库缺少相应的表,而members表有依赖于groups表,最终发现是groups表不存在导致memebers建表语句也失败了。虽然解决了问题,但我从建表语句上看不出来问题,目前怀疑可能是我用的最新版本的数据库导致的,等我再换一个版本的数据库测试一下。

部署Ambari Server实战案例的更多相关文章

  1. 基于Ambari Server部署HDP集群实战案例

    基于Ambari Server部署HDP集群实战案例 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 一.部署Ambari Server端 博主推荐阅读: https://www.c ...

  2. 使用zabbix server监控tomcat实战案例

    使用zabbix server监控tomcat实战案例 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 大家都知道,zabbix server效率高是使用C语言编写的,有很多应用程序 ...

  3. Ubuntu系统部署tomcat并启用JMX实战案例

    Ubuntu系统部署tomcat并启用JMX实战案例 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 一.安装JDK环境 1>.更换阿里云的软件源 [root@zabbix_g ...

  4. 企业Shell面试题及企业运维实战案例(三)

    1.企业Shell面试题1:批量生成随机字符文件名案例 使用for循环在/oldboy目录下批量创建10个html文件,其中每个文件需要包含10个随机小写字母加固定字符串oldboy,名称示例如下: ...

  5. Flume实战案例运维篇

    Flume实战案例运维篇 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 一.Flume概述 1>.什么是Flume Flume是一个分布式.可靠.高可用的海量日志聚合系统,支 ...

  6. Jenkins 搭建企业实战案例 (发布与回滚)

    让我们的代码部署变得easy,不再难,Jenkins是一个可扩展的持续集成引擎,是一个开源软件项目,旨在提供一个开放易用的软件平台,使软件的持续集成变成可能.Jenkins非常易于安装和配置,简单易用 ...

  7. 使用Zabbix监控Nginx服务实战案例

    使用Zabbix监控Nginx服务实战案例 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任.  一.编译安装nginx步骤详解并开启状态页 博主推荐阅读: https://www.cn ...

  8. zabbix java gateway配置实战案例

    zabbix java gateway配置实战案例 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 一.部署tomcat服务 博主推荐阅读: CentOS: https://www. ...

  9. puppet实现主从部署各种软件实战参考模型

    puppet实现主从部署各种软件实战参考模型   实验要求:     1.我将准备三个节点 node2 , node3 , node4 2.我们想让节点node3部署ntp,nginx ;节点node ...

随机推荐

  1. 转:Nginx的accept_mutex配置

    通常多数人不会注意Nginx的accept_mutex配置,不过实际上它对系统的吞吐量有一定的影响. events { accept_mutex off; } 让我们看看accept_mutex的意义 ...

  2. Django 3.0 中连接mysql 8.0,可以不使用pymysql ,升级Mysqlclient即可

    python 中,连接mysql一般都推荐用pymysql ,而且在django中,网上的教程都是这么连接mysql的. import pymysql pymysql.install_as_MySQL ...

  3. 【React Native错误集】Android error “Could not get BatchedBridge, make sure your bundle is packaged properly” on start of app

    问题1:Android error “Could not get BatchedBridge, make sure your bundle is packaged properly” on start ...

  4. Redis列表类型

    列表类型(list) 可以存储一个有序的字符串列表.常用的操作是向列表两端添加元素. 一个列表类型键最多能容纳2^32 -1个元素. 命令 向列表两端增加元素 LPUSH key value [val ...

  5. 防止SQL注入的登录页面

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN""http://www.w3.org/T ...

  6. NOI2019 选做

    施工中-- 这里是一个同步赛选手,同步赛打铜了,下面内容来源于互联网,如有雷同敬请谅解-- d1t1 回家路线 d1t1 吐槽 本题首先数据范围出的有点水,其次数据有点水,导致这题真的成了签到题. 现 ...

  7. 什么叫github

    git remote add origin https://github.com/huiwangui/git-demo.git:表示在本地仓库关联远程仓库(https://github.com/hui ...

  8. windos常见软件库

    1.护卫神软件库 http://soft.huweishen.com/special/1.html 2.护卫神windows资料库 http://v.huweishen.com/ 3.国超软件下载 h ...

  9. 禁用UpdateOrchestrator重新启动任务

    LTSC2019 联网下载更新后,总是用户不使用电脑的时候重启更新系统. 搜索发现是计划任务中\Microsoft\Windows\UpdateOrachestrator重新任务的导致的. 查看这个任 ...

  10. Mybatis注解开发单表CRUD

    Mybatis注解开发单表CRUD mybatis注解开发和xml开发不可兼容,要么全部使用注解,要么全部使用xml,个人建议注解,简单. 当实体类属性名称和数据库表属性名称一致时:无需配置Resul ...