配置ssh集群服务

1、配置ssh 无密码登录
ssh-keygen -t rsa
根据提示按三次enter键

[root@centos67 opt]# 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:
22:ec:f0:b6:2b:dc:54:d6:4f:ae:a0:a8:e6:3d:55:84 root@centos67
The key's randomart image is:
+--[ RSA 2048]----+
|      .          |
|     E .         |
|      ..         |
|   .  o.. .      |
|  . ooo S+       |
|   +.o..  o      |
| . +=. . .       |
| .=oo.  .        |
|+o o+.           |
+-----------------+

2、修改ip与hostname映射,修改/etc/hosts(删除所有,只添加下面一行)

192.168.128.130 master
192.168.128.131 slave1
192.168.128.132 slave2
192.168.128.133 slave3

3、输入命令
ssh-copy-id -i /root/.ssh/id_rsa.pub centos67
根据提示输入yes,123456(root用户的密码)

[root@centos67 opt]# ssh-copy-id -i /root/.ssh/id_rsa.pub centos67
The authenticity of host 'centos67 (192.168.0.128)' can't be established.
RSA key fingerprint is 09:7a:e4:ad:28:ce:ac:b6:0f:ea:99:82:fa:62:25:96.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'centos67,192.168.0.128' (RSA) to the list of known hosts.
root@centos67's password: 
Now try logging into the machine, with "ssh 'centos67'", and check in:

  .ssh/authorized_keys

to make sure we haven't added extra keys that you weren't expecting

4、检查各个子节点是否能成功直接登录

[root@centos67 opt]# ssh centos67
Last login: Tue Nov  3 18:39:41 2015 from 192.168.0.1
[root@master ~]# ssh slave1
[root@slave1 ~]# exit
[root@master ~]# ssh-keygen -t rsa
[root@master ~]# ssh-copy-id -i /root/.ssh/id_rsa.pub master
[root@master ~]# ssh master
[root@master ~]# ssh-copy-id -i /root/.ssh/id_rsa.pub slave1
[root@master ~]# ssh slave1
[root@slave1 ~]# exit
[root@master ~]# ssh-copy-id -i /root/.ssh/id_rsa.pub slave2
[root@master ~]# ssh slave2
[root@slave2 ~]# exit
[root@master ~]# ssh-copy-id -i /root/.ssh/id_rsa.pub slave3
[root@master ~]# ssh slave3
[root@slave3 ~]# exit

注:当报错-bash: ssh-copy-id: command not found
是因为还没安装openssh-clients。
输入yum install openssh-clients 命令进行安装,如果安装的时候报错No more mirrors to try是因为没有挂载,清理yum缓存并挂载

[root@master ~]# ls /media/
[root@master ~]# mount /dev/dvd /media/

然后再安装openssh-clients即可。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值