1. 主机规划
2. Master与哪些minion通信
2.1. Master与哪些minion正常通信
1 [root@salt100 ~]# salt '*' test.ping 2 salt100: 3 True 4 salt01: 5 True 6 salt02: 7 True 8 salt03: 9 True
2.2. 查看master与指定minion通信是否正常
比如指定salt01
1 [root@salt100 ~]# salt 'salt01' test.ping 2 salt01: 3 True
3. 远程执行
示例1
1 [root@salt100 ~]# salt '*' cmd.run 'w' 2 salt01: 3 22:55:08 up 2:32, 1 user, load average: 0.00, 0.01, 0.05 4 USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT 5 yun pts/0 10.0.0.1 20:23 1:19m 0.27s 0.09s sshd: yun [priv] 6 salt100: 7 22:55:08 up 2:33, 1 user, load average: 0.00, 0.01, 0.05 8 USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT 9 yun pts/0 10.0.0.1 20:23 4.00s 0.67s 0.03s sshd: yun [priv] 10 salt03: 11 22:55:08 up 2:32, 1 user, load average: 0.00, 0.01, 0.04 12 USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT 13 yun pts/0 10.0.0.1 20:23 55:40 0.20s 0.03s sshd: yun [priv] 14 salt02: 15 22:55:08 up 2:32, 1 user, load average: 0.00, 0.01, 0.05 16 USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT 17 yun pts/0 10.0.0.1 20:23 1:23m 0.25s 0.09s sshd: yun [priv]
示例2
1 [root@salt100 ~]# salt '*' cmd.run 'mkdir -p /tmp/zhang' 2 salt03: 3 salt02: 4 salt100: 5 salt01: 6 [root@salt100 ~]# salt '*' cmd.run 'ls -ld /tmp/zhang' 7 salt100: 8 drwxr-xr-x 2 root root 6 Dec 3 22:57 /tmp/zhang 9 salt01: 10 drwxr-xr-x 2 root root 6 Dec 3 22:57 /tmp/zhang 11 salt02: 12 drwxr-xr-x 2 root root 6 Dec 3 22:57 /tmp/zhang 13 salt03: 14 drwxr-xr-x 2 root root 6 Dec 3 22:57 /tmp/zhang
4. saltstack与zeromq
1 [root@salt100 ~]# ps -ef | grep 'salt-ma' 2 root 1139 1 0 10:24 ? 00:00:01 /usr/bin/python /usr/bin/salt-master 3 root 1415 1139 0 10:25 ? 00:00:00 /usr/bin/python /usr/bin/salt-master 4 root 1541 1139 0 10:25 ? 00:00:00 /usr/bin/python /usr/bin/salt-master 5 root 1544 1139 0 10:25 ? 00:00:00 /usr/bin/python /usr/bin/salt-master 6 root 1553 1139 0 10:25 ? 00:01:12 /usr/bin/python /usr/bin/salt-master 7 root 1560 1139 0 10:25 ? 00:00:00 /usr/bin/python /usr/bin/salt-master 8 root 1563 1560 0 10:25 ? 00:00:23 /usr/bin/python /usr/bin/salt-master 9 root 1564 1560 0 10:25 ? 00:00:01 /usr/bin/python /usr/bin/salt-master 10 root 1571 1560 0 10:25 ? 00:00:01 /usr/bin/python /usr/bin/salt-master 11 root 1574 1560 0 10:25 ? 00:00:02 /usr/bin/python /usr/bin/salt-master 12 root 1575 1139 0 10:25 ? 00:00:24 /usr/bin/python /usr/bin/salt-master 13 root 1576 1560 0 10:25 ? 00:00:01 /usr/bin/python /usr/bin/salt-master 14 root 1584 1560 0 10:25 ? 00:00:01 /usr/bin/python /usr/bin/salt-master 15 root 20986 20949 0 15:56 pts/1 00:00:00 grep --color=auto salt-ma 16 [root@salt100 ~]# yum install -y python-setproctitle 17 [root@salt100 ~]# systemctl restart salt-master.service # 重启 master 18 [root@salt100 ~]# ps -ef | grep 'salt-ma' 19 root 21105 1 4 15:57 ? 00:00:00 /usr/bin/python /usr/bin/salt-master ProcessManager 20 root 21110 21105 0 15:57 ? 00:00:00 /usr/bin/python /usr/bin/salt-master MultiprocessingLoggingQueue 21 root 21124 21105 0 15:57 ? 00:00:00 /usr/bin/python /usr/bin/salt-master ZeroMQPubServerChannel # ZeroMQ 22 root 21127 21105 0 15:57 ? 00:00:00 /usr/bin/python /usr/bin/salt-master EventPublisher 23 root 21128 21105 0 15:57 ? 00:00:00 /usr/bin/python /usr/bin/salt-master Maintenance 24 root 21129 21105 0 15:57 ? 00:00:00 /usr/bin/python /usr/bin/salt-master ReqServer_ProcessManager 25 root 21130 21129 0 15:57 ? 00:00:00 /usr/bin/python /usr/bin/salt-master MWorkerQueue 26 root 21131 21129 16 15:57 ? 00:00:00 /usr/bin/python /usr/bin/salt-master MWorker-0 27 root 21132 21129 17 15:57 ? 00:00:01 /usr/bin/python /usr/bin/salt-master MWorker-1 28 root 21133 21129 17 15:57 ? 00:00:01 /usr/bin/python /usr/bin/salt-master MWorker-2 29 root 21134 21129 16 15:57 ? 00:00:00 /usr/bin/python /usr/bin/salt-master MWorker-3 30 root 21135 21105 0 15:57 ? 00:00:00 /usr/bin/python /usr/bin/salt-master FileserverUpdate 31 root 21136 21129 17 15:57 ? 00:00:01 /usr/bin/python /usr/bin/salt-master MWorker-4 32 root 21735 21136 0 15:57 ? 00:00:00 /usr/bin/python /usr/bin/salt-master MWorker-4 33 root 21737 20949 0 15:57 pts/1 00:00:00 grep --color=auto salt-ma 34 root 21738 21132 0 15:57 ? 00:00:00 /usr/bin/python /usr/bin/salt-master MWorker-1