saltstack的安装使用

本文介绍了如何在CentOS 6.3_x86_64上安装SaltStack,并提供了详细的配置指南,包括设置EPEL第三方软件源、安装Salt Master与Minion组件、配置端口与身份验证等。

saltstack的安装使用

 

centos6.3_x86_64

 

安装EPEL第三方软件源

wget -c http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm

rpm -ivh epel-release-6-8.noarch.rpm

安装

yum install salt-master -y  //master

yum install salt-minion     //clients

 

chkconfig --list|grep salt   //master默认监听两个端口, 4505(publish_port)为salt的消息发布系统,4506(ret_port)为salt客户端与服务端通信的端口,所以确保客户端能跟服务端的这2个端口通信

salt-master     0:off   1:off   2:off   3:on    4:on    5:on    6:off

salt-syndic     0:off   1:off   2:off   3:on    4:on    5:on    6:off

chkconfig --list|grep salt   //clients   没有端口,只有进程

salt-minion     0:off   1:off   2:off   3:on    4:on    5:on    6:off

配置

/etc/init.d/salt-master start  //master直接启动,若也要作为clients,install salt-minino,修改master和id

vi /etc/salt/minion    //clients

master: 192.168.2.18   //冒号后面有空格

/etc/init.d/salt-minion start  

认证

salt-key -L //all list 详细可salt-key --help

 

实时管理

salt "localhost.localdomain" cmd.run "df -Th"

localhost.localdomain:

    Filesystem    Type    Size  Used Avail Use% Mounted on

    /dev/mapper/VolGroup-lv_root

                  ext4     19G  6.5G   11G  38% /

    tmpfs        tmpfs    244M     0  244M   0% /dev/shm

    /dev/sda1     ext4    485M   40M  420M   9% /boot

群发

salt "*" cmd.run "ls -al /opt/io.sh"

localhost.localdomain:

    -rwxr-xr-x 1 root root 396 Jun  8 18:22 /opt/io.sh

过滤匹配

salt '192.168.*' cmd.run 'echo hi'  

 

正常我们每台主机的HOSTS都是这样

127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4

::1         localhost localhost.localdomain localhost6 localhost6.localdomain6

为了区分开来并且MASTER也作为客户端

vi /etc/salt/minion

 39 id: 192.168.2.18  //或者修改为自定义名称 比如 id: salt-master,修改id后客户端必须重启,salt-keys -L 才能认得到 然后加入-a 如果修改过ID,最好把旧的删掉 -d

salt-key -D      //删除所有KEY

salt-key -d key  //删除单个key

salt-key -A      //接受所有KEY

salt-key -a key  //接受单个key

[root@server1 salt]# salt-key -L

Accepted Keys:

Unaccepted Keys:

192.168.2.18

192.168.2.19

Rejected Keys:

[root@server1 salt]# salt-key -a 192.168.2.18

Key for minion 192.168.2.18 accepted.

[root@server1 salt]# salt-key -a 192.168.2.19

Key for minion 192.168.2.19 accepted.

[root@server1 salt]# salt-key -L

Accepted Keys:

192.168.2.18

192.168.2.19

Unaccepted Keys:

Rejected Keys:

 

测试服务端和客户端通讯

salt "192.168.2.19" test.ping     //单引号也可以

192.168.2.19:

    True

salt "*" salt.modules.disk    //salt.modules.disk  模块

 

服务端:

 vi /etc/salt/master

nodegroups:

    mytest1: 'S@192.168.2.0/24'    

salt -N mytest1 test.ping

192.168.2.18:

    True

client1_2.19:

    True

 

KEYS名字  nodegroups:

    test1: 'L@192.168.2.18,client1_2.19' //多个

    test2: 'client1_2.19'   //单个


转载于:https://my.oschina.net/havefun/blog/208120

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值