saltstack是一个新的基础平台管理工具; C/S架构
https://docs.saltstack.com/en/latest/topics/installation/index.html
优点:
1.安装、部署简单,可快速启动服务
2.可支撑管理上万台服务器的规模
3.传输数据基于ZeroMQ(轻量级消息队列),传输数据并发、快速
4.支持API及自定义模块,可以通过Python轻松扩展
依赖:
DEPENDENCIES
Salt should run on any Unix-like platform so long as the dependencies are met.
Python 2.6 >= 2.6 <3.0
msgpack-python - High-performance message interchange format
YAML - Python YAML bindings
Jinja2 - parsing Salt States (configurable in the master settings)
MarkupSafe - Implements a XML/HTML/XHTML Markup safe string for Python
apache-libcloud - Python lib for interacting with many of the popular cloud service providers using a unified API
Requests - HTTP library
Tornado - Web framework and asynchronous networking library
futures - Backport of the concurrent.futures package from Python 3.2
端口:
4505:为salt的消息发布专用端口 //在monion端ss -e会发现一直和master的4505端口保持链接,用于和客户端的长连接,保证master端和minion端的消息通信正常
4506:用于文件服务的传输端口,进行认证等
环境: [root@salt-master salt]# salt '*' grains.item os osrelease salt-master: ---------- os: CentOS osrelease: 7.2.1511 hddcluster3: ---------- os: RedHat osrelease: 7.3 hddcluster2: ---------- os: RedHat osrelease: 7.2 hddcluster4: ---------- os: RedHat osrelease: 7.2 salt-minion01: ---------- os: CentOS osrelease: 6.7 hddcluster1: ---------- os: RedHat osrelease: 7.2 [root@salt-master salt]#
salt-master服务端主机: 详细安装请参考官网,正常情况yum是可以安装saltstack的、 服务器端安装master和minion: yum install salt-master yum install salt-minion 查看服务端安装了什么: [root@salt-master ~]# rpm -ql salt-master /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 /usr/lib/systemd/system/salt-master.service /usr/share/man/man1/salt-cp.1.gz /usr/share/man/man1/salt-key.1.gz /usr/share/man/man1/salt-master.1.gz /usr/share/man/man1/salt-run.1.gz /usr/share/man/man1/salt-unity.1.gz /usr/share/man/man7/salt.7.gz /var/log/salt/master [root@salt-master ~]# rpm -ql salt-minion /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 /usr/lib/systemd/system/salt-minion.service /usr/share/man/man1/salt-call.1.gz /usr/share/man/man1/salt-minion.1.gz /usr/share/man/man1/salt-proxy.1.gz /var/log/salt/minion 修改简单的配置: vi /etc/salt/master #interface: 0.0.0.0 改为 interface: 10.0.0.177 //10.0.0.177为服务器的本机地址 到此入门的安装配置就已经完毕,下面说minion端的安装配置了
客户端只安装minion包括hddcluster1、hddcluster2、hddcluster3、hddcluster4、salt-minion01: yum install salt-minion [root@salt-minion01 ~]# rpm -ql salt-minion /etc/rc.d/init.d/salt-minion /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 /usr/share/man/man1/salt-call.1.gz /usr/share/man/man1/salt-minion.1.gz /usr/share/man/man1/salt-proxy.1.gz /var/log/salt/minion root@salt-minion01 ~]# vim /etc/salt/minion #master: salt 改为: master: 10.0.0.177
------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------
启动服务: 服务端: systemctl enable salt-master.service systemctl start salt-master.service systemctl enbale salt-minion.service systemctl start salt-minion.service 客户端: centos7,redhat7: systemctl enbale salt-minion.service systemctl start salt-minion.service centos6: /etc/init.d/salt-minion start chkconfig salt-minion on
查看端口: 服务端: [root@salt-master ~]# ss -l |grep 450 tcp LISTEN 0 100 10.0.0.177:4505 *:* tcp LISTEN 0 100 10.0.0.177:4506 *:* 客户端: telnet 10.0.0.177 4505 telnet 10.0.0.177 4506
-----------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------
测试阶段:
查看未接受的key [root@salt-master ~]# salt-key -L Accepted Keys: Denied Keys: Unaccepted Keys: hddcluster1 hddcluster2 hddcluster4 salt-master salt-minion01 Rejected Keys: 一键接受所有key: [root@salt-master ~]# salt-key -A -y The following keys are going to be accepted: Unaccepted Keys: hddcluster1 hddcluster2 hddcluster3 hddcluster4 salt-master salt-minion01 Key for minion hddcluster1 accepted. Key for minion hddcluster2 accepted. Key for minion hddcluster3 accepted. Key for minion hddcluster4 accepted. Key for minion salt-master accepted. Key for minion salt-minion01 accepted. [root@salt-master ~]# salt-key -L Accepted Keys: hddcluster1 hddcluster2 hddcluster3 hddcluster4 salt-master salt-minion01 Denied Keys: Unaccepted Keys: Rejected Keys: 测试一下: [root@salt-master ~]# salt '*' grains.item fqdn_ip4 salt-master: ---------- fqdn_ip4: - 10.0.0.177 hddcluster4: ---------- fqdn_ip4: - 10.0.0.181 hddcluster3: ---------- fqdn_ip4: - 10.0.0.202 hddcluster1: ---------- fqdn_ip4: - 10.0.0.197 hddcluster2: ---------- fqdn_ip4: - 10.0.0.102 salt-minion01: ---------- fqdn_ip4: - 10.0.0.199
[root@salt-master ~]# salt-master --version salt-master 2016.3.4 (Boron)