一、yum安装
安装master端:yum install salt-master -y
安装minion端:yum install salt-minion -y
如果没有yum源
Run the following commands to install the SaltStack repository and key:
sudo yum install https://repo.saltstack.com/yum/redhat/salt-repo-2015.8-2.el7.noarch.rpm
Run sudo yum clean expire-cache
Install the salt-minion, salt-master, or other Salt components:
sudo yum install salt-master
sudo yum install salt-minion
sudo yum install salt-ssh
sudo yum install salt-syndic
sudo yum install salt-cloud
sudo yum install salt-api
二、源码包安装
wget http://download.zeromq.org/zeromq-4.0.5.tar.gz && tar zxvf zeromq-4.0.5.tar.gz && cd zeromq-4.0.5 && ./autogen.sh && ./configure --prefix=/usr/local && make && make install
yum -y install autoconf libsodium uuid uuid-c++ uuid-devel libuuid libuuid-devel swig.x86_64
/usr/local/python/bin/pip2 install pyyaml
/usr/local/python/bin/pip2 install MarkupSafe
/usr/local/python/bin/pip2 install Jinja2
/usr/local/python/bin/pip2 install pyzmq
/usr/local/python/bin/pip2 install msgpack-python
/usr/local/python/bin/pip2 install msgpack-pure
/usr/local/python/bin/pip2 install pycrypto
/usr/local/python/bin/pip2 install requests
/usr/local/python/bin/pip2 install msgpack-python
/usr/local/python/bin/pip2 install salt
wget https://pypi.python.org/packages/source/s/salt/salt-2015.5.0.tar.gz && tar zxvf salt-2015.5.0.tar.gz && cd salt-2015.5.0/ && /usr/local/python/bin/python2.7 setup.py install
wget https://pypi.python.org/packages/source/s/salt/salt-2014.7.5.tar.gz && tar zxvf salt-2015.5.0.tar.gz && cd salt-2015.5.0/ && /usr/local/python/bin/python2.7 setup.py install
三、配置文件
(1)、master端
mkdir -p /etc/salt
mkdir -p /usr/local/salt/run
mkdir -p /usr/local/salt/logs
mkdir -p /usr/local/salt/salt
mkdir -p /usr/local/salt/pillar
mkdir -p /usr/local/salt/etc
chown -R monitor.monitor /usr/local/salt
cp -a pkg/suse/salt-master /etc/init.d/
cp -a pkg/suse/salt-master /usr/local/bin/
chmod +x /etc/init.d/salt-master
chkconfig --level 235 salt-master on
ln -s /usr/local/bin/salt-master /usr/bin/
配置文件项
vim /etc/salt/master
#绑定IP
interface: 10.133.33.85
#自动识别KEY
auto_accept: True
#salt运行的用户,影响到salt的执行权限
user: monitor
#salt的运行线程,开的线程越多一般处理的速度越快,但一般不要超过CPU的个数
worker_threads: 10
#master的管理端口
publish_port : 4505
#master跟minion的通讯端口,用于文件服务,认证,接受返回结果等
ret_port : 4506
#如果这个master运行的salt-syndic连接到了一个更高层级的master,那么这个参数需要配置成连接到的这个高层级master的监听端口
syndic_master_port : 4506
#指定pid文件位置
pidfile: /usr/local/salt/run/salt-master.pid
#saltstack 可以控制的文件系统的开始位置
root_dir: /usr/local/salt
#日志文件地址
log_file: /usr/local/salt/logs/salt_master.log
log_datefmt_logfile: '%Y-%m-%d %H:%M:%S'
#导入配置文件
default_include: /usr/local/salt/etc/*.conf
#salt state执行时候的根目录
file_roots:
base:
- /usr/local/salt/salt
#设置pillar 的根目录
pillar_roots:
base:
- /usr/local/salt/pillar
ext_pillar:
- hiera: /usr/local/salt/etc/hiera.yaml
- cmd_yaml: cat /usr/local/salt/etc/salt/yaml
启停
service salt-master start
service salt-master stop
service salt-master restart
(2)、minion端
mkdir /etc/salt
cp -a conf/minion /etc/salt/
cp -a pkg/suse/salt-minion /etc/init.d/
chmod +x /etc/init.d/salt-minion
chkconfig --level 235 salt-minion on
ln -s /usr/local/bin/salt-minion /usr/bin/
vim /etc/salt/minion
#minion的识别ID,可以是IP,域名,或是可以通过DNS解析的字符串
id: 10.144.160.124
#salt运行的用户权限
user: monitor
#master的识别ID,可以是IP,域名,或是可以通过DNS解析的字符串
master : 10.251.27.28
#master通讯端口
master_port: 4506
#备份模式,minion是本地备份,当进行文件管理时的文件备份模式
backup_mode: minion
#执行salt-call时候的输出方式
output: nested
#minion等待master接受认证的时间
acceptance_wait_time: 10
#失败重连次数,0表示无限次,非零会不断尝试到设置值后停止尝试
acceptance_wait_time_max: 0
#重新认证延迟时间,可以避免因为master的key改变导致minion需要重新认证的syn风暴
random_reauth_delay: 60
#导入配置文件
default_include: /usr/local/salt/etc/*.conf
#日志文件位置
log_file: /usr/local/salt/logs/salt_minion.log
sock_dir: /usr/local/salt/run
log_datefmt_logfile: '%Y-%m-%d %H:%M:%S'
pidfile: /usr/local/salt/run/salt-minion.pid
#文件路径基本位置
root_dir: /usr/local/salt
file_roots:
base:
- /usr/local/salt/salt
#pillar基本位置
pillar_roots:
base:
- /usr/local/salt/pillar
启停
service salt-minion start
service salt-minion stop
service salt-minion restart