本文共 4642 字,大约阅读时间需要 15 分钟。
[root@salt100 ~]# salt '*' test.pingsalt100: Truesalt01: Truesalt02: Truesalt03: True
比如指定salt01
[root@salt100 ~]# salt 'salt01' test.pingsalt01: True
[root@salt100 ~]# salt '*' cmd.run 'w'salt01: 22:55:08 up 2:32, 1 user, load average: 0.00, 0.01, 0.05 USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT yun pts/0 10.0.0.1 20:23 1:19m 0.27s 0.09s sshd: yun [priv]salt100: 22:55:08 up 2:33, 1 user, load average: 0.00, 0.01, 0.05 USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT yun pts/0 10.0.0.1 20:23 4.00s 0.67s 0.03s sshd: yun [priv]salt03: 22:55:08 up 2:32, 1 user, load average: 0.00, 0.01, 0.04 USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT yun pts/0 10.0.0.1 20:23 55:40 0.20s 0.03s sshd: yun [priv]salt02: 22:55:08 up 2:32, 1 user, load average: 0.00, 0.01, 0.05 USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT yun pts/0 10.0.0.1 20:23 1:23m 0.25s 0.09s sshd: yun [priv]
[root@salt100 ~]# salt '*' cmd.run 'mkdir -p /tmp/zhang'salt03:salt02:salt100:salt01:[root@salt100 ~]# salt '*' cmd.run 'ls -ld /tmp/zhang'salt100: drwxr-xr-x 2 root root 6 Dec 3 22:57 /tmp/zhangsalt01: drwxr-xr-x 2 root root 6 Dec 3 22:57 /tmp/zhangsalt02: drwxr-xr-x 2 root root 6 Dec 3 22:57 /tmp/zhangsalt03: drwxr-xr-x 2 root root 6 Dec 3 22:57 /tmp/zhang
[root@salt100 ~]# ps -ef | grep 'salt-ma'root 1139 1 0 10:24 ? 00:00:01 /usr/bin/python /usr/bin/salt-masterroot 1415 1139 0 10:25 ? 00:00:00 /usr/bin/python /usr/bin/salt-masterroot 1541 1139 0 10:25 ? 00:00:00 /usr/bin/python /usr/bin/salt-masterroot 1544 1139 0 10:25 ? 00:00:00 /usr/bin/python /usr/bin/salt-masterroot 1553 1139 0 10:25 ? 00:01:12 /usr/bin/python /usr/bin/salt-masterroot 1560 1139 0 10:25 ? 00:00:00 /usr/bin/python /usr/bin/salt-masterroot 1563 1560 0 10:25 ? 00:00:23 /usr/bin/python /usr/bin/salt-masterroot 1564 1560 0 10:25 ? 00:00:01 /usr/bin/python /usr/bin/salt-masterroot 1571 1560 0 10:25 ? 00:00:01 /usr/bin/python /usr/bin/salt-masterroot 1574 1560 0 10:25 ? 00:00:02 /usr/bin/python /usr/bin/salt-masterroot 1575 1139 0 10:25 ? 00:00:24 /usr/bin/python /usr/bin/salt-masterroot 1576 1560 0 10:25 ? 00:00:01 /usr/bin/python /usr/bin/salt-masterroot 1584 1560 0 10:25 ? 00:00:01 /usr/bin/python /usr/bin/salt-masterroot 20986 20949 0 15:56 pts/1 00:00:00 grep --color=auto salt-ma[root@salt100 ~]# yum install -y python-setproctitle [root@salt100 ~]# systemctl restart salt-master.service # 重启 master[root@salt100 ~]# ps -ef | grep 'salt-ma'root 21105 1 4 15:57 ? 00:00:00 /usr/bin/python /usr/bin/salt-master ProcessManagerroot 21110 21105 0 15:57 ? 00:00:00 /usr/bin/python /usr/bin/salt-master MultiprocessingLoggingQueueroot 21124 21105 0 15:57 ? 00:00:00 /usr/bin/python /usr/bin/salt-master ZeroMQPubServerChannel # ZeroMQroot 21127 21105 0 15:57 ? 00:00:00 /usr/bin/python /usr/bin/salt-master EventPublisherroot 21128 21105 0 15:57 ? 00:00:00 /usr/bin/python /usr/bin/salt-master Maintenanceroot 21129 21105 0 15:57 ? 00:00:00 /usr/bin/python /usr/bin/salt-master ReqServer_ProcessManagerroot 21130 21129 0 15:57 ? 00:00:00 /usr/bin/python /usr/bin/salt-master MWorkerQueueroot 21131 21129 16 15:57 ? 00:00:00 /usr/bin/python /usr/bin/salt-master MWorker-0root 21132 21129 17 15:57 ? 00:00:01 /usr/bin/python /usr/bin/salt-master MWorker-1root 21133 21129 17 15:57 ? 00:00:01 /usr/bin/python /usr/bin/salt-master MWorker-2root 21134 21129 16 15:57 ? 00:00:00 /usr/bin/python /usr/bin/salt-master MWorker-3root 21135 21105 0 15:57 ? 00:00:00 /usr/bin/python /usr/bin/salt-master FileserverUpdateroot 21136 21129 17 15:57 ? 00:00:01 /usr/bin/python /usr/bin/salt-master MWorker-4root 21735 21136 0 15:57 ? 00:00:00 /usr/bin/python /usr/bin/salt-master MWorker-4root 21737 20949 0 15:57 pts/1 00:00:00 grep --color=auto salt-maroot 21738 21132 0 15:57 ? 00:00:00 /usr/bin/python /usr/bin/salt-master MWorker-1
转载于:https://blog.51cto.com/9410445/2369668