背景:
公司有多个部门,有一些机器有本部门的业务,这些机器也有其他部门的业务,所以本部门需要一个master服务器来管理这批机器,其他部门也需要一个master服务器来管理这个机器,所以就需要多个master来进行管理。
实现:
实现方式就是所有的master服务器使用相同的private key,即我们只需要将其中一台已经配置好的master上的private key进行复制,然后拷贝到另一台master服务器上即可,然后在minion端配置好minion id即可,配置完成后需要重启下服务。
示例:
准备了三台机器
机器列表 | 状态 |
192.168.235.133 | master1 |
192.168.235.134 | minion |
192.168.235.135 | master2 |
1)将master2上的private key进行拷贝至master1上
[root@localhost master]# ll
总用量
-r--------. root root 1月 : master.pem #private key
-rw-r--r--. root root 1月 : master.pub
drwxr-xr-x. root root 1月 : minions
drwxr-xr-x. root root 1月 : minions_autosign
drwxr-xr-x. root root 1月 : minions_denied
drwxr-xr-x. root root 1月 : minions_pre
drwxr-xr-x. root root 1月 : minions_rejected private key 所在目录:/etc/salt/pki/master
2)修改minion端的配置文件
书写格式一定要写对
3)然后在master1上进行密钥认证
[root@localhost master]# salt-key -L
Accepted Keys:
Denied Keys:
Unaccepted Keys:
m1
Rejected Keys:
[root@localhost master]# salt-key -A
The following keys are going to be accepted:
Unaccepted Keys:
m1
Proceed? [n/Y] Y
Key for minion m1 accepted.
4)重启服务,测试即可
需要注意的是:另一个master不能有其他节点服务器连接
以上操作便实现了多个master共同管理minion节点的需求了