准备环境
- 操作系统:CentOS 7.4 64位
- 参考资料:SaltStack帮助文档
虚拟机初始化配置
- 参考资料:MySQL5.7单机版安装 - 准备环境
注意:修改主机名为“salt-minion”
开始安装
配置SaltStack yum源:
[root@localhost ~]# vim /etc/yum.repos.d/saltstack.repo
文件内容:
[saltstack-repo]
name=SaltStack repo for RHEL/CentOS $releasever
baseurl=https://repo.saltstack.com/yum/redhat/$releasever/$basearch/latest
enabled=1
gpgcheck=1
gpgkey=https://repo.saltstack.com/yum/redhat/$releasever/$basearch/latest/SALTSTACK-GPG-KEY.pub
加载yum源:
[root@localhost ~]# yum makecache
安装salt-minion:
[root@localhost ~]# yum install -y salt-minion
配置minion开机自动启动:
[root@localhost ~]# systemctl enable salt-minion
启动Minion:
[root@localhost ~]# systemctl start salt-minion
配置salt-minion
配置文件:/etc/salt/minion
master: salt-master
注意:salt-master
为master的主机名,需要配置本机/etc/hosts
重启salt-minion:
[root@localhost ~]# systemctl restart salt-minion
检查配置
在Salt Master上,授权该Salt Minion访问:
[root@salt-master ~]# salt-key
找到对应的主机名或IP
[root@salt-master ~]# salt-key -a -y 主机名或IP
[root@salt-master ~]# salt '主机名或IP' test.ping
如果返回值为True,则配置完成。