常規(guī)運(yùn)維工作涉及業(yè)務(wù)的配置管理和狀態(tài)維護(hù)
基于狀態(tài)(系統(tǒng)狀態(tài)粉怕、代碼狀態(tài)、配置狀態(tài)缭裆、進(jìn)程狀態(tài))
saltstack基于C/S架構(gòu)的服務(wù)模式
服務(wù)端:Master
客戶端:Minion
消息隊(duì)列中的發(fā)布與訂閱(pub/sub)服務(wù)模式
Master和Minion都是已守護(hù)進(jìn)程模式運(yùn)行颤枪,一直監(jiān)聽配置文件里定義的ret_port(接受minion請求)和publish_port(發(fā)布消息)的端口
當(dāng)Minion運(yùn)行時會自動連接到配置文件里面定義的Master地址ret_port端口進(jìn)行連接認(rèn)證。默認(rèn)客戶端請求id是socket.getfqdn()取到的值恒傻,也可以在Minion啟動之前修改Minion的id值
Master端;
#salt-master -l debug
#ss -a | egrep '4505|4506'
Minion端:
#salt-minion -l debug
saltstack 安裝方法一:
步驟1:
#rpm -e --nodeps python2-pycryptodomex
#yum install python-crypto
步驟2:
#sudo yum install https://repo.saltstack.com/yum/redhat/salt-repo-latest-2.el6.noarch.rpm
步驟3:選擇安裝
#sudo yum install salt-minion
#sudo yum install salt-master
#sudo yum install salt-ssh
#sudo yum install salt-syndic
#sudo yum install salt-cloud
#sudo yum install salt-api
步驟4:
#sudo service salt-minion restart
saltstack 安裝方法二:
#wget https://repo.saltstack.com/yum/redhat/6.8/x86_64/saltstack-rhel6.repo
![FFTBTUND]OK%G7MF2``MHL1.png](http://upload-images.jianshu.io/upload_images/6445752-74b2279f35f0f7ba.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
#######vim /etc/yum.repos.d/saltstack.repo
[root@localhost yum.repos.d]# cat saltstack.repo
[saltstack-repo]
name=SaltStack repo for RHEL/CentOS $releasever
baseurl=https://repo.saltstack.com/yum/redhat/$releasever/$basearch/latest
enabled=1
gpgcheck=1 gpgkey=https://repo.saltstack.com/yum/redhat/$releasever/$basearch/latest/SALTSTACK-GPG-KEY.pub
服務(wù)啟動
#service salt-master start //服務(wù)器端啟動
#netstat -antlp | egrep "4506|4506"
#ss -a | egrep "4505|4506"
#service salt-minion start //客戶端啟動
配置文件:
客戶端配置:
vim /etc/salt/minion
# Set the location of the salt master server. If the master server cannot be
#master: salt
master: 192.168.0.67 //salt服務(wù)器的IP地址
#service salt-minion restart
服務(wù)器配置:
vim /etc/salt/master
[root@localhost salt]# cat master | grep interface
# The address of the interface to bind to:
#interface: 0.0.0.0
interface: 192.168.0.67
#service salt-master restart
開始saltstack之旅
證書管理
Master上:
[root@localhost yum.repos.d]# salt-key -L //查看當(dāng)前證書簽證情況
Accepted Keys:
Denied Keys:
Unaccepted Keys:
192.168.0.62
Rejected Keys:
#salt-key -A -y //同意簽證所有沒有接受的
[root@localhost salt]# salt-key -L
Accepted Keys:
192.168.0.62
Denied Keys:
Unaccepted Keys:
Rejected Keys
#salt '*' test.ping
[root@localhost salt]# rpm -ql salt-master
/etc/rc.d/init.d/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
Master配置文件:
- max_open_files——可以根據(jù)Master將Minion數(shù)量進(jìn)行適當(dāng)?shù)恼{(diào)整脸侥。
- timeout——可以根據(jù)Master和Minion的網(wǎng)絡(luò)狀況適當(dāng)調(diào)整。
- auto_accept和autosign_file——在大規(guī)模部署Minion的時候可以設(shè)置自動簽證盈厘。
- master_tops和所有以external開頭的參數(shù)這些參數(shù)是SaltStack與外部系統(tǒng)進(jìn)行整合的相關(guān)配置參數(shù)睁枕,