您好,登錄后才能下訂單哦!
官方網站:https://www.saltstack.com/
官方文檔 https://docs.saltstack.cn/contents.html
GitHub: https://github.com/saltstack
中國saltstack用戶組:https://www.saltstack.cn/
CentOS-6.5安裝saltstack
192.168.161.132 salt-master | salt-master 可裝(salt-minion)這里只裝salt-master |
192.168.161.133 salt-test-minion | salt-minion |
[root@salt-master /]# cat /etc/hosts127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4 ::1 localhost localhost.localdomain localhost6 localhost6.localdomain6192.168.161.132 salt-master192.168.161.133 salt-test-minion
安裝epel源
[root@salt-master /]# wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-6.repo
關閉防火墻
[root@salt-master /]# /etc/init.d/iptables stop iptables: Setting chains to policy ACCEPT: filter [ OK ] iptables: Flushing firewall rules: [ OK ] iptables: Unloading modules: [ OK ] [root@salt-test-minion /]# /etc/init.d/iptables stop iptables: Setting chains to policy ACCEPT: filter [ OK ] iptables: Flushing firewall rules: [ OK ] iptables: Unloading modules: [ OK ]
master端
[root@salt-master /]# yum -y install salt-master Installed: salt-master.noarch 0:2015.5.10-2.el6 Dependency Installed: PyYAML.x86_64 0:3.10-3.1.el6 libyaml.x86_64 0:0.1.3-4.el6_6 m2crypto.x86_64 0:0.20.2-9.el6 openpgm.x86_64 0:5.1.118-3.el6 python-babel.noarch 0:0.9.4-5.1.el6 python-backports.x86_64 0:1.0-5.el6 python-backports-ssl_match_hostname.noarch 0:3.4.0.2-4.el6.centos python-chardet.noarch 0:2.2.1-1.el6 python-jinja2.x86_64 0:2.2.1-2.el6_5 python-msgpack.x86_64 0:0.4.6-1.el6 python-requests.noarch 0:2.6.0-3.el6 python-six.noarch 0:1.9.0-2.el6 python-urllib3.noarch 0:1.10.2-1.el6 python-zmq.x86_64 0:14.3.1-1.el6 salt.noarch 0:2015.5.10-2.el6 zeromq3.x86_64 0:3.2.5-1.el6 Dependency Updated: python.x86_64 0:2.6.6-66.el6_8 python-libs.x86_64 0:2.6.6-66.el6_8 Complete![root@salt-master /]# chkconfig salt-master on [root@salt-master /]# chkconfig --list salt-master salt-master 0:off 1:off 2:on 3:on 4:on 5:on 6:off
salt-test-minion端
[root@salt-test-minion /]# yum -y install salt-minion Installed: salt-minion.noarch 0:2015.5.10-2.el6 Dependency Installed: PyYAML.x86_64 0:3.10-3.1.el6 libyaml.x86_64 0:0.1.3-4.el6_6 m2crypto.x86_64 0:0.20.2-9.el6 openpgm.x86_64 0:5.1.118-3.el6 python-babel.noarch 0:0.9.4-5.1.el6 python-backports.x86_64 0:1.0-5.el6 python-backports-ssl_match_hostname.noarch 0:3.4.0.2-4.el6.centos python-chardet.noarch 0:2.2.1-1.el6 python-jinja2.x86_64 0:2.2.1-2.el6_5 python-msgpack.x86_64 0:0.4.6-1.el6 python-requests.noarch 0:2.6.0-3.el6 python-six.noarch 0:1.9.0-2.el6 python-urllib3.noarch 0:1.10.2-1.el6 python-zmq.x86_64 0:14.3.1-1.el6 salt.noarch 0:2015.5.10-2.el6 zeromq3.x86_64 0:3.2.5-1.el6 Dependency Updated: python.x86_64 0:2.6.6-66.el6_8 python-libs.x86_64 0:2.6.6-66.el6_8 Complete![root@salt-test-minion /]# chkconfig salt-minion on #加入開機啟動 [root@salt-test-minion /]# chkconfig --list salt-minion salt-minion 0:off 1:off 2:on 3:on 4:on 5:on 6:off
[root@salt-master /]# cp /etc/salt/master /etc/salt/master.bk #做備份 [root@salt-master /]# vim /etc/salt/master
416 file_roots: #:把#(注釋)去掉
417 base:
418 - /srv/salt
529 pillar_roots: #:把#(注釋)去掉
530 base:
531 - /srv/pillar
[root@salt-master /]# /etc/init.d/salt-master start
Starting salt-master daemon: [ OK ]
salt-test-minion端
[root@salt-test-minion /]# cp /etc/salt/minion /etc/salt/minion.bk [root@salt-test-minion /]# vim /etc/salt/minion
16 master: 192.168.161.132 #改為master的Ip或主機名
78 id: minion #定義個名字(建議起個有意義的名字如:nfs、nginx等)
[root@salt-test-minion /]# /etc/init.d/salt-minion start
Starting salt-minion daemon: [ OK ]
[root@salt-test-minion /]# chkconfig salt-minion on
master端
[root@salt-master /]# salt-key -L#顯示所有minion認證信息
[root@salt-master /]# salt-key -a salt-test-minion #接受salt-test-minion的認證信息;可跟參數 -y
[root@salt-master /]# salt-key
或
[root@localhost /]# salt-key -A #接受所有Unaccepted狀態的minion認證信息
The following keys are going to be accepted:
Unaccepted Keys:
minion
Proceed? [n/Y] y
Key for minion minion accepted.
[root@localhost /]# salt-key
Accepted Keys:
minion
Denied Keys:
Unaccepted Keys:
Rejected Keys:
安裝完成
一些簡單命令介紹
[root@localhost salt]# salt-key -d salt-test-minion #拒絕認證salt-test-minion [root@localhost salt]# salt-key -D 拒絕所有 [root@salt-master /]# salt '*' test.ping #檢查當前所有主機狀態
或
[root@salt-master /]# salt 'salt-test-minion' test.ping
[root@salt-master /]# salt '*' cmd.run 'df -h'
文件分發
[root@salt-master /]# mkdir /srv/-master /]# cd /srv/salt/-/srv/-/etc/- source: salt:--- mode:
[root@salt-master salt]# mkdir files [root@salt-master salt]# cd files [root@salt-master files]# ls [root@salt-master files]# vim /etc/hosts [root@salt-master files]# cat /etc/hosts #在最后追加一些內容 目的和salt-test-minion的/etc/hosts/的內容不同,后面驗證是否分發成功127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4 ::1 localhost localhost.localdomain localhost6 localhost6.localdomain6192.168.161.132 salt-master192.168.161.133 salt-test-minion ######################### #[root@salt-test-minion /]# cat /etc/hosts #salt-test-minion 的hosts文件 #127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4 #::1 localhost localhost.localdomain localhost6 localhost6.localdomain6 #192.168.161.132 salt-master #192.168.161.133 salt-test-minion [root@salt-master files]# cp /etc/hosts . #拷貝到當前目錄 [root@salt-master files]# cd - /srv/salt [root@salt-master salt]# salt '*' state.sls host_file
到salt-test-minion上驗證是否真的分發成功
或
[root@salt-master salt]# salt-cp '*' /etc/hosts /etc #不用創建上面的host_file.sls即可實現(不建議此方法)
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。