zoukankan      html  css  js  c++  java
  • SaltStack

    我用的是salt版本2014.1.4,系统版本是Centos 6.2 X64 最小化安装的

    各自安装salt,开始学习
    Centos 6.x:rpm -ivh http://mirrors.ustc.edu.cn/epel/6/x86_64/epel-release-6-8.noarch.rpm
    Centos 5.x:rpm -ivh http://dl.fedoraproject.org/pub/epel/5/x86_64/epel-release-5-4.noarch.rpm
    服务端安装
    yum install salt-master
    客户端安装
    yum install salt-minion

    安装完毕后启动
    服务端
    /etc/init.d/salt-master start
    客户端
    /etc/init.d/salt-minion start

    启动了还不能立即使用 还需要修改各自配置文件
    服务端:
    配置文件是/etc/salt/master
    刚起步学习的时候我只修改了里面14行的interface选项,这个选项默认是监听全部地址的,这样不是很安全,我把它改成了eth0使用的IP地址
    然后重启了:/etc/init.d/salt-master restart

    客户端:
    配置文件是/etc/salt/minion
    这个配置文件修改了11行的master和42行的id选项
    master 修改成 master主机的地址 这里我改的是192.168.1.100
    id 修改成test101 这个主要是用来区别客户端名的

    test102的修改也和101差不多..

    回到服务端的主机上添加2台minion客户端需要使用到salt-key命令
    先看看有哪些没添加的key

    [root@localhost ~]# salt-key -L
    Accepted Keys:
    Unaccepted Keys:
    test101
    test102
    Rejected Keys:
    #然后再一个一个的添加
    [root@localhost ~]# salt-key -a test102
    The following keys are going to be accepted:
    Unaccepted Keys:
    test102
    Proceed? [n/Y] y
    Key for minion test102 accepted.
    [root@localhost ~]# salt-key -L
    Accepted Keys:
    test102
    Unaccepted Keys:
    test101
    Rejected Keys:
    [root@localhost ~]# salt-key -a test101
    The following keys are going to be accepted:
    Unaccepted Keys:
    test101
    Proceed? [n/Y] Y
    Key for minion test101 accepted.
    [root@localhost ~]# salt-key -L
    Accepted Keys:
    test101
    test102
    Unaccepted Keys:
    Rejected Keys:

    当添加完后就可以直接在master上操作所有的minion了,比如分别查看2台minion的/etc/passwd文件的最后修改时间

    [root@localhost salt]# salt '*' cmd.run 'stat /etc/passwd'
    test102:
          File: `/etc/passwd'
          Size: 856           Blocks: 8          IO Block: 4096   regular file
        Device: fd00h/64768d    Inode: 656679      Links: 1
        Access: (0644/-rw-r--r--)  Uid: (    0/    root)   Gid: (    0/    root)
        Access: 2014-06-08 13:41:09.348744813 -0400
        Modify: 2014-06-08 13:41:09.239736010 -0400
        Change: 2014-06-08 13:41:09.239736010 -0400
    test101:
          File: `/etc/passwd'
          Size: 856           Blocks: 8          IO Block: 4096   regular file
        Device: fd00h/64768d    Inode: 787238      Links: 1
        Access: (0644/-rw-r--r--)  Uid: (    0/    root)   Gid: (    0/    root)
        Access: 2014-06-07 21:29:01.553429161 -0400
        Modify: 2014-05-24 18:55:08.254380629 -0400
        Change: 2014-05-24 18:55:08.254380629 -0400
    当然也可以操作单台的值需要定义好的id名字就好了
    [root@localhost salt]# salt 'test101' cmd.run 'ls'
    test101:
        anaconda-ks.cfg
        install.log
        install.log.syslog
        redis-2.8.3
        redis-2.8.3.tar.gz
    [root@localhost salt]# 

    这前面几个还是很简单的都是几个命令,后面配置sls,pillar,grains完全搞不懂是个什么概念,学习起来是真的苦难,
    到网上搜了几篇文章,都讲得不是很清楚(不知道是我基础差的原因...),

    英文文档呢完全看不懂,中文官方文档看了一下也没看懂,而且感觉更新很慢,算了还是自己看源码吧...

  • 相关阅读:
    短链设计
    .NET Core .NET标准REST库Refit
    .net core 实现动态 Web API
    Visual Studio 2013 Web开发
    .Net 跨平台可移植类库PCL可用于任何平台包括Mono
    Jexus 支持PHP的三种方式
    单元测试模拟框架:Nsubstitute
    开发便于运维的Windows服务
    搭建Linux+Jexus+MariaDB+ASP.NET[LJMA]环境
    在Linux和Windows平台上操作MemoryMappedFile(简称MMF)
  • 原文地址:https://www.cnblogs.com/pping/p/3989696.html
Copyright © 2011-2022 走看看