Saltstack 实战-安装篇
Saltstack 简介
Saltstack 是一种管理工具,允许管理员对多个操作系统创建一个一致的管理系统。
三大功能:
- 配置管理
- 远程执行
- 云管理
三种部署架构:
- master->minion # master 发送指令,minion 执行指令.
- master->syndic->minion # master 通过syndic 进行管理,也可以混合管理
- 没有 master 的minion # 通过本地执行完成操作
安装部署
1. 环境准备:
服务器均关闭防火墙和selinux
三台测试服务器
- hostname:master.wpic.com
- hostname: client1.wpic.com
- hostname: client2.wpic.com
三台服务器通过 /etc/hosts 文件做好域名解析
192.168.79.134 master master.wpic.com 192.168.79.133 client1 client1.wpic.com 192.168.79.132 client2 client2.wpic.com
master 端
yum install -y epel-release yum install -y salt-master
minion 端
yum install -y epel-release yum install -y salt-minion
2. 配置 salt-master (默认参数即可,可直接启动)
systemctl enable salt-master && systemctl start salt-master
配置文件 /etc/salt/master
默认监听端口
- 4505 # 提供远程执行命令发送功能。
- 4506 # 此为接收端口,支持认证,文件服务,结果收集等功能。
3. 配置 salt-minion
配置文件 /etc/salt/minion
client1.wpic.com
master: master.wpic.com # master 的主机名或者 ip 地址 id: client1.wpic.com # minion 的主机名,经测试默认也是主机名
client2.wpic.com
master: master.wpic.com # master 的主机名或者 ip 地址 id: client2.wpic.com # minion 的主机名,经测试默认也是主机名
启动并设置开机启动 salt-minion
systemctl enable salt-minion && systemctl start salt-minion
4. master 上接受 minion 密钥(类似于ssh-key)
salt-key 命令可以帮助我们管理 minion 密钥,配置完成后 master 和 minion 间的通信是加密的
[root@master ~]# salt-key -L # 查看已经接受和未接受的密钥 Accepted Keys: Denied Keys: Unaccepted Keys: client1.wpic.com clients.wpic.com Rejected Keys: [root@master ~]# salt-key -f client1.wpic.com # 查看密钥指纹 Unaccepted Keys: client1.wpic.com: b8:51:44:6f:5e:82:fc:db:d4:a9:96:18:4f:a5:82:7e [root@master ~]# salt-key -a "*" # 接受所有密钥请求 The following keys are going to be accepted: Unaccepted Keys: client1.wpic.com clients.wpic.com Proceed? [n/Y] y Key for minion client1.wpic.com accepted. Key for minion clients.wpic.com accepted. [root@master ~]# salt-key -L # 查看密钥状态 Accepted Keys: client1.wpic.com clients.wpic.com Denied Keys: Unaccepted Keys: Rejected Keys:
5. 测试
[root@master ~]# salt "*" test.ping # test 为 salt 模块,ping 是模块的方法后者函数
client1.wpic.com:
True
clients.wpic.com:
True
Saltstack 基础安装完毕,下一章我们将要探讨远程执行篇。

浙公网安备 33010602011771号