saltstack

目录

安装

centos 6.x安装
#服务端,客户端都要安装
yum -y install python-crypto m2crypto PyYAML python-mako python-setuptools Cython
wget -c http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
rpm -ivh epel-release-6-8.noarch.rpm

centos 5.x安装
yum -y install python-crypto m2crypto PyYAML python-mako python-setuptools Cython
wget  "http://download.fedoraproject.org/pub/epel/5/i386/epel-release-5-4.noarch.rpm"
rpm -ivh epel-release-5-4.noarch.rpm

#服务器安装
yum -y install salt-master 
#客户端安装
yum -y install salt-minion

配置

#注意防火墙的配置
#也可以关闭防火墙
master 端配置

vim /etc/sysconfig/network
HOSTNAME=saltmaster

hostname saltmaster
hostname

vim /etc/salt/master
interface: 192.168.4.111

/etc/init.d/salt-master start
chkconfig salt-master on

#查看服务器是否开启,注意要防火墙规则
[root@saltmaster ~]# netstat -lanput |grep python
tcp        0      0 192.168.4.111:4505          0.0.0.0:*                   LISTEN      11232/python        
tcp        0      0 192.168.4.111:4506          0.0.0.0:*                   LISTEN      11224/python 


#minion 是没有端口的
minion 端配置
vim /etc/hosts 
192.168.4.111 saltmaster

vim /etc/salt/minion
master: 192.168.4.111
id: WEB2013-10-023

/etc/init.d/salt-minion start
chkconfig salt-minion on


使用

salt-key list

[root@saltmaster ~]# salt-key -a WEB2013-10-023
The following keys are going to be accepted:
Unaccepted Keys:
WEB2013-10-023
Proceed? [n/Y] y
Key for minion WEB2013-10-023 accepted.


[root@saltmaster ~]# salt-key list
Accepted Keys:
WEB2013-10-023
Unaccepted Keys:
Rejected Keys:

#ping一下所有的minion
[root@saltmaster ~]# salt "*" test.ping
WEB2013-10-023:
    True

#在所有的minion上执行uptime命令
[root@saltmaster ~]# salt "*" cmd.run uptime
WEB2013-10-023:
     20:01:21 up 11 days,  3:28,  3 users,  load average: 0.00, 0.00, 0.00


#查看线上运行的服务器
[root@saltmaster ~]# salt-run manage.status
down:
up:
    - WEB2013-10-023



目录