zoukankan      html  css  js  c++  java
  • 自动化运维之saltstack 简单用法(一)

    安装saltstack

    saltstack大概就是一个大哥,控制一群小弟。。。

    需要EPEO源

    wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-6.repo
    或者7
    
    
    wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
     
    在master端安装saltstack
    yum install salt-master -y

    chkconfig salt-master on
    #开机自启动

    在小弟端安装 minino

    yum install salt-minion -y

    chkconfig salt-minion on

    配置master端

    vim /etc/salt/master
    
    #(416行,注释打开,记住空格)
    
    file_roots:
      base:
        - /srv/salt
    
    #(529,注释打开)
    
    pillar_roots
    
      base:
    
        - /srv/pillar

    启动master服务

    /etc/init.d/salt-master start
    [root@web01 salt]# tree pki/          
    pki/
    └── master
        ├── master.pem
        ├── master.pub
        ├── minions
        │   ├── salt
        │   ├── web01
        │   └── web02
        ├── minions_autosign
        ├── minions_denied
        ├── minions_pre
        └── minions_rejected

    修改minion端

    vim /etc/salt/minion
    
    #(: 号后面一定要有一个空格)
    
    16 master: 192.168.70.125
    
    #(名字无所谓,为了方便管理)
    
     78 id: salt

    /etc/init.d/salt-minion start

    查看接口

    [root@web01 ~]# salt-key
    Accepted Keys:     #同意的key
    salt
    Denied Keys:     #拒绝的
    Unaccepted Keys:    #未同意的
    web01
    web02
    Rejected Keys:

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

    参数 -a 管理某一个机器

            -A  管理全部

           -y  同意

           -L  列出所以

           -d   删除单独的

           -D   删除所有

    测试 ping主机

    命令  ‘目标’  模块.方法

    salt '*' test.ping
    web01:
        True
    web02:
        True

    查看某一个主机

    salt 'web02' test.ping
    web02:
        True

    查看所有磁盘信息

    [root@web01 ~]# salt '*' cmd.run 'df -h'
    web02:
        Filesystem      Size  Used Avail Use% Mounted on
        /dev/vda3        18G  3.7G   13G  22% /
        tmpfs           940M   84K  940M   1% /dev/shm
        /dev/vda1       190M   40M  141M  23% /boot
    web01:
        Filesystem      Size  Used Avail Use% Mounted on
        /dev/sda3       7.6G  3.7G  3.6G  51% /
        tmpfs           928M   84K  928M   1% /dev/shm
        /dev/sda1       190M   40M  140M  23% /boot



  • 相关阅读:
    webpack基础
    LeetCode232. 用栈实现队列做题笔记
    mysql 时间加减一个月
    leetcode 1381. 设计一个支持增量操作的栈 思路与算法
    LeetCode 141. 环形链表 做题笔记
    leetcode 707. 设计链表 做题笔记
    leetcode 876. 链表的中间结点 做题笔记
    leetcode 143. 重排链表 做题笔记
    leetcode 1365. 有多少小于当前数字的数字 做题笔记
    LeetCode1360. 日期之间隔几天 做题笔记
  • 原文地址:https://www.cnblogs.com/sky00747/p/8241558.html
Copyright © 2011-2022 走看看