SaltStack 开源的集群管理工具,基于Python开发,开源,简单,快速,容易上手。
Master 是主管理节点; (农场主)
Minion 是具体的服务设备节点; (监工)
Syndic 是一群Minion的代理管理节点;(奴隶)
- 配置HOST
[root@23 bin]# cat /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.198.23 salt-master
192.168.198.99 salt-minion
2.通过yum安装
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-6.repo
salt-master# yum install -y salt-master
salt-minion# yum -y install salt-minion
3.master 上配置防火墙
iptables -I INPUT 10 -p tcp --dport 4505:4506 -j ACCEPT
4.配置master节点
vim /etc/salt/master
# The file server works on environments passed to the master,each environment
# can have multiple root directories,the subdirectories in the multiple file
# roots cannot match,otherwise the downloaded files will not be able to be
# reliably ensured. A base environment is required to house the top file.
# Example:
# file_roots:
# base:
# - /srv/salt/
# dev:
# - /srv/salt/dev/services
# - /srv/salt/dev/states
# prod:
# - /srv/salt/prod/services
# - /srv/salt/prod/states
#
file_roots:
base:
- /srv/salt
# Salt Pillars allow for the building of global data that can be made selectively
# available to different minions based on minion grain filtering. The Salt
# Pillar is laid out in the same fashion as the file server,with environments,
# a top file and sls files. However,pillar data does not need to be in the
# highstate format,and is generally just key/value pairs.
pillar_roots:
base:
- /srv/pillar
5.配置minion节点
vim /etc/salt/minion
# Set the location of the salt master server. If the master server cannot be
# resolved,then the minion will fail to start.
master: salt-master
#
Explicitly declare the id for this minion to use,if left commented the id
# will be the hostname as returned by the python call: socket.getfqdn()
# Since salt uses detached ids it is possible to run multiple minions on the
# same machine but with different ids,this can be useful for salt compute
# clusters.
id: salt-minion
6.启动服务
salt-master# /etc/init.d/salt-master start
salt-minion# /etc/init.d/salt-minion start
minion启动后,会向master发起认证请求,可以配置master默认接受一切认证请求,或者挨个接受。
7.接受认证
salt-master# salt-key -L #List all public keys
Accepted Keys:
Denied Keys:
Unaccepted Keys:
salt-minion
Rejected Keys:
接受salt-minion的请求
salt-master# salt-key -a salt-minion #Accept the specified public key
The following keys are going to be accepted:
Unaccepted Keys:
salt-minion Proceed? [n/Y] y
Key for minion salt-minion accepted.
[root@23 bin]# salt-key -L
Accepted Keys:
salt-minion Denied Keys: Unaccepted Keys: Rejected Keys:
8.简单命令
# salt '*' test.ping #检查当前所有主机状态
# salt 'salt-minion' test.ping
# salt '*' cmd.run 'df -h'
9.缺点就是太占内存了,默认启动10个进程,每个占用1g的内存
top
PID USER PR NI VIRT RES SHR S %cpu %MEM TIME+ COMMAND
31970 root 20 0 394m 34m 2916 S 0.0 0.9 5:07.42 salt-master
31977 root 20 0 1194m 33m 3008 S 0.0 0.9 0:01.13 salt-master
31974 root 20 0 1194m 33m 3008 S 0.0 0.9 0:01.13 salt-master
31976 root 20 0 1194m 33m 3004 S 0.0 0.9 0:01.15 salt-master
31982 root 20 0 1194m 33m 3008 S 0.0 0.9 0:01.13 salt-master
31975 root 20 0 1194m 33m 2996 S 0.0 0.9 0:01.13 salt-master
31972 root 20 0 370m 23m 1568 S 0.0 0.6 0:00.22 salt-master
31991 root 20 0 666m 21m 1720 S 0.0 0.6 0:00.17 salt-master
31971 root 20 0 370m 21m 1796 S 0.0 0.6 0:00.00 salt-master
31969 root 20 0 286m 21m 1320 S 0.0 0.6 0:00.01 salt-master
http://www.cnblogs.com/zzzhfo/p/5790918.html
http://www.cnblogs.com/alexyang8/p/3445333.html