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)
  • 相关阅读:
    CentOS Linux下VNC Server远程桌面配置详解
    Java 中的悲观锁和乐观锁的实现
    spring @configuration使用
    MySQL 汉字拼音
    chmod用数字来表示权限的方法
    C语言创建删不掉的目录
    Android小经验
    系统清理——查找大文件
    最全Pycharm教程(42)——Pycharm扩展功能之Emacs外部编辑器
    怎样学习程序
  • 原文地址:https://www.cnblogs.com/wanglan/p/7417531.html
Copyright © 2011-2022 走看看