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


    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
  • 相关阅读:
    Effective Java 第三版——26. 不要使用原始类型
    Effective Java 第三版——25. 将源文件限制为单个顶级类
    Effective Java 第三版——24. 优先考虑静态成员类
    Effective Java 第三版——23. 优先使用类层次而不是标签类
    Effective Java 第三版——22. 接口仅用来定义类型
    Effective Java 第三版——21. 为后代设计接口
    Effective Java 第三版——20. 接口优于抽象类
    Effective Java 第三版——19. 如果使用继承则设计,并文档说明,否则不该使用
    Effective Java 第三版——18. 组合优于继承
    Effective Java 第三版——17. 最小化可变性
  • 原文地址:https://www.cnblogs.com/zhanglianghhh/p/10604464.html
Copyright © 2020-2023  润新知