master:centos7 ip:192.168.90.12 hostname:master.salt.com minion:windows2008 ip:192.168.90.14 IDname:win2008-192.168.90.14 minion:centos7 ip:192.168.90.11 IDname: centos7-192.168.90.11
centos7 都需要安装saltstack 源:
yum install -y https://repo.saltstack.com/yum/redhat/salt-repo-latest.el7.noarch.rpm sudo yum clean expire-cache #master命令: sudo yum install -y salt-master salt-minion salt-ssh salt-syndic salt-cloud salt-api systemctl start salt-minion systemctl start salt-master #minion命令: centos: sudo yum install -y salt-minion systemctl restart salt-minionwindows安装包: 不支持windows 2003 https://docs.saltstack.com/en/latest/topics/installation/windows.html#building-and-developing-on-windows 下载:Python2 x86: Salt-Minion-2019.2.0-x86-Setup.exe ,注意python版本使用和master端一样,避免出错。 下载完打开安装。 master ip or hostname //可以直接填IP,或者填写域名 minion name //填写这台服务器要在master端显示的名字,建议格式为:系统-ip ,比较好区分
2,修改配置文件,然后在master端授权: centos7:
master端: vim /etc/salt/minion master: 192.168.90.12 //在第16行添加,冒号后有一个空格 id: master //112行添加。id是显示在master端查看 minion端: master: 192.168.90.12 //在第16行 id: centos7-192.168.90.11 //112行添加。id是显示在master端查看window:(安装时候已经输入,可忽略。默认文件在C:\salt\conf\minion)
master: 192.168.90.12 id: win2008-192.168.90.14修改完之后,重启服务。 测试环境下,windows的salt 服务使用administrator账户登陆,比较省事。生产环境使用独立用户登陆,并授予这个用户一些操作目录的权限,避免出现权限漏洞。 windows 命令:(windows更改区域语言设置,高级,非Unicode更改为英语(美国),否则无法启动,编码问题!)
sc start salt-minion net start salt-minionmaster端授权:salt-key -A //授权所有申请的minion -a 授权单独一台 -L 查看所有, -d 删除一台授权 -D 删除所有授权 如果Windows申请key授权,没有在master端出现,在c:\salt\bin 文件夹运行 python c:\salt\bin\scripts\salt-minion -l debug 可以查看报错。
然后测试通讯: salt ‘*’ test.ping 表示正常通讯。安装完成。
配置文件修改: master配置文件 /etc/salt/master : salt推送文件的默认路径是:/srv/salt master配置文件650行可修改。
minion配置文件 /etc/salt/minion: master: 192.168.90.11 //在第16行 id: centos7-192.168.90.11 //112行添加。id是显示在master端查看
master配置文件其他一些可修改的内容: auto_accept: False //322行 是否允许客户端自动认证 file_roots: //658行 修改默认配置文件的路径,默认为:/srv/salt nodegroups: //1192 行 设置组分类,可以把主机名分组。
参考: https://blog.csdn.net/sinat_35930259/article/details/81157252?utm_source=blogxgwz0 https://docs.saltstack.com/en/latest/topics/installation/index.html https://blog.51cto.com/13558754/2063243 https://www.centos.bz/tag/saltstack/
