用namenode做cm server,要配置ssh 无密码登录,访问datanode。
--1.需要在namenode生成密钥
[root@master01 ~]# ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):
Created directory '/root/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
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:
1a:10:38:c7:5d:dd:6b:f8:32:c5:a8:68:b5:ff:66:1d root@slave07
The key's randomart image is:
+--[ RSA 2048]----+
| o.. ... . |
| o o.. . . |
| o. + . |
| . . o = |
| .oSo + |
| ooo o . E |
| .. . o . . |
| . o . |
| +. |
+-----------------+
[root@master01 .ssh]# pwd
/root/.ssh
[root@master01 .ssh]# ls
id_rsa id_rsa.pub known_hosts
[root@master01 .ssh]# cp id_rsa.pub authorized_keys
[root@master01 .ssh]# ls
authorized_keys id_rsa id_rsa.pub known_hosts
[root@slave07 ~]# ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):
Created directory '/root/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
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:
1a:10:38:c7:5d:dd:6b:f8:32:c5:a8:68:b5:ff:66:1d root@slave07
The key's randomart image is:
+--[ RSA 2048]----+
| o.. ... . |
| o o.. . . |
| o. + . |
| . . o = |
| .oSo + |
| ooo o . E |
| .. . o . . |
| . o . |
| +. |
+-----------------+
[root@slave07 ~]#
--4. 把nn的公钥 传到 dn中 /root/.ssh/ 下(这里以slave07为例)
[root@master01 .ssh]# scp authorized_keys root@slave07:/root/.ssh/
root@192.168.156.28's password:
authorized_keys 100% 395 0.4KB/s 00:00
[root@master01 .ssh]#
[root@master01 .ssh]# ssh slave07
The authenticity of host 'slave07 (192.168.156.28)' can't be established.
RSA key fingerprint is a0:16:4d:76:9a:d9:2b:3f:0c:5c:9b:41:fe:19:a5:4e.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'slave07' (RSA) to the list of known hosts.
Last login: Wed Jun 15 22:49:21 2016 from 192.168.156.199
[root@slave07 ~]#
--6. 再次从master01 到 slave07,就无需任何提示。
[root@slave07 ~]# exit;
logout
Connection to slave07 closed.
[root@master01 .ssh]# ssh slave07
Last login: Wed Jun 15 22:57:22 2016 from master01
[root@slave07 ~]#
--7.完成。
注: 如果安装节点超过10以上,50台,请写成shell脚本自动完成 ssh免密钥登录。