码迷,mamicode.com
首页 > 其他好文 > 详细

saltstack

时间:2016-11-23 00:18:45      阅读:241      评论:0      收藏:0      [点我收藏+]

标签:salt

saltstack时一种基于C/S架构的服务模式,可以简单地理解为如果我们想要使用saltstack就需要在现有的环境下引入维护一套C/S架构。在saltstack架构中服务器端叫做master,客户端叫做minion。

首先来安装saltstack:

在安装之前需要在两台服务器上安装epel源:yum install -y epel-release
在master:
yum install -y salt-master salt-minion
在slace:
yum install -y  salt-minion

因为我们在master上安装了客户端程序,因此master本身也是一个minion。

修改minion端的配置文件

/etc/salt/minion
把#master: salt  把前面的注释去掉,然后把salt改为master端的ip地址。
master: 192.168.1.120 //master端ip

启动saltsatck:

在对用的服务器上分别采用如下语句启用saltstack:

service salt-master start 或者/etc/init.d/salt-master start
service salt-minion start 或者/etc/init.d/salt-minion start

认证:

saltstck使用ssl签证的方式进行安全认证:

[root@master ~]# salt-key   //显示当前key的状态
Accepted Keys:
Denied Keys:
Unaccepted Keys:     //未接受的key有两个
master
slave
Rejected Keys:
[root@master ~]# salt-key -L  //可以使用-L来显示
Accepted Keys:
Denied Keys:
Unaccepted Keys:
master
slave
Rejected Keys:

同意签证未接受的key
[root@master ~]# salt-key -a slave    //用-a选项指定接受某个key,用A则是同意签证所有未接收的key
The following keys are going to be accepted:
Unaccepted Keys:
slave
Proceed? [n/Y] y     //敲字母y
Key for minion slave accepted.
[root@master ~]# salt-key -L
Accepted Keys:
slave               //已经签证。
Denied Keys:
Unaccepted Keys:
master
Rejected Keys:
[root@master ~]# salt-key -A -y    //签证另一个key,,
The following keys are going to be accepted:
Unaccepted Keys:
master
Key for minion master accepted.
[root@master ~]# salt-key -L
Accepted Keys:                //两个key已经签证。
master
slave
Denied Keys:
Unaccepted Keys:
Rejected Keys:

接受成功后我们运行一条指令,如下:

[root@master ~]# salt ‘*‘ test.ping      //*表示所有的minion。
slave:
    True
master:
    True

可以查看一下master,minion端安装了那些文件:

[root@master ~]# rpm -ql  salt-master
/etc/rc.d/init.d/salt-master
/etc/salt/master
/usr/bin/salt
/usr/bin/salt-cp
/usr/bin/salt-key
/usr/bin/salt-master
/usr/bin/salt-run
/usr/bin/salt-unity

[root@slave minion.d]# rpm -ql salt-minion
/etc/rc.d/init.d/salt-minion
/etc/salt/minion
/usr/bin/salt-call
/usr/bin/salt-minion

salt命令的几种匹配方式:

正则匹配:

[root@master ~]# salt -E ‘^s‘ test.ping
slave:
    True

列表匹配:

[root@master ~]# salt -L master,slave test.ping   //中间用逗号分割
master:
    True
slave:
    True
[root@master ~]#

组匹配:

需要在minion配置文件中做如下修改:

nodegroups:
  groups: ‘L@master,slave‘   //把注释去掉,然后添加minion。
[root@master ~]# salt -N groups test.ping
master:
    True
slave:
    True


本文出自 “自定义” 博客,谢绝转载!

saltstack

标签:salt

原文地址:http://zidingyi.blog.51cto.com/10735263/1875432

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!