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

CentOS 6.4 部署saltstack master/minion

时间:2015-04-17 19:48:43      阅读:172      评论:0      收藏:0      [点我收藏+]

标签:

实验环境:
salt-master: 10.65.253.121 slatm-3738
salt-monion1: 10.65.253.125 slats1-4739
salt-monion2: 10.65.253.139 slats2-5740
 
Saltstack master.
安装epel yum源
warning: /var/tmp/rpm-tmp.dV3tGo: Header V3 RSA/SHA256 Signature, key ID 0608b895: NOKEY
Preparing...                ########################################### [100%]
   1:epel-release           ########################################### [100%]
 
安装salt-master
[root@slatm-3738 ~]#  yum install salt-master.noarch -y
 
salt-master配置文件
[root@slatm-3738 ~]# grep -v ^# /etc/salt/master | grep -v ^$
default_include: master.d/*.conf
interface: 10.65.253.121
publish_port: 4505
max_open_files: 100000
worker_threads: 5
ret_port: 4506
pidfile: /var/run/salt-master.pid
root_dir: /home/salt/
pki_dir: /etc/salt/pki/master
cachedir: /var/cache/salt/master
timeout: 5
sock_dir: /var/run/salt/master
file_roots:
  base:
    - /srv/salt/data/
pillar_roots:
  base:
    - /srv/pillar/data/
key_logfile: /var/log/salt/key
log_level_logfile: warning
log_datefmt_logfile: ‘%Y-%m-%d %H:%M:%S‘
log_fmt_logfile: ‘%(asctime)s,%(msecs)03.0f [%(name)-17s][%(levelname)-8s] %(message)s‘
nodegroups:
   group1: ‘10.65.253.125‘
   group2: ‘10.65.253.139‘
 
启动salt-master服务
[root@slatm-3738 ~]# /etc/init.d/salt-master start
Starting salt-master daemon:                               [  OK  ]
[root@slatm-3738 salt]# chkconfig salt-master on
 
Saltstack minion.
1. 安装epel yum源
warning: /var/tmp/rpm-tmp.soS8bi: Header V3 RSA/SHA256 Signature, key ID 0608b895: NOKEY
Preparing...                ########################################### [100%]
   1:epel-release           ########################################### [100%]
 
2. 安装软件
[root@slats1-4739 ~]# yum -y install salt-minion
 
3. 更改配置文件
[root@slats1-4739 ~]# grep -v ^# /etc/salt/minion | grep -v ^$
master: 10.65.253.121
master_port: 4506
user: root
pidfile: /var/run/salt-minion.pid
root_dir: /home/salt/
pki_dir: /etc/salt/pki/minion
id: 10.65.253.125
cachedir: /var/cache/salt/minion
sock_dir: /var/run/salt/minion
backup_mode: minion
acceptance_wait_time: 10
acceptance_wait_time_max: 0
file_roots:
  base:
    - /srv/salt
pillar_roots:
  base:
    - /srv/pillar
log_file: /var/log/salt/minion
key_logfile: /var/log/salt/key
log_level: warning
log_datefmt_logfile: ‘%Y-%m-%d %H:%M:%S‘
log_fmt_logfile: ‘%(asctime)s,%(msecs)03.0f [%(name)-17s][%(levelname)-8s] %(message)s‘
 
启动salt-minion服务
[root@slats1-4739 ~]# /etc/init.d/salt-minion start
Starting salt-minion daemon:                               [  OK  ]
[root@slats1-4739 ~]# chkconfig salt-minion on
 
在slat-master上查看/接受minion的key
[root@slatm-3738 ~]# salt-key
Accepted Keys:
Unaccepted Keys:
10.65.253.125
Rejected Keys:
 
[root@slatm-3738 ~]# salt-key -y -a 10.65.253.125
The following keys are going to be accepted:
Unaccepted Keys:
10.65.253.125
Key for minion 10.65.253.125 accepted.
 
查看key的状态:
[root@slatm-3738 ~]# salt-key -L
Accepted Keys:
10.65.253.125
Unaccepted Keys:
Rejected Keys:
 
可以通过命令删除指定的key
# salt-key -y -d 192.168.0.100
 
测试:
查看主机状态:
[root@slatm-3738 ~]# salt ‘10.65.253.125‘ test.ping
10.65.253.125:
    True
 
向所有minion上执行命令:
[root@slatm-3738 ~]# salt ‘*‘ cmd.run ‘uname -a‘
10.65.253.125:
    Linux slats1-4739 2.6.32-358.el6.x86_64 #1 SMP Fri Feb 22 00:31:26 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux
 
给定义的指定组执行命令:
[root@slatm-3738 ~]# salt --nodegroup group1 cmd.run ‘uname -a‘
10.65.253.125:
    Linux slats1-4739 2.6.32-358.el6.x86_64 #1 SMP Fri Feb 22 00:31:26 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux
 
执行minion上的自定义脚本
a. 在minion上方个脚本
[root@slats1-4739 ~]# cat /tmp/test.sh
#!/bin/bash
 
echo "hello world."
 
[root@slatm-3738 ~]# salt ‘*‘ cmd.run ‘sh /tmp/test.sh‘
10.65.253.125:
    hello world.
 
[root@slatm-3738 ~]# salt -N group1 cmd.run ‘sh /tmp/test.sh‘
10.65.253.125:
    hello world.

CentOS 6.4 部署saltstack master/minion

标签:

原文地址:http://www.cnblogs.com/torvalds0310/p/4435611.html

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