部署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 hdp102.yinzhengjie.org.cn: 3G-6G hdp103.yinzhengjie.org.cn: 3G-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
ansible基础命令使用可参考: https://www.cnblogs.com/yinzhengjie/p/10447587.html
5>.使用ansible工具验证免密配置
三.
四.
五.