升木 发表于 2018-7-31 09:54:14

CentOS-6.5-saltstack-安装

  官方网站:https://www.saltstack.com/
  官方文档   https://docs.saltstack.cn/contents.html
  GitHub:https://github.com/saltstack
  中国saltstack用户组:https://www.saltstack.cn/
  CentOS-6.5安装saltstack
  192.168.161.132
  salt-master
  salt-master
  可装(salt-minion)这里只装salt-master
  192.168.161.133
  salt-test-minion
  salt-minion
# cat /etc/hosts127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4  
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6192.168.161.132    salt-master192.168.161.133    salt-test-minion
  安装epel源
# wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-6.repo  关闭防火墙

# /etc/init.d/iptables stop  
iptables: Setting chains to policy ACCEPT: filter [ OK ]
  
iptables: Flushing firewall rules: [ OK ]
  
iptables: Unloading modules: [ OK ]
  

  
# /etc/init.d/iptables stop
  
iptables: Setting chains to policy ACCEPT: filter [ OK ]
  
iptables: Flushing firewall rules: [ OK ]
  
iptables: Unloading modules: [ OK ]

  master端

# yum -y install salt-master  

  
Installed:
  
salt-master.noarch 0:2015.5.10-2.el6
  

  
Dependency Installed:
  
PyYAML.x86_64 0:3.10-3.1.el6
  
libyaml.x86_64 0:0.1.3-4.el6_6
  
m2crypto.x86_64 0:0.20.2-9.el6
  
openpgm.x86_64 0:5.1.118-3.el6
  
python-babel.noarch 0:0.9.4-5.1.el6
  
python-backports.x86_64 0:1.0-5.el6
  
python-backports-ssl_match_hostname.noarch 0:3.4.0.2-4.el6.centos
  
python-chardet.noarch 0:2.2.1-1.el6
  
python-jinja2.x86_64 0:2.2.1-2.el6_5
  
python-msgpack.x86_64 0:0.4.6-1.el6
  
python-requests.noarch 0:2.6.0-3.el6
  
python-six.noarch 0:1.9.0-2.el6
  
python-urllib3.noarch 0:1.10.2-1.el6
  
python-zmq.x86_64 0:14.3.1-1.el6
  
salt.noarch 0:2015.5.10-2.el6
  
zeromq3.x86_64 0:3.2.5-1.el6
  

  
Dependency Updated:
  
python.x86_64 0:2.6.6-66.el6_8 python-libs.x86_64 0:2.6.6-66.el6_8
  

  
Complete!# chkconfig salt-master on
  
# chkconfig --list salt-master
  
salt-master 0:off    1:off    2:on    3:on    4:on    5:on    6:off

  salt-test-minion端

# yum -y install salt-minion  

  
Installed:
  
salt-minion.noarch 0:2015.5.10-2.el6
  

  
Dependency Installed:
  
PyYAML.x86_64 0:3.10-3.1.el6
  
libyaml.x86_64 0:0.1.3-4.el6_6
  
m2crypto.x86_64 0:0.20.2-9.el6
  
openpgm.x86_64 0:5.1.118-3.el6
  
python-babel.noarch 0:0.9.4-5.1.el6
  
python-backports.x86_64 0:1.0-5.el6
  
python-backports-ssl_match_hostname.noarch 0:3.4.0.2-4.el6.centos
  
python-chardet.noarch 0:2.2.1-1.el6
  
python-jinja2.x86_64 0:2.2.1-2.el6_5
  
python-msgpack.x86_64 0:0.4.6-1.el6
  
python-requests.noarch 0:2.6.0-3.el6
  
python-six.noarch 0:1.9.0-2.el6
  
python-urllib3.noarch 0:1.10.2-1.el6
  
python-zmq.x86_64 0:14.3.1-1.el6
  
salt.noarch 0:2015.5.10-2.el6
  
zeromq3.x86_64 0:3.2.5-1.el6
  

  
Dependency Updated:
  
python.x86_64 0:2.6.6-66.el6_8 python-libs.x86_64 0:2.6.6-66.el6_8
  

  
Complete!# chkconfig salt-minion on    #加入开机启动
  
# chkconfig --list salt-minion
  
salt-minion 0:off    1:off    2:on    3:on    4:on    5:on    6:off

              master端

# cp /etc/salt/master /etc/salt/master.bk   #做备份  
# vim /etc/salt/master

  416 file_roots:     #:把#(注释)去掉
  417   base:
  418   - /srv/salt

  529 pillar_roots:     #:把#(注释)去掉
  530   base:
  531   - /srv/pillar
  # /etc/init.d/salt-master start
  Starting salt-master daemon: [ OK ]

  salt-test-minion端

# cp /etc/salt/minion /etc/salt/minion.bk  
# vim /etc/salt/minion

16 master: 192.168.161.132     #改为master的Ip或主机名
78 id: minion #定义个名字(建议起个有意义的名字如:nfs、nginx等)  # /etc/init.d/salt-minion start
  Starting salt-minion daemon: [ OK ]
  # chkconfig salt-minion on

  master端

# salt-key-L#显示所有minion认证信息
  # salt-key -a salt-test-minion   #接受salt-test-minion的认证信息;可跟参数 -y

  # salt-key

  或
  # salt-key -A   #接受所有Unaccepted状态的minion认证信息
  The following keys are going to be accepted:
  Unaccepted Keys:
  minion
  Proceed? y
  Key for minion minion accepted.
  # salt-key
  Accepted Keys:
  minion
  Denied Keys:
  Unaccepted Keys:
  Rejected Keys:

  安装完成
  一些简单命令介绍

# salt-key -d salt-test-minion#拒绝认证salt-test-minion  

  
# salt-key -D    拒绝所有
  

  
# salt '*' test.ping    #检查当前所有主机状态

  或
  # salt 'salt-test-minion' test.ping

  # salt '*' cmd.run 'df -h'


  文件分发

# mkdir /srv/-master /]# cd /srv/salt/-/srv/-/etc/- source: salt:--- mode:

# mkdir files  
# cd files
  
# ls
  
# vim /etc/hosts
  
# cat /etc/hosts   #在最后追加一些内容 目的和salt-test-minion的/etc/hosts/的内容不同,后面验证是否分发成功127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
  
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6192.168.161.132    salt-master192.168.161.133    salt-test-minion
  
#########################
  

  
## cat /etc/hosts   #salt-test-minion的hosts文件
  
#127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
  
#::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
  
#192.168.161.132    salt-master
  
#192.168.161.133    salt-test-minion
  

  
# cp /etc/hosts .    #拷贝到当前目录
  
# cd -
  
/srv/salt
  
# salt '*' state.sls host_file


  到salt-test-minion上验证是否真的分发成功

  或
# salt-cp '*' /etc/hosts /etc   #不用创建上面的host_file.sls即可实现(不建议此方法)
             
页: [1]
查看完整版本: CentOS-6.5-saltstack-安装