saltstack建立top-master主机

通过建立top-master主机管理salt-master端及其salt-minion节点,同时可以进行salt-master主机的横向扩展,从而通过一个或几个top-master管理多个salt-master及其salt-minion,实现大规模的集群管理
(本文所有主机ip均为172.25.17网段,主机名和ip相对应。比如172.25.17.3对应server3,并且所有salt包和python包需要自行下载并配置到yum源中)

环境

当前的实验环境是,server3作为salt-master,server4、server5、server6都作为server3的salt-minion端。目的是将sevrer6作为新的top-master端。
本文主机ip为172.25.17网段,主机名和ip相对应。比如172.25.17.3对应server3

实现

1.在server3端将server6从salt-minion列表中移除:

[root@server3 _modules]# salt-key -L    #查看salt-minion列表
Accepted Keys:
server3
server4
server5
server6
Denied Keys:
Unaccepted Keys:
Rejected Keys:
[root@server3 _modules]# salt-key -d server6   #移除server6
The following keys are going to be deleted:
Accepted Keys:
server6
Proceed? [N/y] y
Key for minion server6 deleteed.

2.在server6端停掉salt-minion服务和其他服务,并安装salt-master服务:

[root@server6 sysconfig]# /etc/init.d/salt-minion stop
Stopping salt-minion:root:server6 daemon: OK
[root@server6 sysconfig]# chkconfig salt-minion off
[root@server6 sysconfig]# /etc/init.d/haproxy stop
Stopping haproxy:                                          [  OK  ]
[root@server6 sysconfig]# /etc/init.d/keepalived stop
Stopping keepalived:                                       [  OK  ]
[root@server6 sysconfig]# yum install salt-master -y

编辑server6端的master配置文件:

[root@server6 sysconfig]# vim /etc/salt/master

开启order_master,设定为True表示开启:

 855 # Set the order_masters setting to True if this master will command lower
 856 # masters' syndic interfaces.
 857 order_masters: True

编辑完成之后开启master服务:

[root@server6 sysconfig]# /etc/init.d/salt-master start
Starting salt-master daemon:                               [  OK  ]

3.在server3端安装salt-syndic并编辑master配置文件:

[root@server3 _modules]# yum install salt-syncdic -y
[root@server3 _modules]# vim /etc/salt/master

设定top-master主机为server6:

 859 # If this master will be running a salt syndic daemon, syndic_master tells
 860 # this master where to receive commands from.
 861 syndic_master: 172.25.17.6

之后重启master服务,不要使用restart,先stop然后start。重启之后开启slat-syndic服务:

[root@server3 _modules]# /etc/init.d/salt-master stop
Stopping salt-master daemon:                               [  OK  ]
[root@server3 _modules]# /etc/init.d/salt-master start
Starting salt-master daemon:                               [  OK  ]
[root@server3 _modules]# /etc/init.d/salt-syndic start
Starting salt-syndic daemon:                               [  OK  ]

4.这样在server6端就可以看到server3在列表里:

扫描二维码关注公众号,回复: 2850198 查看本文章
[root@server6 sysconfig]# salt-key -L
Accepted Keys:
Denied Keys:
Unaccepted Keys:
server3
Rejected Keys:

添加server3:

The following keys are going to be accepted:
Unaccepted Keys:
server3
Proceed? [n/Y] y
Key for minion server3 accepted.

之后,就可以ping到server3及其所有minion了,server6就成为了一个top-master:

[root@server6 sysconfig]# salt '*' test.ping
server4:
    True
server5:
    True
server3:
    True

猜你喜欢

转载自blog.csdn.net/letter_A/article/details/81810153
今日推荐