1、版本
最新版,当前是3007.1
2、服务角色
No. | hostname | role1 | role2 | remark |
1 | hadoop01 | minion | master | |
2 | hadoop02 | minion | master | |
3 | hadoop03 | minion |
3、yum 库
[root@hadoop01 ~]# more /etc/yum.repos.d/salt.repo
[salt-repo]
name=Salt repo for RHEL/CentOS 7 PY3
baseurl=https://repo.saltproject.io/salt/py3/redhat/7/x86_64/latest
skip_if_unavailable=True
failovermethod=priority
priority=10
enabled=1
enabled_metadata=1
gpgcheck=1
gpgkey=https://repo.saltproject.io/salt/py3/redhat/7/x86_64/latest/SALT-PROJECT-GPG-PUBKEY-2023.pub
4、Master安装
[root@hadoop01 ~]# yum install -y salt-master
[root@hadoop01 ~]# cat /etc/salt/master
default_include: master.d/*.yaml
file_roots:
base:
- /srv/salt
auto_accept: True
open_mode: True
file_recv: True
file_recv_max_size: 102400
log_file: /var/log/salt/master
log_level: warning
log_level_logfile: warning
publish_port: 6715
worker_threads: 20
ret_port: 6716
pidfile: /var/run/salt-master.pid
timeout: 60
sock_dir: /var/run/salt/master
keep_jobs: 1
minion_data_cache: True
pillar_roots:
base:
- /srv/pillar
5、Minion安装
[root@hadoop03 ~]# yum install -y salt-minion
[root@hadoop03 ~]# cat /etc/salt/minion
master:
- hadoop01.jedy.com.cn
- hadoop02.jedy.com.cn
id: hadoop03.jedy.com.cn
master_port: 6716
6、服务启动
Master
systemctl start salt-master
minion
systemctl start salt-minion
7、验证(master端执行)
检查minion是否存在
[root@hadoop01 ~]# salt-key -L
Accepted Keys:
hadoop03.jedy.com.cn
Denied Keys:
Unaccepted Keys:
Rejected Keys:
查看minion的主机名
[root@hadoop01 ~]# salt \* cmd.run 'hostname'
hadoop03.jedy.com.cn:
hadoop03.jedy.com.cn
8、主从配置
8.1、Master2安装
从master1 cp 配置,这里主要是把master1上的私钥和公钥/etc/salt/pki/master/master.pem 和/etc/salt/pki/master/master.pem,同步到master2 上
[root@hadoop02 ~]# yum install -y salt-master
[root@hadoop02 ~]# cd /etc/salt/ ; rm -rf *
[root@hadoop02 salt]# rsync -auv hadoop01.jedy.com.cn:/etc/salt/* /etc/salt/
[root@hadoop02 salt]# sed -i 's/id: .*/id: `hostname`' minion
[root@hadoop02 salt]# systemctl enable --now salt-master
8.2、配置同步
master上创建同步脚本
[root@hadoop01 ~]# cat /script/rsync_salt.sh
#!/bin/bash
. /etc/profile
dst_host=hadoop02.jedy.com.cn
rsync -auv /srv/salt /srv/pillar $dst_host:/srv/
rsync -auv /etc/salt/master* $dst_host:/etc/salt/
赋权和运行
[root@hadoop01 ~]# chmod 700 /script/rsync_salt.sh
[root@hadoop01 ~]# sh /script/rsync_salt.sh
定时同步
[root@hadoop01 ~]# crontab -l
*/5 * * * * /script/rsync_salt.sh >/dev/null 2>&
更新minion端配置
[root@hadoop01 ~]# salt \* cmd.run 'sed -i "/id/i\ \ - hadoop02.jedy.com.cn" /etc/salt/minion'
[root@hadoop01 ~]# salt \* cmd.run 'systemctl restart salt-minion'
8.3、验证
slave端检查
[root@hadoop02 ~]# salt \* cmd.run hostname
9、遇到的问题
9.1、minion不能启动
报错:
没有明显日志
解决方案:
删除/etc/salt下所有文件,重装minion
python 问题,yum update修复
9.2、minion不能注册
报错:
/var/log/salt/minion中报
[salt.utils.parsers:1062][WARNING ][17001] Minion received a SIGTERM. Exiting.
解决方案:
关闭主机防火墙
systemctl stop firewalld
systemctl disable firewalld