一、服务环境
--------------------------------------------------------------
序号 | 设备型号 | 设备IP | 设备用途 |
1 | 虚拟机 | 192.168.122.100 | salt master |
2 | 虚拟机 | 192.168.122.101 | salt minion |
3 | 虚拟机 | 192.168.122.102 | salt minion |
4 | 虚拟机 | 192.168.122.103 | salt minion |
5 | 虚拟机 | 192.168.122.104 | salt minion |
6 | 虚拟机 | 192.168.122.105 | salt minion |
二、相关saltstack rpm安装包
相关RPM安装包和脚本见(http://down.51cto.com/data/2226975),脚本在redhat6.3上可用,其他版本系统上需要自行修改。
----------------------------------------------------------------
libyaml-0.1.3-1.4.el6.x86_64.rpmopenpgm-5.1.118-3.el6.x86_64.rpmpython-babel-0.9.4-5.1.el6.noarch.rpmpython-backports-1.0-3.el6.x86_64.rpmpython-backports-ssl_match_hostname-3.4.0.2-1.el6.noarch.rpmpython-chardet-2.0.1-1.el6.noarch.rpmpython-jinja2-2.2.1-2.el6_5.x86_64.rpmpython-msgpack-0.1.13-3.el6.x86_64.rpmpython-ordereddict-1.1-2.el6.noarch.rpmpython-requests-1.1.0-4.el6.noarch.rpmpython-six-1.7.3-1.el6.noarch.rpmpython-urllib3-1.5-7.el6.noarch.rpmpython-zmq-14.3.1-1.el6.x86_64.rpmPyYAML-3.10-3.1.el6.x86_64.rpmsalt-2014.7.0-3.el6.noarch.rpmsalt-master-2014.7.0-3.el6.noarch.rpmsalt-minion-2014.7.0-3.el6.noarch.rpmsshpass-1.05-1.el6.x86_64.rpmzeromq3-3.2.4-1.el6.x86_64.rpm
三、首先在salt-master服务端上利用写好的脚本安装服务端和客户端(服务端上也需要安装客户端的)
[root@datanode04 salt]# ./install_saltstack.sh ***if you want to use this machine as a salt-server,choose 1***if you want to use this machine as a salt-client,choose 2
四、配置saltsatck
4.1 master配置
[root@nagios-monitor salt]# vim /etc/salt/master [root@nagios-monitor salt]# cat /etc/salt/master |grep "^interface" interface: 192.168.122.100 [root@nagios-monitor salt]#
4.2 minion配置
[root@nagios-monitor salt]# vim /etc/salt/minion[root@nagios-monitor salt]# cat /etc/salt/minion|grep "^master"master: 192.168.122.100[root@nagios-monitor salt]#
五、启动saltstack
5.1 启动master并加入开机自启动
[root@nagios-monitor salt]# chkconfig --list|grep saltsalt-master 0:关闭 1:关闭 2:启用 3:启用 4:启用 5:启用 6:关闭salt-minion 0:关闭 1:关闭 2:启用 3:启用 4:启用 5:启用 6:关闭[root@nagios-monitor salt]# service salt-master startStarting salt-master daemon: [确定][root@nagios-monitor salt]# service salt-minion startStarting salt-minion daemon: [确定][root@nagios-monitor salt]#
六、测试saltstack
接下来的命令都在master上执行
6.1 查看minion列表
[root@nagios-monitor salt]# salt-key -LAccepted Keys:Unaccepted Keys:nagios-monitorRejected Keys:
6.2 接收所有key
[root@nagios-monitor salt]# salt-key -AThe following keys are going to be accepted:Unaccepted Keys:nagios-monitorProceed? [n/Y] YKey for minion nagios-monitor accepted.
6.3 简单测试
[root@nagios-monitor salt]# salt "*" test.pingnagios-monitor: True
七、在其他客户端上安装客户端相关rpm软件包
7.1 安装相关软件包
[root@datanode04 salt]# ./install_saltstack.sh ***if you want to use this machine as a salt-server,choose 1***if you want to use this machine as a salt-client,choose 2you want to use this machine as [ salt-server(=1)|salt-client(=2) ]:2warning: libyaml-0.1.3-1.4.el6.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID ec551f03: NOKEYPreparing... ########################################### [100%] 1:libyaml ########################################### [100%]warning: PyYAML-3.10-3.1.el6.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID ec551f03: NOKEYPreparing... ########################################### [100%] 1:PyYAML ########################################### [100%]warning: python-babel-0.9.4-5.1.el6.noarch.rpm: Header V3 RSA/SHA256 Signature, key ID ec551f03: NOKEYPreparing... ########################################### [100%] 1:python-babel ########################################### [100%]warning: python-jinja2-2.2.1-2.el6_5.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID ec551f03: NOKEYPreparing... ########################################### [100%] 1:python-jinja2 ########################################### [100%]warning: python-msgpack-0.1.13-3.el6.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID 0608b895: NOKEYPreparing... ########################################### [100%] 1:python-msgpack ########################################### [100%]warning: python-chardet-2.0.1-1.el6.noarch.rpm: Header V3 RSA/SHA256 Signature, key ID 0608b895: NOKEYPreparing... ########################################### [100%] 1:python-chardet ########################################### [100%]warning: python-ordereddict-1.1-2.el6.noarch.rpm: Header V3 RSA/SHA256 Signature, key ID 0608b895: NOKEYPreparing... ########################################### [100%] 1:python-ordereddict ########################################### [100%]warning: python-backports-1.0-3.el6.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID 0608b895: NOKEYPreparing... ########################################### [100%] 1:python-backports ########################################### [100%]warning: python-backports-ssl_match_hostname-3.4.0.2-1.el6.noarch.rpm: Header V4 RSA/SHA1 Signature, key ID 17ed316d: NOKEYPreparing... ########################################### [100%] 1:python-backports-ssl_ma########################################### [100%]warning: python-six-1.7.3-1.el6.noarch.rpm: Header V3 RSA/SHA256 Signature, key ID 0608b895: NOKEYPreparing... ########################################### [100%] 1:python-six ########################################### [100%]warning: python-urllib3-1.5-7.el6.noarch.rpm: Header V3 RSA/SHA256 Signature, key ID 0608b895: NOKEYPreparing... ########################################### [100%] 1:python-urllib3 ########################################### [100%]warning: python-requests-1.1.0-4.el6.noarch.rpm: Header V3 RSA/SHA256 Signature, key ID 0608b895: NOKEYPreparing... ########################################### [100%] 1:python-requests ########################################### [100%]warning: openpgm-5.1.118-3.el6.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID 0608b895: NOKEYPreparing... ########################################### [100%] 1:openpgm ########################################### [100%]warning: zeromq3-3.2.4-1.el6.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID 0608b895: NOKEYPreparing... ########################################### [100%] 1:zeromq3 ########################################### [100%]warning: python-zmq-14.3.1-1.el6.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID 0608b895: NOKEYPreparing... ########################################### [100%] 1:python-zmq ########################################### [100%]warning: sshpass-1.05-1.el6.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID 0608b895: NOKEYPreparing... ########################################### [100%] 1:sshpass ########################################### [100%]warning: salt-2014.7.0-3.el6.noarch.rpm: Header V3 RSA/SHA256 Signature, key ID 0608b895: NOKEYPreparing... ########################################### [100%] 1:salt ########################################### [100%]warning: salt-minion-2014.7.0-3.el6.noarch.rpm: Header V3 RSA/SHA256 Signature, key ID 0608b895: NOKEYPreparing... ########################################### [100%] 1:salt-minion ########################################### [100%]
7.2 修改客户端相关配置文件以及启动客户端服务(参照上面步骤四和步骤五)
八、接收客户端key
[root@nagios-monitor software]# salt-key -LAccepted Keys:nagios-monitornamenodeUnaccepted Keys:datanode01datanode02datanode03datanode04Rejected Keys:[root@nagios-monitor software]# salt-key -AThe following keys are going to be accepted:Unaccepted Keys:datanode01datanode02datanode03datanode04Proceed? [n/Y] YKey for minion datanode01 accepted.Key for minion datanode02 accepted.Key for minion datanode03 accepted.Key for minion datanode04 accepted.