什么是Saltstack ?
Saltstack 是一个具备puppet 与func 功能为一身的集中化管理平台,saltstack 基于python实现,功能十分强大,各模块融合度及复用性极高,官方极力推荐作为云计算平台的基础架构。
安装Saltstack
6系列yum安装
1 2 3 4
| rpm -ivh http://mirrors.yun-idc.com/epel/6/x86_64/epel-release-6-8.noarch.rpm yum update yum install salt-master #主控端 yum install salt-minion # 被控端
|
7系列安装
1 2 3
| yum install https://repo.saltstack.com/yum/redhat/salt-repo-latest-1.el7.noarch.rpm yum install salt-master #主控端 yum install salt-minion # 被控端
|
pip安装
salt-bootstrap安装
1 2
| curl -L https://bootstrap.saltstack.com -O install_salt.sh 运行脚本查看用法
|
配置Saltstack
主动端
相关文件
1 2 3 4 5 6 7 8 9
| /etc/salt/master #主配置文件 /etc/salt/master.d /etc/salt/pki/master /usr/bin/salt /usr/bin/salt-cp /usr/bin/salt-key /usr/bin/salt-master /usr/bin/salt-run /usr/bin/salt-unity
|
配置文件 /etc/salt/master
1 2
| interface: 127.0.0.1 #监听端 auto_accept: True # 自动接受认证
|
控制端
相关文件
1 2 3 4 5 6 7
| /etc/salt/minion /etc/salt/minion.d /etc/salt/pki/minion /etc/salt/proxy /usr/bin/salt-call /usr/bin/salt-minion /usr/bin/salt-proxy
|
配置
1 2
| master: 172.25.254.135 #主控端 id:salt-test #id,最好是主机名
|
使用
key认证
salt-key -L 显示所有的key
1 2 3 4 5
| Accepted Keys: Denied Keys: Unaccepted Keys: salt-test Rejected Keys:
|
salt-key -A -y
接受所有的key
- salt-key -D
删除所以的key
基本操作
测试
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76
| [root@foundation101 salt]# salt '*' test.ping salt-test: True [root@foundation101 salt]# salt '*' test.versions_information salt-test: ---------- Dependency Versions: ---------- Jinja2: 2.7.2 M2Crypto: 0.21.1 Mako: None PyYAML: 3.10 PyZMQ: 14.7.0 Python: 2.7.5 (default, Feb 11 2014, 07:46:25) RAET: None Tornado: 4.2.1 ZMQ: 4.0.5 cffi: 1.7.0 cherrypy: 3.2.3 dateutil: 1.5 gitdb: None gitpython: None ioflo: None libgit2: None libnacl: None msgpack-pure: None msgpack-python: 0.4.6 mysql-python: 1.2.3 pycparser: 2.14 pycrypto: 2.6.1 pygit2: None python-gnupg: None smmap: None timelib: None Salt Version: ---------- Salt: 2016.3.1 System Versions: ---------- dist: redhat 7.1 Maipo machine: x86_64 release: 3.10.0-123.el7.x86_64 system: Linux version: Red Hat Enterprise Linux Server 7.1 Maipo
|
查看线上运行的服务器:
salt有用指令:
1 2 3
| salt '*' saltutil.running salt '*' saltutil.kill_job jobid salt '*' saltutil.find_job jobid
|