zoukankan      html  css  js  c++  java
  • Saltstack 命令

    命令格式

    salt '<操作目标>' <方法>[参数]

    查看被控主机内存使用情况

    [root@node1 ~]# salt '*' cmd.run 'free -h'
    node2:
                      total        used        free      shared  buff/cache   available
        Mem:           727M        127M        406M        5.1M        194M        473M
        Swap:          1.5G          0B        1.5G

    查看以node开头的主机IP是否联通

    [root@node1 ~]# salt -E '^node' test.ping
    node2:
        True
    node3:
        True

     查看minion的相关状态

    [root@node1 ~]# salt-run manage.status
    down:
    up:
        - node2
        - node3

    查看哪些系统任务还在处理中

    [root@node1 ~]# salt-run jobs.active

    查询所有接收到的证书

    [root@node1 ~]# salt-key -L
    Accepted Keys:
    node2
    node3
    Denied Keys:
    Unaccepted Keys:
    Rejected Keys:

     删除单个证书(删除 node2 )

    [root@node1 ~]# salt-key -d node2
    The following keys are going to be deleted:
    Accepted Keys:
    node2
    Proceed? [N/y] y
    Key for minion node2 deleted

    删除所有证书

    [root@node1 ~]# salt-key -D 

    接受所有证书

    [root@node1 ~]# salt-key -A
    The following keys are going to be accepted:
    Unaccepted Keys:
    node2
    Proceed? [n/Y] Y
    Key for minion node2 accepted.

    接受单个证书

    [root@node1 ~]# salt-key -d nobe2

    显示node2 主机的软件包版本列表

    [root@node1 ~]# salt '*' pkg.list_pkgs 
    node3:
        ----------
        GeoIP:
            1.5.0-11.el7
        NetworkManager:
            1:1.0.0-14.git20150121.b4ea599c.el7
        NetworkManager-libnm:
            1:1.0.0-14.git20150121.b4ea599c.el7

    显示 Python 软件包版本信息

    [root@node1 ~]#  salt '*' pkg.version python
    node3:
        2.7.5-16.el7
    node2:
        2.7.5-16.el7

    安装软件包

    [root@node1 ~]# salt '*' pkg.install httpd
    node3:
        ----------
    node2:
        ----------

    查看mysql服务状态

    [root@node1 ~]#  salt '*' service.status mysql
    node2:
        True
    node3:
        False

    启动 node2 主机 mysql 服务器

    [root@node1 ~]# salt 'node2' cmd.run 'service mysql start' 
    node2:
        Redirecting to /bin/systemctl start  mysql.service

    查看 node2 主机 mysql 详细状态

    [root@node1 ~]# salt 'node2' cmd.run 'service mysql status'
    node2:
        Redirecting to /bin/systemctl status  mysql.service
        mysqld.service - MySQL Community Server
           Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled)
           Active: active (running) since Wed 2017-08-23 12:24:03 EDT; 3min 17s ago
          Process: 3732 ExecStartPost=/usr/bin/mysql-systemd-start post (code=exited, status=0/SUCCESS)
          Process: 3718 ExecStartPre=/usr/bin/mysql-systemd-start pre (code=exited, status=0/SUCCESS)
         Main PID: 3731 (mysqld_safe)
  • 相关阅读:
    1093 Count PAT's(25 分)
    1089 Insert or Merge(25 分)
    1088 Rational Arithmetic(20 分)
    1081 Rational Sum(20 分)
    1069 The Black Hole of Numbers(20 分)
    1059 Prime Factors(25 分)
    1050 String Subtraction (20)
    根据生日计算员工年龄
    动态获取当前日期和时间
    对计数结果进行4舍5入
  • 原文地址:https://www.cnblogs.com/wanglan/p/7417531.html
Copyright © 2011-2022 走看看