ambari,CDH安装大数据环境,都需要ssh免密登录,当然手动安装apache版本的hadoop环境也需要。
注意:访问的用户名和登录用户一致 如:三台机器都有root用户,以下的行为都基于同一用户
- 第一步: 配置hadoopmaster节点无密码登录到其他节点,在hadoopmaster节点上操作
ssh-keygen -t rsa 运行结束以后, 默认在 ~/.ssh目录生成两个文件:
id_rsa :私钥
id_rsa.pub :公钥
[root@hadoopmaster ~]# 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:
SHA256:NMVPXezqq+MPf95MtP5bzaghnvXSljcC4BH/QFCvm+I root@hadoopmaster
The key's randomart image is:
+---[RSA 2048]----+
| o+. . o.|
| o..o . .|
| o +o . . |
| . + oo .|
| S o.o ..|
| . .o..+o|
| ..o=o.o=|
| ...+oB*+=|
| Eo.+**BO|
+----[SHA256]-----+
- 第二步: 拷贝ssh公钥到其他节点
[root@hadoopmaster ~]# ssh-copy-id hadoopslave1
[root@hadoopmaster ~]# ssh-copy-id hadoopslave2
[root@hadoopmaster ~]# ssh-copy-id hadoopslave3
[root@hadoopmaster ~]# ssh-copy-id hadoopslave4
拷贝公钥到其他节点也可以使用scp命令
- 第三步: 导入公钥到认证文件
导入本机(hadoopmaster)
cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
在被访问的服务器上(hadoopslave1 hadoopslave2,hadoopslave3,hadoopslave4 )
cat ~/id_rsa.pub >> ~/.ssh/authorized_keys
- 第四步:在服务器上更改权限(必须) (hadoopslave1 hadoopslave2,hadoopslave3,hadoopslave4)
检查权限,可能需要更改权限
chmod 755 ~
chmod 700 ~/.ssh
chmod 600 ~/.ssh/authorized_keys
- 第五步:测试免密登录是否成功
ssh hadoopslave1
ssh hadoopslave2