zoukankan      html  css  js  c++  java
  • 部署Ambari Server实战案例

            部署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 2048]----+
    |                 |
    |                 |
    |      . .        |
    |     + * 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------- 1 root root 1679 Jan 21 02:37 /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:93:c0:d4:6e:7e:13:16:61:f1:93:a7:38:01.
    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: 1 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: 1
    
    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         2020-01-21 02:21
    root     pts/0        2020-01-21 02:35 (172.200.0.1)
    [root@hdp101.yinzhengjie.org.cn ~]# 
    [root@hdp101.yinzhengjie.org.cn ~]# ssh hdp101.yinzhengjie.org.cn
    Last login: Tue Jan 21 02:35:51 2020 from 172.200.0.1
    [root@hdp101.yinzhengjie.org.cn ~]# 
    [root@hdp101.yinzhengjie.org.cn ~]# who
    root     tty1         2020-01-21 02:21
    root     pts/0        2020-01-21 02:35 (172.200.0.1)
    root     pts/1        2020-01-21 02:39 (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:93:c0:d4:6e:7e:13:16:61:f1:93:a7:38:01.
    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: 1 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: 1
    
    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         2020-01-21 02:21
    root     pts/0        2020-01-21 02:35 (172.200.0.1)
    [root@hdp101.yinzhengjie.org.cn ~]# 
    [root@hdp101.yinzhengjie.org.cn ~]# ssh hdp102.yinzhengjie.org.cn
    Last login: Tue Jan 21 02:36:16 2020 from 172.200.0.1
    [root@hdp102.yinzhengjie.org.cn ~]# 
    [root@hdp102.yinzhengjie.org.cn ~]# who
    root     tty1         2020-01-21 02:24
    root     pts/0        2020-01-21 02:36 (172.200.0.1)
    root     pts/1        2020-01-21 02:40 (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         2020-01-21 02:21
    root     pts/0        2020-01-21 02:35 (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:93:c0:d4:6e:7e:13:16:61:f1:93:a7:38:01.
    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: 1 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: 1
    
    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         2020-01-21 02:21
    root     pts/0        2020-01-21 02:35 (172.200.0.1)
    [root@hdp101.yinzhengjie.org.cn ~]# 
    [root@hdp101.yinzhengjie.org.cn ~]# ssh hdp103.yinzhengjie.org.cn
    Last login: Tue Jan 21 02:36:38 2020 from 172.200.0.1
    [root@hdp103.yinzhengjie.org.cn ~]# 
    [root@hdp103.yinzhengjie.org.cn ~]# who
    root     tty1         2020-01-21 02:27
    root     pts/0        2020-01-21 02:36 (172.200.0.1)
    root     pts/1        2020-01-21 02:43 (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         2020-01-21 02:21
    root     pts/0        2020-01-21 02:35 (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 4
    -rw------- 1 root root 412 Jan 21 02:43 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 2048]----+
    |       +.        |
    |      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 12
    -rw------- 1 root root  412 Jan 21 02:43 authorized_keys
    -rw------- 1 root root 1675 Jan 21 02:44 id_rsa
    -rw-r--r-- 1 root root  412 Jan 21 02:44 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:93:c0:d4:6e:7e:13:16:61:f1:93:a7:38:01.
    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: 1 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: 1
    
    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         2020-01-21 02:27
    root     pts/0        2020-01-21 02:36 (172.200.0.1)
    [root@hdp103.yinzhengjie.org.cn ~]# 
    [root@hdp103.yinzhengjie.org.cn ~]# ssh hdp101.yinzhengjie.org.cn
    Last login: Tue Jan 21 02:39:07 2020 from 172.200.1.101
    [root@hdp101.yinzhengjie.org.cn ~]# 
    [root@hdp101.yinzhengjie.org.cn ~]# who
    root     tty1         2020-01-21 02:21
    root     pts/0        2020-01-21 02:35 (172.200.0.1)
    root     pts/1        2020-01-21 02:45 (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         2020-01-21 02:27
    root     pts/0        2020-01-21 02:36 (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         2020-01-21 02:27
    root     pts/0        2020-01-21 02:36 (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:93:c0:d4:6e:7e:13:16:61:f1:93:a7:38:01.
    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: 1 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: 1
    
    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 21 02:40:47 2020 from 172.200.1.101
    [root@hdp102.yinzhengjie.org.cn ~]# 
    [root@hdp102.yinzhengjie.org.cn ~]# who
    root     tty1         2020-01-21 02:24
    root     pts/0        2020-01-21 02:36 (172.200.0.1)
    root     pts/1        2020-01-21 02:46 (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         2020-01-21 02:27
    root     pts/0        2020-01-21 02:36 (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: 1 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: 1
    
    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         2020-01-21 02:27
    root     pts/0        2020-01-21 02:36 (172.200.0.1)
    [root@hdp103.yinzhengjie.org.cn ~]# 
    [root@hdp103.yinzhengjie.org.cn ~]# ssh hdp103.yinzhengjie.org.cn
    Last login: Tue Jan 21 02:43:38 2020 from 172.200.1.101
    [root@hdp103.yinzhengjie.org.cn ~]# 
    [root@hdp103.yinzhengjie.org.cn ~]# who
    root     tty1         2020-01-21 02:27
    root     pts/0        2020-01-21 02:36 (172.200.0.1)
    root     pts/1        2020-01-21 02:48 (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         2020-01-21 02:27
    root     pts/0        2020-01-21 02:36 (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 0:2.4.2.0-2.el7 will be installed
    --> Processing Dependency: sshpass for package: ansible-2.4.2.0-2.el7.noarch
    --> Processing Dependency: python2-jmespath for package: ansible-2.4.2.0-2.el7.noarch
    --> Processing Dependency: python-six for package: ansible-2.4.2.0-2.el7.noarch
    --> Processing Dependency: python-setuptools for package: ansible-2.4.2.0-2.el7.noarch
    --> Processing Dependency: python-passlib for package: ansible-2.4.2.0-2.el7.noarch
    --> Processing Dependency: python-paramiko for package: ansible-2.4.2.0-2.el7.noarch
    --> Processing Dependency: python-jinja2 for package: ansible-2.4.2.0-2.el7.noarch
    --> Processing Dependency: python-httplib2 for package: ansible-2.4.2.0-2.el7.noarch
    --> Processing Dependency: python-cryptography for package: ansible-2.4.2.0-2.el7.noarch
    --> Processing Dependency: PyYAML for package: ansible-2.4.2.0-2.el7.noarch
    --> Running transaction check
    ---> Package PyYAML.x86_64 0:3.10-11.el7 will be installed
    --> Processing Dependency: libyaml-0.so.2()(64bit) for package: PyYAML-3.10-11.el7.x86_64
    ---> Package python-httplib2.noarch 0:0.9.2-1.el7 will be installed
    ---> Package python-jinja2.noarch 0:2.7.2-4.el7 will be installed
    --> Processing Dependency: python-babel >= 0.8 for package: python-jinja2-2.7.2-4.el7.noarch
    --> Processing Dependency: python-markupsafe for package: python-jinja2-2.7.2-4.el7.noarch
    ---> Package python-paramiko.noarch 0:2.1.1-9.el7 will be installed
    --> Processing Dependency: python2-pyasn1 for package: python-paramiko-2.1.1-9.el7.noarch
    ---> Package python-passlib.noarch 0:1.6.5-2.el7 will be installed
    ---> Package python-setuptools.noarch 0:0.9.8-7.el7 will be installed
    --> Processing Dependency: python-backports-ssl_match_hostname for package: python-setuptools-0.9.8-7.el7.noarch
    ---> Package python-six.noarch 0:1.9.0-2.el7 will be installed
    ---> Package python2-cryptography.x86_64 0:1.7.2-2.el7 will be installed
    --> Processing Dependency: python-idna >= 2.0 for package: python2-cryptography-1.7.2-2.el7.x86_64
    --> Processing Dependency: python-cffi >= 1.4.1 for package: python2-cryptography-1.7.2-2.el7.x86_64
    --> Processing Dependency: python-ipaddress for package: python2-cryptography-1.7.2-2.el7.x86_64
    --> Processing Dependency: python-enum34 for package: python2-cryptography-1.7.2-2.el7.x86_64
    ---> Package python2-jmespath.noarch 0:0.9.0-3.el7 will be installed
    ---> Package sshpass.x86_64 0:1.06-2.el7 will be installed
    --> Running transaction check
    ---> Package libyaml.x86_64 0:0.1.4-11.el7_0 will be installed
    ---> Package python-babel.noarch 0:0.9.6-8.el7 will be installed
    ---> Package python-backports-ssl_match_hostname.noarch 0:3.5.0.1-1.el7 will be installed
    --> Processing Dependency: python-backports for package: python-backports-ssl_match_hostname-3.5.0.1-1.el7.noarch
    ---> Package python-cffi.x86_64 0:1.6.0-5.el7 will be installed
    --> Processing Dependency: python-pycparser for package: python-cffi-1.6.0-5.el7.x86_64
    ---> Package python-enum34.noarch 0:1.0.4-1.el7 will be installed
    ---> Package python-idna.noarch 0:2.4-1.el7 will be installed
    ---> Package python-ipaddress.noarch 0:1.0.16-2.el7 will be installed
    ---> Package python-markupsafe.x86_64 0:0.11-10.el7 will be installed
    ---> Package python2-pyasn1.noarch 0:0.1.9-7.el7 will be installed
    --> Running transaction check
    ---> Package python-backports.x86_64 0:1.0-8.el7 will be installed
    ---> Package python-pycparser.noarch 0:2.14-1.el7 will be installed
    --> Processing Dependency: python-ply for package: python-pycparser-2.14-1.el7.noarch
    --> Running transaction check
    ---> Package python-ply.noarch 0:3.4-11.el7 will be installed
    --> Finished Dependency Resolution
    
    Dependencies Resolved
    
    =======================================================================================================================================================
     Package                                                Arch                      Version                              Repository                 Size
    =======================================================================================================================================================
    Installing:
     ansible                                                noarch                    2.4.2.0-2.el7                        extras                    7.6 M
    Installing for dependencies:
     PyYAML                                                 x86_64                    3.10-11.el7                          base                      153 k
     libyaml                                                x86_64                    0.1.4-11.el7_0                       base                       55 k
     python-babel                                           noarch                    0.9.6-8.el7                          base                      1.4 M
     python-backports                                       x86_64                    1.0-8.el7                            base                      5.8 k
     python-backports-ssl_match_hostname                    noarch                    3.5.0.1-1.el7                        base                       13 k
     python-cffi                                            x86_64                    1.6.0-5.el7                          base                      218 k
     python-enum34                                          noarch                    1.0.4-1.el7                          base                       52 k
     python-httplib2                                        noarch                    0.9.2-1.el7                          extras                    115 k
     python-idna                                            noarch                    2.4-1.el7                            base                       94 k
     python-ipaddress                                       noarch                    1.0.16-2.el7                         base                       34 k
     python-jinja2                                          noarch                    2.7.2-4.el7                          base                      519 k
     python-markupsafe                                      x86_64                    0.11-10.el7                          base                       25 k
     python-paramiko                                        noarch                    2.1.1-9.el7                          base                      269 k
     python-passlib                                         noarch                    1.6.5-2.el7                          extras                    488 k
     python-ply                                             noarch                    3.4-11.el7                           base                      123 k
     python-pycparser                                       noarch                    2.14-1.el7                           base                      104 k
     python-setuptools                                      noarch                    0.9.8-7.el7                          base                      397 k
     python-six                                             noarch                    1.9.0-2.el7                          base                       29 k
     python2-cryptography                                   x86_64                    1.7.2-2.el7                          base                      502 k
     python2-jmespath                                       noarch                    0.9.0-3.el7                          extras                     39 k
     python2-pyasn1                                         noarch                    0.1.9-7.el7                          base                      100 k
     sshpass                                                x86_64                    1.06-2.el7                           extras                     21 k
    
    Transaction Summary
    =======================================================================================================================================================
    Install  1 Package (+22 Dependent packages)
    
    Total download size: 12 M
    Installed size: 60 M
    Downloading packages:
    (1/23): PyYAML-3.10-11.el7.x86_64.rpm                                                                                           | 153 kB  00:00:00     
    (2/23): libyaml-0.1.4-11.el7_0.x86_64.rpm                                                                                       |  55 kB  00:00:00     
    (3/23): python-backports-1.0-8.el7.x86_64.rpm                                                                                   | 5.8 kB  00:00:00     
    (4/23): python-backports-ssl_match_hostname-3.5.0.1-1.el7.noarch.rpm                                                            |  13 kB  00:00:00     
    (5/23): python-cffi-1.6.0-5.el7.x86_64.rpm                                                                                      | 218 kB  00:00:00     
    (6/23): python-enum34-1.0.4-1.el7.noarch.rpm                                                                                    |  52 kB  00:00:00     
    (7/23): python-idna-2.4-1.el7.noarch.rpm                                                                                        |  94 kB  00:00:00     
    (8/23): python-ipaddress-1.0.16-2.el7.noarch.rpm                                                                                |  34 kB  00:00:00     
    (9/23): python-babel-0.9.6-8.el7.noarch.rpm                                                                                     | 1.4 MB  00:00:00     
    (10/23): python-markupsafe-0.11-10.el7.x86_64.rpm                                                                               |  25 kB  00:00:00     
    (11/23): python-httplib2-0.9.2-1.el7.noarch.rpm                                                                                 | 115 kB  00:00:00     
    (12/23): python-passlib-1.6.5-2.el7.noarch.rpm                                                                                  | 488 kB  00:00:00     
    (13/23): python-pycparser-2.14-1.el7.noarch.rpm                                                                                 | 104 kB  00:00:00     
    (14/23): python-paramiko-2.1.1-9.el7.noarch.rpm                                                                                 | 269 kB  00:00:00     
    (15/23): python-jinja2-2.7.2-4.el7.noarch.rpm                                                                                   | 519 kB  00:00:00     
    (16/23): python-setuptools-0.9.8-7.el7.noarch.rpm                                                                               | 397 kB  00:00:00     
    (17/23): python-six-1.9.0-2.el7.noarch.rpm                                                                                      |  29 kB  00:00:00     
    (18/23): python-ply-3.4-11.el7.noarch.rpm                                                                                       | 123 kB  00:00:00     
    (19/23): python2-pyasn1-0.1.9-7.el7.noarch.rpm                                                                                  | 100 kB  00:00:00     
    (20/23): python2-jmespath-0.9.0-3.el7.noarch.rpm                                                                                |  39 kB  00:00:00     
    (21/23): python2-cryptography-1.7.2-2.el7.x86_64.rpm                                                                            | 502 kB  00:00:00     
    (22/23): sshpass-1.06-2.el7.x86_64.rpm                                                                                          |  21 kB  00:00:00     
    (23/23): ansible-2.4.2.0-2.el7.noarch.rpm                                                                                       | 7.6 MB  00:00:03     
    -------------------------------------------------------------------------------------------------------------------------------------------------------
    Total                                                                                                                  3.7 MB/s |  12 MB  00:00:03     
    Running transaction check
    Running transaction test
    Transaction test succeeded
    Running transaction
      Installing : python2-pyasn1-0.1.9-7.el7.noarch                                                                                                  1/23 
      Installing : python-ipaddress-1.0.16-2.el7.noarch                                                                                               2/23 
      Installing : python-six-1.9.0-2.el7.noarch                                                                                                      3/23 
      Installing : python-httplib2-0.9.2-1.el7.noarch                                                                                                 4/23 
      Installing : sshpass-1.06-2.el7.x86_64                                                                                                          5/23 
      Installing : libyaml-0.1.4-11.el7_0.x86_64                                                                                                      6/23 
      Installing : PyYAML-3.10-11.el7.x86_64                                                                                                          7/23 
      Installing : python-backports-1.0-8.el7.x86_64                                                                                                  8/23 
      Installing : python-backports-ssl_match_hostname-3.5.0.1-1.el7.noarch                                                                           9/23 
      Installing : python-setuptools-0.9.8-7.el7.noarch                                                                                              10/23 
      Installing : python-babel-0.9.6-8.el7.noarch                                                                                                   11/23 
      Installing : python-passlib-1.6.5-2.el7.noarch                                                                                                 12/23 
      Installing : python-ply-3.4-11.el7.noarch                                                                                                      13/23 
      Installing : python-pycparser-2.14-1.el7.noarch                                                                                                14/23 
      Installing : python-cffi-1.6.0-5.el7.x86_64                                                                                                    15/23 
      Installing : python-markupsafe-0.11-10.el7.x86_64                                                                                              16/23 
      Installing : python-jinja2-2.7.2-4.el7.noarch                                                                                                  17/23 
      Installing : python-idna-2.4-1.el7.noarch                                                                                                      18/23 
      Installing : python-enum34-1.0.4-1.el7.noarch                                                                                                  19/23 
      Installing : python2-cryptography-1.7.2-2.el7.x86_64                                                                                           20/23 
      Installing : python-paramiko-2.1.1-9.el7.noarch                                                                                                21/23 
      Installing : python2-jmespath-0.9.0-3.el7.noarch                                                                                               22/23 
      Installing : ansible-2.4.2.0-2.el7.noarch                                                                                                      23/23 
      Verifying  : python-backports-ssl_match_hostname-3.5.0.1-1.el7.noarch                                                                           1/23 
      Verifying  : python2-jmespath-0.9.0-3.el7.noarch                                                                                                2/23 
      Verifying  : python-enum34-1.0.4-1.el7.noarch                                                                                                   3/23 
      Verifying  : python-setuptools-0.9.8-7.el7.noarch                                                                                               4/23 
      Verifying  : python-jinja2-2.7.2-4.el7.noarch                                                                                                   5/23 
      Verifying  : python-six-1.9.0-2.el7.noarch                                                                                                      6/23 
      Verifying  : python-idna-2.4-1.el7.noarch                                                                                                       7/23 
      Verifying  : python-markupsafe-0.11-10.el7.x86_64                                                                                               8/23 
      Verifying  : python-ply-3.4-11.el7.noarch                                                                                                       9/23 
      Verifying  : python-passlib-1.6.5-2.el7.noarch                                                                                                 10/23 
      Verifying  : python-paramiko-2.1.1-9.el7.noarch                                                                                                11/23 
      Verifying  : python-babel-0.9.6-8.el7.noarch                                                                                                   12/23 
      Verifying  : python-backports-1.0-8.el7.x86_64                                                                                                 13/23 
      Verifying  : python-cffi-1.6.0-5.el7.x86_64                                                                                                    14/23 
      Verifying  : python-pycparser-2.14-1.el7.noarch                                                                                                15/23 
      Verifying  : libyaml-0.1.4-11.el7_0.x86_64                                                                                                     16/23 
      Verifying  : ansible-2.4.2.0-2.el7.noarch                                                                                                      17/23 
      Verifying  : python-ipaddress-1.0.16-2.el7.noarch                                                                                              18/23 
      Verifying  : sshpass-1.06-2.el7.x86_64                                                                                                         19/23 
      Verifying  : python-httplib2-0.9.2-1.el7.noarch                                                                                                20/23 
      Verifying  : python2-pyasn1-0.1.9-7.el7.noarch                                                                                                 21/23 
      Verifying  : PyYAML-3.10-11.el7.x86_64                                                                                                         22/23 
      Verifying  : python2-cryptography-1.7.2-2.el7.x86_64                                                                                           23/23 
    
    Installed:
      ansible.noarch 0:2.4.2.0-2.el7                                                                                                                       
    
    Dependency Installed:
      PyYAML.x86_64 0:3.10-11.el7                  libyaml.x86_64 0:0.1.4-11.el7_0                               python-babel.noarch 0:0.9.6-8.el7        
      python-backports.x86_64 0:1.0-8.el7          python-backports-ssl_match_hostname.noarch 0:3.5.0.1-1.el7    python-cffi.x86_64 0:1.6.0-5.el7         
      python-enum34.noarch 0:1.0.4-1.el7           python-httplib2.noarch 0:0.9.2-1.el7                          python-idna.noarch 0:2.4-1.el7           
      python-ipaddress.noarch 0:1.0.16-2.el7       python-jinja2.noarch 0:2.7.2-4.el7                            python-markupsafe.x86_64 0:0.11-10.el7   
      python-paramiko.noarch 0:2.1.1-9.el7         python-passlib.noarch 0:1.6.5-2.el7                           python-ply.noarch 0:3.4-11.el7           
      python-pycparser.noarch 0:2.14-1.el7         python-setuptools.noarch 0:0.9.8-7.el7                        python-six.noarch 0:1.9.0-2.el7          
      python2-cryptography.x86_64 0:1.7.2-2.el7    python2-jmespath.noarch 0:0.9.0-3.el7                         python2-pyasn1.noarch 0:0.1.9-7.el7      
      sshpass.x86_64 0:1.06-2.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[101:103].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=0 >>
    
    
    hdp101.yinzhengjie.org.cn | SUCCESS | rc=0 >>
    
    
    hdp103.yinzhengjie.org.cn | SUCCESS | rc=0 >>
    
    
    [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=0 >>
    5529 Jps
    
    hdp103.yinzhengjie.org.cn | SUCCESS | rc=0 >>
    5761 Jps
    
    hdp101.yinzhengjie.org.cn | SUCCESS | rc=0 >>
    6393 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=0
    [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=1
    [root@hdp101.yinzhengjie.org.cn ~]# 
    [root@hdp101.yinzhengjie.org.cn ~]# 

    2>.安装MySQL8.0软件源

    [root@hdp101.yinzhengjie.org.cn ~]# ll
    total 0
    [root@hdp101.yinzhengjie.org.cn ~]# 
    [root@hdp101.yinzhengjie.org.cn ~]# wget https://dev.mysql.com/get/mysql80-community-release-el7-3.noarch.rpm
    --2020-01-21 03:13:48--  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|:443... connected.
    HTTP request sent, awaiting response... 302 Found
    Location: https://repo.mysql.com//mysql80-community-release-el7-3.noarch.rpm [following]
    --2020-01-21 03:13:50--  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|:443... connected.
    HTTP request sent, awaiting response... 200 OK
    Length: 26024 (25K) [application/x-redhat-package-manager]
    Saving to: ‘mysql80-community-release-el7-3.noarch.rpm’
    
    100%[====================================================================================================================================================================================================================================>] 26,024       152KB/s   in 0.2s   
    
    2020-01-21 03:13:51 (152 KB/s) - ‘mysql80-community-release-el7-3.noarch.rpm’ saved [26024/26024]
    
    [root@hdp101.yinzhengjie.org.cn ~]# 
    [root@hdp101.yinzhengjie.org.cn ~]# ll
    total 28
    -rw-r--r-- 1 root root 26024 Apr 25  2019 mysql80-community-release-el7-3.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 32
    -rw-r--r--. 1 root root 1664 Nov 23  2018 CentOS-Base.repo
    -rw-r--r--. 1 root root 1309 Nov 23  2018 CentOS-CR.repo
    -rw-r--r--. 1 root root  649 Nov 23  2018 CentOS-Debuginfo.repo
    -rw-r--r--. 1 root root  314 Nov 23  2018 CentOS-fasttrack.repo
    -rw-r--r--. 1 root root  630 Nov 23  2018 CentOS-Media.repo
    -rw-r--r--. 1 root root 1331 Nov 23  2018 CentOS-Sources.repo
    -rw-r--r--. 1 root root 5701 Nov 23  2018 CentOS-Vault.repo
    [root@hdp101.yinzhengjie.org.cn ~]# 
    [root@hdp101.yinzhengjie.org.cn ~]# ll
    total 28
    -rw-r--r-- 1 root root 26024 Apr 25  2019 mysql80-community-release-el7-3.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-3.noarch.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
    Preparing...                          ################################# [100%]
    Updating / installing...
       1:mysql80-community-release-el7-3  ################################# [100%]
    [root@hdp101.yinzhengjie.org.cn ~]# 
    [root@hdp101.yinzhengjie.org.cn ~]# ll /etc/yum.repos.d/
    total 40
    -rw-r--r--. 1 root root 1664 Nov 23  2018 CentOS-Base.repo
    -rw-r--r--. 1 root root 1309 Nov 23  2018 CentOS-CR.repo
    -rw-r--r--. 1 root root  649 Nov 23  2018 CentOS-Debuginfo.repo
    -rw-r--r--. 1 root root  314 Nov 23  2018 CentOS-fasttrack.repo
    -rw-r--r--. 1 root root  630 Nov 23  2018 CentOS-Media.repo
    -rw-r--r--. 1 root root 1331 Nov 23  2018 CentOS-Sources.repo
    -rw-r--r--. 1 root root 5701 Nov 23  2018 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  00:00:00     
    extras                                                                                                                                                                                                                                                 | 2.9 kB  00:00:00     
    mysql-connectors-community                                                                                                                                                                                                                             | 2.5 kB  00:00:00     
    mysql-tools-community                                                                                                                                                                                                                                  | 2.5 kB  00:00:00     
    mysql80-community                                                                                                                                                                                                                                      | 2.5 kB  00:00:00     
    updates                                                                                                                                                                                                                                                | 2.9 kB  00:00:00     
    (1/3): mysql80-community/x86_64/primary_db                                                                                                                                                                                                             |  97 kB  00:00:00     
    (2/3): mysql-connectors-community/x86_64/primary_db                                                                                                                                                                                                    |  53 kB  00:00:01     
    (3/3): mysql-tools-community/x86_64/primary_db                                                                                                                                                                                                         |  69 kB  00:00:01     
    Resolving Dependencies
    --> Running transaction check
    ---> Package mysql-community-server.x86_64 0:8.0.19-1.el7 will be installed
    --> Processing Dependency: mysql-community-common(x86-64) = 8.0.19-1.el7 for package: mysql-community-server-8.0.19-1.el7.x86_64
    --> Processing Dependency: mysql-community-client(x86-64) >= 8.0.11 for package: mysql-community-server-8.0.19-1.el7.x86_64
    --> Running transaction check
    ---> Package mysql-community-client.x86_64 0:8.0.19-1.el7 will be installed
    --> Processing Dependency: mysql-community-libs(x86-64) >= 8.0.11 for package: mysql-community-client-8.0.19-1.el7.x86_64
    ---> Package mysql-community-common.x86_64 0:8.0.19-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:8.0.19-1.el7 will be obsoleting
    --> Running transaction check
    ---> Package mysql-community-libs-compat.x86_64 0:8.0.19-1.el7 will be obsoleting
    --> Finished Dependency Resolution
    
    Dependencies Resolved
    
    ==============================================================================================================================================================================================================================================================================
     Package                                                                      Arch                                                    Version                                                        Repository                                                          Size
    ==============================================================================================================================================================================================================================================================================
    Installing:
     mysql-community-libs                                                         x86_64                                                  8.0.19-1.el7                                                   mysql80-community                                                  4.0 M
         replacing  mariadb-libs.x86_64 1:5.5.60-1.el7_5
     mysql-community-libs-compat                                                  x86_64                                                  8.0.19-1.el7                                                   mysql80-community                                                  1.3 M
         replacing  mariadb-libs.x86_64 1:5.5.60-1.el7_5
     mysql-community-server                                                       x86_64                                                  8.0.19-1.el7                                                   mysql80-community                                                  436 M
    Installing for dependencies:
     mysql-community-client                                                       x86_64                                                  8.0.19-1.el7                                                   mysql80-community                                                   41 M
     mysql-community-common                                                       x86_64                                                  8.0.19-1.el7                                                   mysql80-community                                                  605 k
    
    Transaction Summary
    ==============================================================================================================================================================================================================================================================================
    Install  3 Packages (+2 Dependent packages)
    
    Total download size: 483 M
    Downloading packages:
    warning: /var/cache/yum/x86_64/7/mysql80-community/packages/mysql-community-common-8.0.19-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY                                                                            ] 320 kB/s | 540 kB  00:25:42 ETA 
    Public key for mysql-community-common-8.0.19-1.el7.x86_64.rpm is not installed
    (1/5): mysql-community-common-8.0.19-1.el7.x86_64.rpm                                                                                                                                                                                                  | 605 kB  00:00:01     
    (2/5): mysql-community-libs-8.0.19-1.el7.x86_64.rpm                                                                                                                                                                                                    | 4.0 MB  00:00:02     
    (3/5): mysql-community-libs-compat-8.0.19-1.el7.x86_64.rpm                                                                                                                                                                                             | 1.3 MB  00:00:00     
    (4/5): mysql-community-client-8.0.19-1.el7.x86_64.rpm                                                                                                                                                                                                  |  41 MB  00:00:07     
    (5/5): mysql-community-server-8.0.19-1.el7.x86_64.rpm                                                                                                                                                                                                  | 436 MB  00:00:42     
    ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    Total                                                                                                                                                                                                                                          10 MB/s | 483 MB  00:00:47     
    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    : mysql80-community-release-el7-3.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.19-1.el7.x86_64                                                                                                                                                                                                                 1/6 
      Installing : mysql-community-libs-8.0.19-1.el7.x86_64                                                                                                                                                                                                                   2/6 
      Installing : mysql-community-client-8.0.19-1.el7.x86_64                                                                                                                                                                                                                 3/6 
      Installing : mysql-community-server-8.0.19-1.el7.x86_64                                                                                                                                                                                                                 4/6 
      Installing : mysql-community-libs-compat-8.0.19-1.el7.x86_64                                                                                                                                                                                                            5/6 
      Erasing    : 1:mariadb-libs-5.5.60-1.el7_5.x86_64                                                                                                                                                                                                                       6/6 
      Verifying  : mysql-community-libs-8.0.19-1.el7.x86_64                                                                                                                                                                                                                   1/6 
      Verifying  : mysql-community-libs-compat-8.0.19-1.el7.x86_64                                                                                                                                                                                                            2/6 
      Verifying  : mysql-community-client-8.0.19-1.el7.x86_64                                                                                                                                                                                                                 3/6 
      Verifying  : mysql-community-common-8.0.19-1.el7.x86_64                                                                                                                                                                                                                 4/6 
      Verifying  : mysql-community-server-8.0.19-1.el7.x86_64                                                                                                                                                                                                                 5/6 
      Verifying  : 1:mariadb-libs-5.5.60-1.el7_5.x86_64                                                                                                                                                                                                                       6/6 
    
    Installed:
      mysql-community-libs.x86_64 0:8.0.19-1.el7                                            mysql-community-libs-compat.x86_64 0:8.0.19-1.el7                                            mysql-community-server.x86_64 0:8.0.19-1.el7                                           
    
    Dependency Installed:
      mysql-community-client.x86_64 0:8.0.19-1.el7                                                                                          mysql-community-common.x86_64 0:8.0.19-1.el7                                                                                         
    
    Replaced:
      mariadb-libs.x86_64 1:5.5.60-1.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 0
    drwxr-xr-x. 3 root root 15 Jan 20 05:28 x86_64
    [root@hdp101.yinzhengjie.org.cn ~]# 
    [root@hdp101.yinzhengjie.org.cn ~]# ll /var/cache/yum/$basearch/$releasever/x86_64
    total 0
    drwxr-xr-x. 8 root root 202 Jan 21 03:17 7
    [root@hdp101.yinzhengjie.org.cn ~]# 
    [root@hdp101.yinzhengjie.org.cn ~]# ll /var/cache/yum/$basearch/$releasever/x86_64/7
    total 8
    drwxr-xr-x. 4 root root 278 Jan 21 03:17 base
    drwxr-xr-x. 4 root root 183 Jan 21 03:17 extras
    drwxr-xr-x  4 root root 137 Jan 21 03:17 mysql80-community
    drwxr-xr-x  4 root root 137 Jan 21 03:17 mysql-connectors-community
    drwxr-xr-x  4 root root 137 Jan 21 03:17 mysql-tools-community
    -rw-r--r--  1 root root 530 Jan 21 03:17 timedhosts
    -rw-r--r--. 1 root root 489 Jan 20 05:28 timedhosts.txt
    drwxr-xr-x. 4 root root 183 Jan 21 03:17 updates
    [root@hdp101.yinzhengjie.org.cn ~]# 
    [root@hdp101.yinzhengjie.org.cn ~]# 
    [root@hdp101.yinzhengjie.org.cn ~]# ll /var/cache/yum/$basearch/$releasever/x86_64/7/mysql80-community
    total 104
    -rw-r--r-- 1 root root 99494 Jan  9 19:16 1fd8234d262afcc83f200d02b90b12d38fc3f59b-primary.sqlite.bz2
    -rw-r--r-- 1 root root     0 Jan 21 03:17 cachecookie
    drwxr-xr-x 2 root root    31 Jan 21 03:17 gen
    drwxr-xr-x 2 root root   279 Jan 21 03:17 packages
    -rw-r--r-- 1 root root  2525 Jan  9 19:16 repomd.xml
    [root@hdp101.yinzhengjie.org.cn ~]# 
    [root@hdp101.yinzhengjie.org.cn ~]# ll /var/cache/yum/$basearch/$releasever/x86_64/7/mysql80-community/packages        #安装MySQL的rpm包会存在这里,我们可以直接拷贝到生产服务器上安装。
    total 494732
    -rw-r--r-- 1 root root  43126424 Jan  9 19:13 mysql-community-client-8.0.19-1.el7.x86_64.rpm
    -rw-r--r-- 1 root root    619248 Jan  9 19:13 mysql-community-common-8.0.19-1.el7.x86_64.rpm
    -rw-r--r-- 1 root root   4212908 Jan  9 19:14 mysql-community-libs-8.0.19-1.el7.x86_64.rpm
    -rw-r--r-- 1 root root   1365572 Jan  9 19:14 mysql-community-libs-compat-8.0.19-1.el7.x86_64.rpm
    -rw-r--r-- 1 root root 457272180 Jan  9 19:14 mysql-community-server-8.0.19-1.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(8)
               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 2020-01-21 03:29:33 CST; 8s ago
         Docs: man:mysqld(8)
               http://dev.mysql.com/doc/refman/en/using-systemd.html
      Process: 6607 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS)
     Main PID: 6684 (mysqld)
       Status: "Server is operational"
       CGroup: /system.slice/mysqld.service
               └─6684 /usr/sbin/mysqld
    
    Jan 21 03:29:28 hdp101.yinzhengjie.org.cn systemd[1]: Starting MySQL Server...
    Jan 21 03:29:33 hdp101.yinzhengjie.org.cn systemd[1]: 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 
    2020-01-20T19:29:28.259360Z 0 [System] [MY-013169] [Server] /usr/sbin/mysqld (mysqld 8.0.19) initializing of server in progress as process 6634
    2020-01-20T19:29:30.310721Z 5 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: tW-l9!YS_R<6
    2020-01-20T19:29:33.011165Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.19) starting as process 6684
    2020-01-20T19:29:33.880394Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed.
    2020-01-20T19:29:33.899499Z 0 [System] [MY-010931] [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: 33060[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 8
    Server version: 8.0.19
    
    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 user() identified by 'yzj@2019MySQL';
    Query OK, 0 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 9
    Server version: 8.0.19 MySQL Community Server - GPL
    
    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> set GLOBAL validate_password.policy=0;
    Query OK, 0 rows affected (0.00 sec)
    
    mysql> alter user user() identified by 'yinzhengjie';
    Query OK, 0 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 10
    Server version: 8.0.19 MySQL Community Server - GPL
    
    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> show variables like '%validate_password_policy%';
    +--------------------------+-------+
    | Variable_name            | Value |
    +--------------------------+-------+
    | validate_password.policy | LOW   |
    +--------------------------+-------+
    1 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 11
    Server version: 8.0.19 MySQL Community Server - GPL
    
    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> 
    mysql> CREATE DATABASE ambari DEFAULT CHARACTER SET UTF8;
    Query OK, 1 row affected, 1 warning (0.00 sec)
    
    mysql> 
    mysql> CREATE USER ambari@'%' IDENTIFIED WITH mysql_native_password BY 'yinzhengjie';
    Query OK, 0 rows affected (0.00 sec)
    
    mysql> 
    mysql> GRANT ALL PRIVILEGES ON ambari.* TO ambari@'%';
    Query OK, 0 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`@`%` |
    +----------------------------------------------------+
    2 rows in set (0.00 sec)
    
    mysql> 
    mysql> FLUSH PRIVILEGES;
    Query OK, 0 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 0
    [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
    --2020-01-21 04:53:27--  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|:443... connected.
    HTTP request sent, awaiting response... 302 Found
    Location: https://cdn.mysql.com//Downloads/Connector-J/mysql-connector-java-8.0.19.tar.gz [following]
    --2020-01-21 04:53:29--  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|:443... connected.
    HTTP request sent, awaiting response... 200 OK
    Length: 3877895 (3.7M) [application/x-tar-gz]
    Saving to: ‘mysql-connector-java-8.0.19.tar.gz’
    
    100%[=============================================================================================================>] 3,877,895   2.05MB/s   in 1.8s   
    
    2020-01-21 04:53:31 (2.05 MB/s) - ‘mysql-connector-java-8.0.19.tar.gz’ saved [3877895/3877895]
    
    [root@hdp101.yinzhengjie.org.cn ~]# 
    [root@hdp101.yinzhengjie.org.cn ~]# ll
    total 3788
    -rw-r--r-- 1 root root 3877895 Dec  4 18:44 mysql-connector-java-8.0.19.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 3788
    -rw-r--r-- 1 root root 3877895 Dec  4 18:44 mysql-connector-java-8.0.19.tar.gz
    [root@hdp101.yinzhengjie.org.cn ~]# 
    [root@hdp101.yinzhengjie.org.cn ~]# tar zxf mysql-connector-java-8.0.19.tar.gz 
    [root@hdp101.yinzhengjie.org.cn ~]# 
    [root@hdp101.yinzhengjie.org.cn ~]# ll
    total 3788
    drwxr-xr-x 3 root root     149 Dec  4 19:44 mysql-connector-java-8.0.19
    -rw-r--r-- 1 root root 3877895 Dec  4 18:44 mysql-connector-java-8.0.19.tar.gz
    [root@hdp101.yinzhengjie.org.cn ~]# 
    [root@hdp101.yinzhengjie.org.cn ~]# ll mysql-connector-java-8.0.19
    total 2760
    -rw-r--r-- 1 root root   89517 Dec  4 19:44 build.xml
    -rw-r--r-- 1 root root  263989 Dec  4 19:44 CHANGES
    -rw-r--r-- 1 root root     183 Dec  4 19:44 INFO_BIN
    -rw-r--r-- 1 root root     135 Dec  4 19:44 INFO_SRC
    -rw-r--r-- 1 root root   97191 Dec  4 19:44 LICENSE
    -rw-r--r-- 1 root root 2356711 Dec  4 19:44 mysql-connector-java-8.0.19.jar
    -rw-r--r-- 1 root root    1266 Dec  4 19:44 README
    drwxr-xr-x 8 root root      86 Dec  4 19:44 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.19
    total 2760
    -rw-r--r-- 1 root root   89517 Dec  4 19:44 build.xml
    -rw-r--r-- 1 root root  263989 Dec  4 19:44 CHANGES
    -rw-r--r-- 1 root root     183 Dec  4 19:44 INFO_BIN
    -rw-r--r-- 1 root root     135 Dec  4 19:44 INFO_SRC
    -rw-r--r-- 1 root root   97191 Dec  4 19:44 LICENSE
    -rw-r--r-- 1 root root 2356711 Dec  4 19:44 mysql-connector-java-8.0.19.jar
    -rw-r--r-- 1 root root    1266 Dec  4 19:44 README
    drwxr-xr-x 8 root root      86 Dec  4 19:44 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.19/mysql-connector-java-8.0.19.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 2304
    -rw-r--r-- 1 root root 2356711 Dec  4 19:44 mysql-connector-java-8.0.19.jar
    [root@hdp101.yinzhengjie.org.cn /usr/share/java]# 
    [root@hdp101.yinzhengjie.org.cn /usr/share/java]# ln -s mysql-connector-java-8.0.19.jar mysql-connector-java.jar
    [root@hdp101.yinzhengjie.org.cn /usr/share/java]# 
    [root@hdp101.yinzhengjie.org.cn /usr/share/java]# ll
    total 2304
    -rw-r--r-- 1 root root 2356711 Dec  4 19:44 mysql-connector-java-8.0.19.jar
    lrwxrwxrwx 1 root root      31 Jan 21 07:21 mysql-connector-java.jar -> mysql-connector-java-8.0.19.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 0
    [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
    --2020-01-21 05:20:21--  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-1.hortonworks.com (public-repo-1.hortonworks.com)... 143.204.83.25, 143.204.83.47, 143.204.83.107, ...
    Connecting to public-repo-1.hortonworks.com (public-repo-1.hortonworks.com)|143.204.83.25|:80... connected.
    HTTP request sent, awaiting response... 200 OK
    Length: 2030700094 (1.9G) [application/x-tar]
    Saving to: ‘ambari-2.7.4.0-centos7.tar.gz’
    
    100%[===========================================================================================================>] 2,030,700,094 10.7MB/s   in 2m 59s 
    
    2020-01-21 05:23:20 (10.8 MB/s) - ‘ambari-2.7.4.0-centos7.tar.gz’ saved [2030700094/2030700094]
    
    [root@hdp101.yinzhengjie.org.cn ~]# 
    [root@hdp101.yinzhengjie.org.cn ~]# ll
    total 1983108
    -rw-r--r-- 1 root root 2030700094 Aug 26 21:13 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 1983108
    -rw-r--r-- 1 root root 2030700094 Aug 26 21:13 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
    --2020-01-21 05:24:30--  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-1.hortonworks.com (public-repo-1.hortonworks.com)... 13.225.166.14, 13.225.166.74, 13.225.166.21, ...
    Connecting to public-repo-1.hortonworks.com (public-repo-1.hortonworks.com)|13.225.166.14|:80... connected.
    HTTP request sent, awaiting response... 200 OK
    Length: 9506255805 (8.9G) [application/x-tar]
    Saving to: ‘HDP-3.1.4.0-centos7-rpm.tar.gz’
    
    100%[===========================================================================================================>] 9,506,255,805 10.2MB/s   in 13m 56s
    
    2020-01-21 05:38:27 (10.8 MB/s) - ‘HDP-3.1.4.0-centos7-rpm.tar.gz’ saved [9506255805/9506255805]
    
    [root@hdp101.yinzhengjie.org.cn ~]# 
    [root@hdp101.yinzhengjie.org.cn ~]# ll
    total 11266564
    -rw-r--r-- 1 root root 2030700094 Aug 26 21:13 ambari-2.7.4.0-centos7.tar.gz
    -rw-r--r-- 1 root root 9506255805 Aug 26 21:26 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-- 1 root root 1.9G Aug 26 21:13 ambari-2.7.4.0-centos7.tar.gz
    -rw-r--r-- 1 root root 8.9G Aug 26 21:26 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
    --2020-01-21 05:39:24--  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-1.hortonworks.com (public-repo-1.hortonworks.com)... 13.249.171.70, 13.249.171.122, 13.249.171.64, ...
    Connecting to public-repo-1.hortonworks.com (public-repo-1.hortonworks.com)|13.249.171.70|:80... connected.
    HTTP request sent, awaiting response... 200 OK
    Length: 90606616 (86M) [application/x-tar]
    Saving to: ‘HDP-UTILS-1.1.0.22-centos7.tar.gz’
    
    100%[=============================================================================================================>] 90,606,616  11.3MB/s   in 8.3s   
    
    2020-01-21 05:39:33 (10.4 MB/s) - ‘HDP-UTILS-1.1.0.22-centos7.tar.gz’ saved [90606616/90606616]
    
    [root@hdp101.yinzhengjie.org.cn ~]# 
    [root@hdp101.yinzhengjie.org.cn ~]# ll -h
    total 11G
    -rw-r--r-- 1 root root 1.9G Aug 26 21:13 ambari-2.7.4.0-centos7.tar.gz
    -rw-r--r-- 1 root root 8.9G Aug 26 21:26 HDP-3.1.4.0-centos7-rpm.tar.gz
    -rw-r--r-- 1 root root  87M Aug 13  2018 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-- 1 root root 1.9G Aug 26 21:13 ambari-2.7.4.0-centos7.tar.gz
    -rw-r--r-- 1 root root 8.9G Aug 26 21:26 HDP-3.1.4.0-centos7-rpm.tar.gz
    -rw-r--r-- 1 root root  87M Aug 13  2018 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
    --2020-01-21 05:44:46--  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-1.hortonworks.com (public-repo-1.hortonworks.com)... 13.249.171.64, 13.249.171.122, 13.249.171.43, ...
    Connecting to public-repo-1.hortonworks.com (public-repo-1.hortonworks.com)|13.249.171.64|:80... connected.
    HTTP request sent, awaiting response... 200 OK
    Length: 162038 (158K) [application/x-tar]
    Saving to: ‘HDP-GPL-3.1.4.0-centos7-gpl.tar.gz’
    
    100%[=============================================================================================================>] 162,038      712KB/s   in 0.2s   
    
    2020-01-21 05:44:47 (712 KB/s) - ‘HDP-GPL-3.1.4.0-centos7-gpl.tar.gz’ saved [162038/162038]
    
    [root@hdp101.yinzhengjie.org.cn ~]# 
    [root@hdp101.yinzhengjie.org.cn ~]# ll -h
    total 11G
    -rw-r--r-- 1 root root 1.9G Aug 26 21:13 ambari-2.7.4.0-centos7.tar.gz
    -rw-r--r-- 1 root root 8.9G Aug 26 21:26 HDP-3.1.4.0-centos7-rpm.tar.gz
    -rw-r--r-- 1 root root 159K Aug 27 00:31 HDP-GPL-3.1.4.0-centos7-gpl.tar.gz
    -rw-r--r-- 1 root root  87M Aug 13  2018 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.6
    Release     : 90.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 0:2.4.6-90.el7.centos will be installed
    --> Processing Dependency: httpd-tools = 2.4.6-90.el7.centos for package: httpd-2.4.6-90.el7.centos.x86_64
    --> Processing Dependency: /etc/mime.types for package: httpd-2.4.6-90.el7.centos.x86_64
    --> Processing Dependency: libaprutil-1.so.0()(64bit) for package: httpd-2.4.6-90.el7.centos.x86_64
    --> Processing Dependency: libapr-1.so.0()(64bit) for package: httpd-2.4.6-90.el7.centos.x86_64
    --> Running transaction check
    ---> Package apr.x86_64 0:1.4.8-5.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-90.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-90.el7.centos                          base                          2.7 M
    Installing for dependencies:
     apr                                  x86_64                          1.4.8-5.el7                                  base                          103 k
     apr-util                             x86_64                          1.5.2-6.el7                                  base                           92 k
     httpd-tools                          x86_64                          2.4.6-90.el7.centos                          base                           91 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): apr-util-1.5.2-6.el7.x86_64.rpm                                                                                          |  92 kB  00:00:00     
    (2/5): apr-1.4.8-5.el7.x86_64.rpm                                                                                               | 103 kB  00:00:00     
    (3/5): httpd-tools-2.4.6-90.el7.centos.x86_64.rpm                                                                               |  91 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-90.el7.centos.x86_64.rpm                                                                                     | 2.7 MB  00:00:00     
    -------------------------------------------------------------------------------------------------------------------------------------------------------
    Total                                                                                                                  4.7 MB/s | 3.0 MB  00:00:00     
    Running transaction check
    Running transaction test
    Transaction test succeeded
    Running transaction
      Installing : apr-1.4.8-5.el7.x86_64                                                                                                              1/5 
      Installing : apr-util-1.5.2-6.el7.x86_64                                                                                                         2/5 
      Installing : httpd-tools-2.4.6-90.el7.centos.x86_64                                                                                              3/5 
      Installing : mailcap-2.1.41-2.el7.noarch                                                                                                         4/5 
      Installing : httpd-2.4.6-90.el7.centos.x86_64                                                                                                    5/5 
      Verifying  : apr-1.4.8-5.el7.x86_64                                                                                                              1/5 
      Verifying  : mailcap-2.1.41-2.el7.noarch                                                                                                         2/5 
      Verifying  : httpd-tools-2.4.6-90.el7.centos.x86_64                                                                                              3/5 
      Verifying  : apr-util-1.5.2-6.el7.x86_64                                                                                                         4/5 
      Verifying  : httpd-2.4.6-90.el7.centos.x86_64                                                                                                    5/5 
    
    Installed:
      httpd.x86_64 0:2.4.6-90.el7.centos                                                                                                                   
    
    Dependency Installed:
      apr.x86_64 0:1.4.8-5.el7       apr-util.x86_64 0:1.5.2-6.el7       httpd-tools.x86_64 0:2.4.6-90.el7.centos       mailcap.noarch 0:2.1.41-2.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(8)
               man:apachectl(8)
    [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 2020-01-21 05:49:22 CST; 1s ago
         Docs: man:httpd(8)
               man:apachectl(8)
     Main PID: 7571 (httpd)
       Status: "Processing requests..."
       CGroup: /system.slice/httpd.service
               ├─7571 /usr/sbin/httpd -DFOREGROUND
               ├─7572 /usr/sbin/httpd -DFOREGROUND
               ├─7573 /usr/sbin/httpd -DFOREGROUND
               ├─7574 /usr/sbin/httpd -DFOREGROUND
               ├─7575 /usr/sbin/httpd -DFOREGROUND
               └─7576 /usr/sbin/httpd -DFOREGROUND
    
    Jan 21 05:49:22 hdp101.yinzhengjie.org.cn systemd[1]: Starting The Apache HTTP Server...
    Jan 21 05:49:22 hdp101.yinzhengjie.org.cn systemd[1]: 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 11355208
    -rw-r--r-- 1 root root 2030700094 Aug 26 21:13 ambari-2.7.4.0-centos7.tar.gz
    -rw-r--r-- 1 root root 9506255805 Aug 26 21:26 HDP-3.1.4.0-centos7-rpm.tar.gz
    -rw-r--r-- 1 root root     162038 Aug 27 00:31 HDP-GPL-3.1.4.0-centos7-gpl.tar.gz
    -rw-r--r-- 1 root root   90606616 Aug 13  2018 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 0
    drwxr-xr-x 3 root root  21 Jan 21 05:54 ambari
    drwxr-xr-x 3 1001 users 21 Aug 26 20:47 HDP
    drwxr-xr-x 3 1001 users 21 Aug 27 00:31 HDP-GPL
    drwxr-xr-x 3 1001 users 21 Aug 13  2018 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=1
    gpgcheck=0
    [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                                                                   13
    base/7/x86_64                                                               CentOS-7 - Base                                                      10,097
    extras/7/x86_64                                                             CentOS-7 - Extras                                                       307
    mysql-connectors-community/x86_64                                           MySQL Connectors Community                                              141
    mysql-tools-community/x86_64                                                MySQL Tools Community                                                   105
    mysql80-community/x86_64                                                    MySQL 8.0 Community Server                                              161
    updates/7/x86_64                                                            CentOS-7 - Updates                                                    1,063
    repolist: 11,887
    [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 0:2.7.4.0-118 will be installed
    --> Processing Dependency: postgresql-server >= 8.1 for package: ambari-server-2.7.4.0-118.x86_64
    --> Running transaction check
    ---> Package postgresql-server.x86_64 0:9.2.24-1.el7_5 will be installed
    --> Processing Dependency: postgresql-libs(x86-64) = 9.2.24-1.el7_5 for package: postgresql-server-9.2.24-1.el7_5.x86_64
    --> Processing Dependency: postgresql(x86-64) = 9.2.24-1.el7_5 for package: postgresql-server-9.2.24-1.el7_5.x86_64
    --> Processing Dependency: libpq.so.5()(64bit) for package: postgresql-server-9.2.24-1.el7_5.x86_64
    --> Running transaction check
    ---> Package postgresql.x86_64 0:9.2.24-1.el7_5 will be installed
    ---> Package postgresql-libs.x86_64 0:9.2.24-1.el7_5 will be installed
    --> Finished Dependency Resolution
    
    Dependencies Resolved
    
    =======================================================================================================================================================
     Package                                  Arch                          Version                               Repository                          Size
    =======================================================================================================================================================
    Installing:
     ambari-server                            x86_64                        2.7.4.0-118                           ambari-repo                        370 M
    Installing for dependencies:
     postgresql                               x86_64                        9.2.24-1.el7_5                        base                               3.0 M
     postgresql-libs                          x86_64                        9.2.24-1.el7_5                        base                               234 k
     postgresql-server                        x86_64                        9.2.24-1.el7_5                        base                               3.8 M
    
    Transaction Summary
    =======================================================================================================================================================
    Install  1 Package (+3 Dependent packages)
    
    Total download size: 377 M
    Installed size: 470 M
    Downloading packages:
    (1/4): postgresql-libs-9.2.24-1.el7_5.x86_64.rpm                                                                                | 234 kB  00:00:00     
    (2/4): postgresql-server-9.2.24-1.el7_5.x86_64.rpm                                                                              | 3.8 MB  00:00:01     
    (3/4): ambari-server-2.7.4.0-118.x86_64.rpm                                                                                     | 370 MB  00:00:02     
    (4/4): postgresql-9.2.24-1.el7_5.x86_64.rpm                                                                                     | 3.0 MB  00:00:02     
    -------------------------------------------------------------------------------------------------------------------------------------------------------
    Total                                                                                                                  125 MB/s | 377 MB  00:00:03     
    Running transaction check
    Running transaction test
    Transaction test succeeded
    Running transaction
      Installing : postgresql-libs-9.2.24-1.el7_5.x86_64                                                                                               1/4 
      Installing : postgresql-9.2.24-1.el7_5.x86_64                                                                                                    2/4 
      Installing : postgresql-server-9.2.24-1.el7_5.x86_64                                                                                             3/4 
      Installing : ambari-server-2.7.4.0-118.x86_64                                                                                                    4/4 
      Verifying  : postgresql-server-9.2.24-1.el7_5.x86_64                                                                                             1/4 
      Verifying  : postgresql-libs-9.2.24-1.el7_5.x86_64                                                                                               2/4 
      Verifying  : ambari-server-2.7.4.0-118.x86_64                                                                                                    3/4 
      Verifying  : postgresql-9.2.24-1.el7_5.x86_64                                                                                                    4/4 
    
    Installed:
      ambari-server.x86_64 0:2.7.4.0-118                                                                                                                   
    
    Dependency Installed:
      postgresql.x86_64 0:9.2.24-1.el7_5            postgresql-libs.x86_64 0:9.2.24-1.el7_5            postgresql-server.x86_64 0:9.2.24-1.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 12
    Server version: 8.0.19 MySQL Community Server - GPL
    
    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> 
    mysql> SHOW DATABASES;
    +--------------------+
    | Database           |
    +--------------------+
    | ambari             |
    | information_schema |
    +--------------------+
    2 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, 0 rows affected (0.01 sec)
    Records: 0  Duplicates: 0  Warnings: 0
    
    Query OK, 0 rows affected (0.01 sec)
    Records: 0  Duplicates: 0  Warnings: 0
    
    Query OK, 0 rows affected (0.01 sec)
    Records: 0  Duplicates: 0  Warnings: 0
    
    Query OK, 0 rows affected (0.01 sec)
    Records: 0  Duplicates: 0  Warnings: 0
    
    Query OK, 0 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     |
    +-------------------------------+
    109 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环境
    [1] Oracle JDK 1.8 + Java Cryptography Extension (JCE) Policy Files 8
    [2] Custom JDK
    ==============================================================================
    Enter choice (1): 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: 8
    Minimum JDK version is 8 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:
    [1] - PostgreSQL (Embedded)
    [2] - Oracle
    [3] - MySQL / MariaDB
    [4] - PostgreSQL
    [5] - Microsoft SQL Server (Tech Preview)
    [6] - SQL Anywhere
    [7] - BDB
    ==============================================================================
    Enter choice (1): 3                #由于咱们安装的MySQL数据库,选择对应的数字3即可,接下来配置数据库信息即可,如果不设置则使用默认的配置。
    Hostname (localhost): 
    Port (3306): 
    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.118.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建表语句也失败了。虽然解决了问题,但我从建表语句上看不出来问题,目前怀疑可能是我用的最新版本的数据库导致的,等我再换一个版本的数据库测试一下。

  • 相关阅读:
    Ztree-
    富文本编辑器Ueditor
    通知 弹框
    ResultEntity
    echart
    定时器,定时发邮件JavaMail
    重定向传值
    图片验证码
    异步json发送put或者delete
    异步时间格式转换插件
  • 原文地址:https://www.cnblogs.com/yinzhengjie2020/p/12219108.html
Copyright © 2011-2022 走看看