节点分发
#从任意Master节点分发配置到其他所有的节点(包括其他的Master与Node) #本例中从master-1分发 [root@master-1 ~]# yum install -y expect [root@master-1 ~]# ssh-keygen -t rsa -P "" -f /root/.ssh/id_rsa #密码更换 [root@master-1 ~]# export mypass=123456 [root@master-1 ~]# name=(master-1 master-2 master-3 node-1 node-2) [root@master-1 ~]# for i in ${name[@]};do expect -c " spawn ssh-copy-id -i /root/.ssh/id_rsa.pub root@$i expect { \"*yes/no*\" {send \"yes\r\"; exp_continue} \"*password*\" {send \"$mypass\r\"; exp_continue} \"*Password*\" {send \"$mypass\r\";} }" done #连接测试
时来天地皆同力,运去英雄不自由