11、salt Master高可用

所有机器的minion修改

vim /etc/salt/minion

master:
  - 192.168.1.61
  - 192.168.1.62

 

配置数据同步到备机,我用的rsync

原master操作

yum install -y rsync

vim /etc/rsyncd.conf

uid = root
gid = root
use chroot = no
max connections = 200
timeout = 600
pid file = /var/run/rsyncd.pid
lock file = /var/run/rsync.lock
log file = /var/log/rsyncd.log

[salt-srv]
path = /srv/salt
ignore errors
read only = false
list = false
auth users = salt
hosts allow = 192.168.1.62
secrets file = /etc/rsync/rsync.password

[salt-pki]
path = /etc/salt/pki/master
ignore errors
read only = false
list = false
auth users = salt
hosts allow = 192.168.1.62
secrets file = /etc/rsync/rsync.password

[salt-conf]
path = /etc/salt/master.d
ignore errors
read only = false
list = false
auth users = salt
hosts allow = 192.168.1.62
secrets file = /etc/rsync/rsync.password


[salt-conf-master]
path = /etc/salt
ignore errors
read only = false
list = false
auth users = salt
hosts allow = 192.168.1.62
secrets file = /etc/rsync/rsync.password

 

mkdir /etc/rsync

vim /etc/rsync/rsync.password

salt:salt2021

chmod 600 /etc/rsync/rsync.password

启动rsync服务

rsync --daemon --config=/etc/rsyncd.conf  

 

备机操作

yum install -y rsync

mkdir /etc/rsync

vim /etc/rsync/rsync.password

salt:salt2021

chmod 600 /etc/rsync/rsync.password

 

vim /data/script/rsync_salt.sh

#!/bin/bash
rsync -auvz --progress --password-file=/etc/rsync/rsync.password salt@192.168.1.61::salt-srv /srv/salt
rsync -auvz --progress --password-file=/etc/rsync/rsync.password salt@192.168.1.61::salt-pki /etc/salt/pki/master
rsync -auvz --progress --password-file=/etc/rsync/rsync.password salt@192.168.1.61::salt-conf /etc/salt/master.d/
rsync -auvz --progress --password-file=/etc/rsync/rsync.password salt@192.168.1.61::salt-conf-master/master /etc/salt/

加入crontab,3分钟同步一下文件,注意如果配置文件更新,需要同步后重启一下备机的salt-master

cat  /etc/crontab 

*/3 * * * * bash /data/script/rsync_salt.sh

 

然后所有机器重启salt-minion

systemctl restart salt-minion

两台master重启,如果配置了job cache,需要mysql更新一下权限,参考之前的博客

systemctl restart salt-master

然后两台master就可以测试salt命令了

 

posted @ 2021-02-25 16:17  莫莫学习  阅读(154)  评论(0编辑  收藏  举报