SaltStack进阶之salt-master高可用



1. salt-master高可用

我们需要用salt来管理公司的所有机器,那么salt的master就不能宕机,否则就会整个瘫痪,所以我们必须要对salt进行高可用。salt的高可用配置非常简单,只需要改一下minion配置文件,将master用列表的形式列出即可。

[root@minion ~]# vim /etc/salt/minion

master:
  - 192.168.30.150
  - 192.168.30.244



2. salt-master高可用之数据同步

涉及到高可用时,数据的同步是个永恒的话题,我们必须保证高可用的2个master间使用的数据是一致的,包括:

  • /etc/salt/master配置文件
  • /etc/salt/pki目录下的所有key
  • /srv/下的salt和pillar目录下的所有文件

保障这些数据同步的方案有

  • nfs挂载
  • rsync同步
  • 使用gitlab进行版本控制

安全相关
为保证数据的同步与防止丢失,可将状态文件通过gitlab进行版本控制管理。


3. salt-master高可用配置

主机IP
master001(主master)192.168.30.150/24
master002(备master)192.168.30.244/24
minion192.168.30.245/24

3.1 修改minion端的配置文件

[root@minion ~]# vim /etc/salt/minion

master:
  - 192.168.30.150
  - 192.168.30.244

[root@minion ~]# systemctl start salt-minion

3.2 启动主master,接收key


[root@master01 ~]# systemctl start salt-master

[root@master01 ~]# ss -anlt
State      Recv-Q Send-Q  Local Address:Port                 Peer Address:Port              
LISTEN     0      128                 *:22                              *:*                  
LISTEN     0      128                 *:4505                            *:*                  
LISTEN     0      100         127.0.0.1:25                              *:*                  
LISTEN     0      128                 *:4506                            *:*                  
LISTEN     0      128                :::22                             :::*                  
LISTEN     0      100               ::1:25                             :::*             

[root@master01 ~]# salt-key -L
Accepted Keys:
Denied Keys:
Unaccepted Keys:
minion          //key已经传过来了


[root@master01 ~]# salt-key -Ay
The following keys are going to be accepted:
Unaccepted Keys:
minion
Key for minion minion accepted.



[root@master01 ~]# salt-key -L
Accepted Keys:
minion         //key接收
Denied Keys:
Unaccepted Keys:
Rejected Keys:


3.3 使主备master配置同步

[root@master01 ~]# scp -r /etc/salt/ 192.168.30.244:/etc/
root@192.168.30.244's password: 
cloud                                                       100% 2927     3.1MB/s   00:00    
master                                                      100%   50KB  14.8MB/s   00:00    
minion                                                      100%   36KB   8.2MB/s   00:00    
minion                                                      100%  451   389.2KB/s   00:00    
master.pem                                                  100% 1675     1.3MB/s   00:00    
master.pub                                                  100%  451   424.7KB/s   00:00    
proxy                                                       100%   28KB  15.7MB/s   00:00    
roster                                                      100%  344   448.4KB/s   00:00    

3.4 启动备master

[root@master02 ~]# systemctl start salt-master
[root@master02 ~]# ss -anlt
State      Recv-Q Send-Q  Local Address:Port                 Peer Address:Port              
LISTEN     0      128                 *:22                              *:*                  
LISTEN     0      128                 *:4505                            *:*                  
LISTEN     0      100         127.0.0.1:25                              *:*                  
LISTEN     0      128                 *:4506                            *:*                  
LISTEN     0      128                :::22                             :::*            
LISTEN     0      100               ::1:25                             :::*             


[root@master02 ~]# salt-key -L
Accepted Keys:
minion         //key已接收
Denied Keys:
Unaccepted Keys:
minion
Rejected Keys:

3.5 测试备master

[root@master02 ~]# salt '*' test.ping
minion:
    True
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值