SaltStack高可用multi-master-第十三篇

multi-master官方介绍

As of Salt 0.16.0, the ability to connect minions to multiple masters has been made available. The multi-master system allows for redundancy of Salt masters and facilitates multiple points of communication out to minions. When using a multi-master setup, all masters are running hot, and any active master can be used to send commands out to the minions.

实验环境

node1  192.168.56.11   角色  salt-master salt-minon (环境前面的文章中已配置好)
node2  192.168.56.12   角色  salt-master salt-minon

说明因测试机器数量有限 ,2台服务器做Master也做Minion,当2个Master启动时候都要处于可用状态

步骤

一,在2个节点上面分别安装Master和Minion
[root@linux-node2 ~]# yum install salt-master salt-minion -y
二,在Minion配置文件中添加多master节点
[root@linux-node2 ~]# more /etc/salt/minion
...
# resolved, then the minion will fail to start.
master: 
  - 192.168.56.11
  - 192.168.56.12
...
三,同步Master配置文件和状态文件
[root@linux-node1 srv]# scp /etc/salt/master 192.168.56.12:/etc/salt/
[root@linux-node1 srv]# scp -r /srv/salt/ 192.168.56.12:/srv/
四,同步Master秘钥对
[root@linux-node2 pki]# mkdir master -p && chmod 700 master/ #在node2节点上创建master文件并修改权限
[root@linux
-node1 master]# scp /etc/salt/pki/master/master.pem master.pub 192.168.56.12:/etc/salt/pki/master/ #在node1上面scp
五,重启Master和Minion服务节点,生效Master和Minion配置文件
[root@linux-node2 pki]# systemctl restart salt-minion

六,在node2的master节点重新接受一下Minion认证
[root@linux-node2 master]# salt-key  #查看发送申请的minon id
Accepted Keys:
Denied Keys:
Unaccepted Keys:
linux-node1.example.com
linux-node2.example.com
Rejected Keys:

[root@linux-node2 master]# salt-key -A  #接受申请,下面输入Y
The following keys are going to be accepted:
Unaccepted Keys:
linux-node1.example.com
linux-node2.example.com
Proceed? [n/Y] Y
Key for minion linux-node1.example.com accepted.
Key for minion linux-node2.example.com accepted.
七,在2个Master节点执行命令都可以正常工作
[root@linux-node1 master]# salt '*' test.ping  #node1 Master节点
linux-node1.example.com:
    True
linux-node2.example.com:
    True

[root@linux-node2 master]# salt '*' test.ping #node2 Master节点
linux-node2.example.com:
    True
linux-node1.example.com:
    True

总结

1.Master配置文件要一样

2.Master file_root路径及状态文件要一样

3.Master 公钥和私钥要一样

4.修改Minion配置中指定Master为列表形式

5.Master接受的minion_id key要保持同步,增删保持一致

6.生产环境可以用nginx做多个master的api负载均衡

7.Master上的key要考虑安全性问题

8.生产环境的状态文件管理可以用git管理

9.还可以通过 failover配置多个multiple masters,相对复杂一些


 附英文参考文档

https://www.unixhot.com/docs/saltstack/topics/tutorials/multimaster.html

 

posted @ 2017-10-23 16:09  warren1236  阅读(1328)  评论(0编辑  收藏  举报