saltstack的安裝使用 centos6.3_x86_64 安裝EPEL第三方軟體源wget -c http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpmrpm -ivh epel-release-6-8.noarch.rpm安裝yum install salt-master -y //masteryum install salt-minion //clients chkconfig --list|grep salt //master預設監聽兩個連接埠, 4505(publish_port)為salt的訊息發布系統,4506(ret_port)為salt用戶端與服務端通訊的連接埠,所以確保用戶端能跟服務端的這2個連接埠通訊salt-master 0:off 1:off 2:off 3:on 4:on 5:on 6:offsalt-syndic 0:off 1:off 2:off 3:on 4:on 5:on 6:offchkconfig --list|grep salt //clients 沒有連接埠,只有進程salt-minion 0:off 1:off 2:off 3:on 4:on 5:on 6:off配置/etc/init.d/salt-master start //master直接啟動,若也要作為clients,install salt-minino,修改master和idvi /etc/salt/minion //clientsmaster: 192.168.2.18 //冒號後面有空格/etc/init.d/salt-minion start 認證salt-key -L //all list 詳細可salt-key --help 即時管理salt "localhost.localdomain" cmd.run "df -Th"localhost.localdomain: Filesystem Type Size Used Avail Use% Mounted on /dev/mapper/VolGroup-lv_root ext4 19G 6.5G 11G 38% / tmpfs tmpfs 244M 0 244M 0% /dev/shm /dev/sda1 ext4 485M 40M 420M 9% /boot群發salt "*" cmd.run "ls -al /opt/io.sh"localhost.localdomain: -rwxr-xr-x 1 root root 396 Jun 8 18:22 /opt/io.sh過濾匹配salt '192.168.*' cmd.run 'echo hi' 正常我們每台主機的HOSTS都是這樣127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4::1 localhost localhost.localdomain localhost6 localhost6.localdomain6為了區分開來並且MASTER也作為用戶端vi /etc/salt/minion 39 id: 192.168.2.18 //或者修改為自訂名稱 比如 id: salt-master,修改id後用戶端必須重啟,salt-keys -L 才能認得到 然後加入-a 如果修改過ID,最好把舊的刪掉 -dsalt-key -D //刪除所有KEYsalt-key -d key //刪除單個keysalt-key -A //接受所有KEYsalt-key -a key //接受單個key[root@server1 salt]# salt-key -LAccepted Keys:Unaccepted Keys:192.168.2.18192.168.2.19Rejected Keys:[root@server1 salt]# salt-key -a 192.168.2.18Key for minion 192.168.2.18 accepted.[root@server1 salt]# salt-key -a 192.168.2.19Key for minion 192.168.2.19 accepted.[root@server1 salt]# salt-key -LAccepted Keys:192.168.2.18192.168.2.19Unaccepted Keys:Rejected Keys: 測試服務端和用戶端通訊salt "192.168.2.19" test.ping //單引號也可以192.168.2.19: Truesalt "*" salt.modules.disk //salt.modules.disk 模組 組服務端: vi /etc/salt/masternodegroups: mytest1: 'S@192.168.2.0/24' salt -N mytest1 test.ping192.168.2.18: Trueclient1_2.19: True KEYS名字 nodegroups: test1: 'L@192.168.2.18,client1_2.19' //多個 test2: 'client1_2.19' //單個