欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  科技

Saltstack_使用指南02_远程执行-验证

程序员文章站 2022-03-12 07:51:25
1. 主机规划 2. Master与哪些minion通信 2.1. Master与哪些minion正常通信 2.2. 查看master与指定minion通信是否正常 比如指定salt01 3. 远程执行 示例1 示例2 4. saltstack与zeromq ......

 

1. 主机规划

Saltstack_使用指南02_远程执行-验证

 

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