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

CentOS 6.5上安装salt

时间:2017-05-25 10:08:16      阅读:204      评论:0      收藏:0      [点我收藏+]

标签:salt   master   minion   epel   saltstack   

一、环境准备

[root@salt-master ~]# cat /etc/sysconfig/network

NETWORKING=yes

HOSTNAME=salt-master.contoso.com

[root@salt-master ~]# hostname

salt-master.contoso.com

[root@salt-master ~]# /etc/init.d/iptables status

iptables: Firewall is not running.

[root@salt-master ~]# iptables -nL

Chain INPUT (policy ACCEPT)

target     prot opt source               destination         


Chain FORWARD (policy ACCEPT)

target     prot opt source               destination         


Chain OUTPUT (policy ACCEPT)

target     prot opt source               destination         

[root@salt-master ~]# getenforce

Disabled

[root@salt-master ~]# crontab -l

*/10 * * * * ntpdate time.nist.gov >/dev/null 2>&1

[root@salt-master ~]# cat /etc/redhat-release 

CentOS release 6.5 (Final)

[root@salt-master ~]# cat /etc/hosts

127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4

::1         localhost localhost.localdomain localhost6 localhost6.localdomain6

172.16.1.100  salt-master     salt-master.contoso.com

172.16.1.101  salt-minion01   salt-minion01.contoso.com

172.16.1.102  salt-minion02   salt-minion02.contoso.com

二、安装salt

1、master安装

rpm -Uvh http://download.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm

yum -y install salt-master

2、minion安装

rpm -Uvh http://download.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm

yum -y install salt-minion

三、修改配置文件

1、master端配置文件

[root@salt-master ~]# cp /etc/salt/master.sample /etc/salt/master

[root@salt-master ~]# vi /etc/salt/master

[root@salt-master salt]# diff master.sample master

416,418c416,420

< #file_roots:

< #  base:

< #    - /srv/salt

---

> file_roots:

>   base:

>     - /srv/salt/base

>   prod:

>     - /srv/salt/prod

535a538,542

> pillar_roots:

>   base:

>     - /srv/pillar/base

>   prod:

>     - /srv/pillar/prod

2、minion端配置文件

[root@salt-minion01 ~]# cp /etc/salt/minion.sample /etc/salt/minion

[root@salt-minion01 ~]# vi /etc/salt/minion

[root@salt-minion01 ~]# diff /etc/salt/minion.sample /etc/salt/minion

16a17

> master: salt-master.contoso.com

78a80

> id: salt-minion01.contoso.com

四、启动salt服务

1、启动master服务

[root@salt-master ~]# /etc/init.d/salt-master start

[root@salt-master ~]# chkconfig salt-master on

检查服务运行状态:

[root@salt-master ~]# netstat -tnlp|grep 4506

tcp        0      0 0.0.0.0:4506                0.0.0.0:*                   LISTEN      1105/python2.6      

[root@salt-master ~]# ps -ef|grep salt

root       1075      1  0 05:39 ?        00:00:00 /usr/bin/python2.6 /usr/bin/salt-master -d

root       1076   1075  0 05:39 ?        00:00:26 /usr/bin/python2.6 /usr/bin/salt-master -d

root       1078   1075  0 05:39 ?        00:00:00 /usr/bin/python2.6 /usr/bin/salt-master -d

root       1083   1075  0 05:39 ?        00:00:00 /usr/bin/python2.6 /usr/bin/salt-master -d

root       1084   1075  0 05:39 ?        00:00:00 /usr/bin/python2.6 /usr/bin/salt-master -d

root       1088   1084  0 05:39 ?        00:00:01 /usr/bin/python2.6 /usr/bin/salt-master -d

root       1089   1084  0 05:39 ?        00:00:01 /usr/bin/python2.6 /usr/bin/salt-master -d

root       1095   1084  0 05:39 ?        00:00:01 /usr/bin/python2.6 /usr/bin/salt-master -d

root       1096   1084  0 05:39 ?        00:00:01 /usr/bin/python2.6 /usr/bin/salt-master -d

root       1102   1084  0 05:39 ?        00:00:01 /usr/bin/python2.6 /usr/bin/salt-master -d

root       1105   1084  0 05:39 ?        00:00:00 /usr/bin/python2.6 /usr/bin/salt-master -d

root       2947   1151  0 07:10 pts/0    00:00:00 grep salt

[root@salt-master ~]# lsof -i :4506

COMMAND    PID USER   FD   TYPE DEVICE SIZE/OFF NODE NAME

salt-mast 1105 root   20u  IPv4   9750      0t0  TCP *:4506 (LISTEN)

salt-mast 1105 root   23u  IPv4  11915      0t0  TCP salt-master:4506->salt-minion01:52639 (ESTABLISHED)

salt-mast 1105 root   28u  IPv4  11914      0t0  TCP salt-master:4506->salt-minion02:34798 (ESTABLISHED)

2、启动minion服务

[root@salt-minion01 ~]# /etc/init.d/salt-minion start

[root@salt-minion01 ~]# chkconfig salt-minion on

检查服务运行状态:

[root@salt-minion01 ~]# netstat -tunlp

Active Internet connections (only servers)

Proto Recv-Q Send-Q Local Address               Foreign Address             State       PID/Program name   

tcp        0      0 0.0.0.0:22                  0.0.0.0:*                   LISTEN      950/sshd            

tcp        0      0 127.0.0.1:25                0.0.0.0:*                   LISTEN      1026/master         

tcp        0      0 :::22                       :::*                        LISTEN      950/sshd            

tcp        0      0 ::1:25                      :::*                        LISTEN      1026/master         

[root@salt-minion01 ~]# lsof -i :4506

COMMAND    PID USER   FD   TYPE DEVICE SIZE/OFF NODE NAME

salt-mini 1054 root   13u  IPv4   9848      0t0  TCP salt-minion01:52639->salt-master:4506 (ESTABLISHED)

[root@salt-minion01 ~]# ps -ef|grep salt

root       1054      1  0 05:39 ?        00:00:04 /usr/bin/python2.6 /usr/bin/salt-minion -d

root       1254   1100  0 07:13 pts/0    00:00:00 grep salt

五、简单测试

1)添加minion端

[root@salt-master ~]# salt-key -A

[root@salt-master ~]# salt-key -L

Accepted Keys:

salt-minion01.contoso.com

salt-minion02.contoso.com

Denied Keys:

Unaccepted Keys:

Rejected Keys:

2)test.ping方法测试

[root@salt-master ~]# salt ‘*‘ test.ping

salt-minion02.contoso.com:

    True

salt-minion01.contoso.com:

    True

3)cmd.run方法测试

[root@salt-master ~]# salt ‘*‘ cmd.run ‘hostname‘

salt-minion01.contoso.com:

    salt-minion01.contoso.com

salt-minion02.contoso.com:

    salt-minion02.contoso.com


本文出自 “IT小二郎” 博客,请务必保留此出处http://jerry12356.blog.51cto.com/4308715/1929155

CentOS 6.5上安装salt

标签:salt   master   minion   epel   saltstack   

原文地址:http://jerry12356.blog.51cto.com/4308715/1929155

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