CentOS 7.2安装部署SaltStack
参考文档:
- Saltstack安装文档:https://repo.saltstack.com/#rhel
SaltStack的安装与简单配置,应用。
一.环境
Server:CentOS Linux release 7.2.1511 (Core)
Salt-master:172.18.12.201
Salt-minion:172.18.12.204
二.Saltstack安装与配置
1. yum安装
# Salt-master安装: [root@localhost ~]# yum install https://repo.saltstack.com/yum/RedHat/salt-repo-latest-1.el7.noarch.rpm [root@localhost ~]# yum clean expire-cache [root@localhost ~]# yum install salt-master # Salt-minion安装,最后一步安装组件有区别: [root@localhost ~]# yum install salt-minion
2. 防火墙配置(salt-master)
# CentOS7.2默认自带firewall,无iptable; # 移除系统自带firewall的开机启动,安装iptable,设置iptable开机启动 [root@localhost ~]# systemctl stop firewalld.service [root@localhost ~]# systemctl disable firewalld.service [root@localhost ~]# yum install iptables-services –y [root@localhost ~]# systemctl enable iptables.service [root@localhost ~]# systemctl restart iptables.service # tcp4506是salt-master发送命令信息的端口,tcp4506是salt-minion返回信息的端口; # Salt-minion可不做防火墙处理,默认iptable规则即可 [root@localhost ~]# vim /etc/sysconfig/iptables -A INPUT -p tcp -m state --state NEW -m tcp --dport 4505 -j ACCEPT -A INPUT -p tcp -m state --state NEW -m tcp --dport 4506 -j ACCEPT
3. salt-master配置
#interface参数绑定master的通信ip,默认可不变更,表示所有主机ip; [root@localhost ~]# sed -i 's/#interface: 0.0.0.0/interface: 172.18.12.201/g' /etc/salt/master # hash_type参数默认可不变更,salt-master也可启动,但启动后有告警如下: # [WARNING ] IMPORTANT: Do not use md5 hashing algorithm! Please set "hash_type" to sha256 in Salt Master config! [root@localhost ~]# sed -i 's/#hash_type: md5/hash_type: sha256/g' /etc/salt/master # auto_accept参数是自动认证开关,默认关闭,使用salt-key确认证书信任 [root@localhost ~]# sed -i 's/#auto_accept: False/auto_accept: True/g' /etc/salt/master
4. salt-minion配置
# master参数指定master 的ip (或者主机名),必配参数,如果minion启动时不能解析到master 主机,启动会失败; [root@localhost ~]# sed -i 's/#master: salt/master: 172.18.12.201/g' /etc/salt/minion # hash_type参数同master; [root@localhost ~]# sed -i 's/#hash_type: sha256/hash_type: sha256/g' /etc/salt/master # id参数设置salt-minion名,默认未设置,minio名取主机hostname中设定的主机名 [root@localhost ~]# sed -i 's/#id:/id: 172.18.12.204/g' /etc/salt/minion
5. 启动服务
启动salt-master
# 设置开机启动,启动后查看状态; # 启动中有问题可通过"systemctl status salt-master.service"与"salt-mater -l debug"等命令定位故障,下面salt-minion相同 [root@localhost ~]# systemctl enable salt-master.service [root@localhost ~]# systemctl start salt-master.service [root@localhost ~]# systemctl status salt-master.service
启动salt-minion
#设置开机启动,启动后查看状态 [root@localhost ~]# systemctl enable salt-minion.service [root@localhost ~]# systemctl start salt-minion.service [root@localhost ~]# systemctl status salt-mionion.service
6. 验证(salt-master)
查看minion表
[root@localhost ~]# salt-key -L
Salt-master已经设置"auto_accept"参数为"True",minion主机"172.18.12.204"已在"Acceptd Keys"中(主机名为salt-minion设置的id或hostname)。
手动认证key("auto_accept"参数为"False"时)
# -A指确认"Unacceptd Keys"中的全部minion(unacceptd中的minion列表为红色,确认到accepted列表中后变为绿色) [root@localhost ~]# salt-key -A # -a指"Unacceptd Keys"中特定的minion # 或[root@localhost ~]# salt-key -a 172.18.12.204
简单的命令测试
# "*"表示所有"Acceptd Keys"中的minion,也可以对特定的minion执行命令; # 返回值为"True"表示master与minion连接成功 [root@localhost ~]# salt "*" test.ping
#使用"cmd.run"可以执行具体的命令 [root@localhost ~]# salt "*" cmd.run "iptables -nL"
相关推荐
pigsmall 2020-11-19
graseed 2020-10-28
大数据杂谈 2020-09-26
SXIAOYI 2020-09-16
jinhao 2020-09-07
ChinaWin 2020-08-13
mohanzb 2020-08-01
王国平 2020-06-20
yoohsummer 2020-06-01
kangtingting0 2020-05-20
MichelinMessi 2020-02-19
impress 2020-02-20
nicepainkiller 2020-01-25
hfszy0 2013-05-15
lizhenmxcz 2013-05-12
gxyblue 2013-05-11
chenshuixian 2013-06-01
羽化大刀Chrome 2013-05-31
tichangde 2020-01-17