hadoop全分布式集群:配置主从节点之间的免密登录

要想实现主节点 对 从节点的管理:
需要配置主节点对从节点的免密登录。
**主节点hostname:vdevops
从节点hostname:test2
hadoop版本:2.8.2
主从节点可以相互通信**

1.主节点中产生RSA密钥
1.1

首先检查目录/home/hadoop/.ssh下是否有id_rsa、 id_rsa.pub两个文件,如有,删除之

1. 2

在主节点中执行,产生密钥

[hadoop@vdevops ~]$ ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/home/hadoop/.ssh/id_rsa): 
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in /home/hadoop/.ssh/id_rsa.
Your public key has been saved in /home/hadoop/.ssh/id_rsa.pub.
The key fingerprint is:
b9:18:3b:50:cd:d9:48:eb:be:84:c0:49:fb:8e:1e:0a hadoop@vdevops
The key's randomart image is:
+--[ RSA 2048]----+
|        .        |
|       + =       |
|    . . * .      |
|   o + . .       |
|    * . S        |
|     + * .       |
|E   . * +        |
| . . + o .       |
|  ..o . .        |
+-----------------+
1.3 生成密钥之后,公钥的形式:
[hadoop@vdevops .ssh]$ cat id_rsa.pub
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCpmiWNRvoBJ5w3f9V58nnHfitKOYxMMvCyOLP0siXtCAUHcOdfJkQQ00Qe9USRAFseosuzL7vDwYBk4jdwrbb1o/OIwbZB7qh8JuNfFHkmKqdwHToze85cRSnXDz7R/YJ7K+/v0AdNVM9XIB6xKXPXiEFp8Cp1S1p00Ld4nJpvxYcjFNl1JLi/l/DVlPyNv4KS3RD4SqFNbVzFgXdEoi3nL5i48Jgjb0XNXSsrGz03trLRRkqGPPqdFQW4bXww1f+pZpRmzU0c1Ng+Azf1SMNq4D3YOIKEePodw28n9ajOpy4NyOz0yvKIXQx8vArKw8ho5QKSEN5EDWCJfC09pAjP hadoop@vdevops
[hadoop@vdevops .ssh]$ pwd
/home/hadoop/.ssh
2. 将主节点中产生RSA密钥分布到从节点中
[hadoop@vdevops .ssh]$ scp id_rsa.pub hadoop@test2:~/vdevops_key
The authenticity of host 'test2 (192.168.1.127)' can't be established.
ECDSA key fingerprint is a7:8a:dc:21:a9:73:ba:92:74:08:02:14:c4:ba:01:0d.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'test2,192.168.1.127' (ECDSA) to the list of known hosts.
hadoop@test2's password: 
id_rsa.pub   

解释:scp id_rsa.pub hadoop@test2:~/vdevops_key: 将 id_rsa.pub传到test2上,并且重新命名为vdevops_key,即文件vdevops_key内容与id_rsa.pub 相同

3. 在从节点中设置主节点的密钥为授权密钥
[hadoop@test2 ~]$ mv ~/vdevops_key ~/.ssh/authorized_keys #移动vdevops_key并重命名为authorized_keys 

[hadoop@test2 ~]$ chmod 600 ~/.ssh/authorized_keys #设置权限
4.尝试主节点登录到从节点

可以直接登录从节点 而不需要密码,显示如下:

[hadoop@vdevops ~]$ ssh test2
Last login: Wed Dec 20 14:07:09 2017 from 192.168.1.247

[1]:《Hadoop实战 r2》
[2]:Hadoop(三)手把手教你搭建Hadoop全分布式集群 https://www.cnblogs.com/zhangyinhua/p/7652686.html#_label2

评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值