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 |
[root@salt-master /]# 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源
[root@salt-master /]# wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-6.repo
关闭防火墙
[root@salt-master /]# /etc/init.d/iptables stop iptables: Setting chains to policy ACCEPT: filter [ OK ] iptables: Flushing firewall rules: [ OK ] iptables: Unloading modules: [ OK ] [root@salt-test-minion /]# /etc/init.d/iptables stop iptables: Setting chains to policy ACCEPT: filter [ OK ] iptables: Flushing firewall rules: [ OK ] iptables: Unloading modules: [ OK ]
master端
[root@salt-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![root@salt-master /]# chkconfig salt-master on [root@salt-master /]# chkconfig --list salt-master salt-master 0:off 1:off 2:on 3:on 4:on 5:on 6:off
salt-test-minion端
[root@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![root@salt-test-minion /]# chkconfig salt-minion on #加入开机启动 [root@salt-test-minion /]# chkconfig --list salt-minion salt-minion 0:off 1:off 2:on 3:on 4:on 5:on 6:off
master端
[root@salt-master /]# cp /etc/salt/master /etc/salt/master.bk #做备份 [root@salt-master /]# vim /etc/salt/master
416 file_roots: #:把#(注释)去掉
417 base:
418 - /srv/salt
529 pillar_roots: #:把#(注释)去掉
530 base:
531 - /srv/pillar
[root@salt-master /]# /etc/init.d/salt-master start
Starting salt-master daemon: [ OK ]
salt-test-minion端
[root@salt-test-minion /]# cp /etc/salt/minion /etc/salt/minion.bk [root@salt-test-minion /]# vim /etc/salt/minion
16 master: 192.168.161.132 #改为master的Ip或主机名
78 id: minion #定义个名字(建议起个有意义的名字如:nfs、nginx等)
[root@salt-test-minion /]# /etc/init.d/salt-minion start
Starting salt-minion daemon: [ OK ]
[root@salt-test-minion /]# chkconfig salt-minion on
master端
[root@salt-master /]# salt-key -L#显示所有minion认证信息
[root@salt-master /]# salt-key -a salt-test-minion #接受salt-test-minion的认证信息;可跟参数 -y
[root@salt-master /]# salt-key
或
[root@localhost /]# salt-key -A #接受所有Unaccepted状态的minion认证信息
The following keys are going to be accepted:
Unaccepted Keys:
minion
Proceed? [n/Y] y
Key for minion minion accepted.
[root@localhost /]# salt-key
Accepted Keys:
minion
Denied Keys:
Unaccepted Keys:
Rejected Keys:
安装完成
一些简单命令介绍
[root@localhost salt]# salt-key -d salt-test-minion #拒绝认证salt-test-minion [root@localhost salt]# salt-key -D 拒绝所有 [root@salt-master /]# salt '*' test.ping #检查当前所有主机状态
或
[root@salt-master /]# salt 'salt-test-minion' test.ping
[root@salt-master /]# salt '*' cmd.run 'df -h'
文件分发
[root@salt-master /]# mkdir /srv/-master /]# cd /srv/salt/-/srv/-/etc/- source: salt:--- mode:
[root@salt-master salt]# mkdir files [root@salt-master salt]# cd files [root@salt-master files]# ls [root@salt-master files]# vim /etc/hosts [root@salt-master files]# 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 ######################### #[root@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 [root@salt-master files]# cp /etc/hosts . #拷贝到当前目录 [root@salt-master files]# cd - /srv/salt [root@salt-master salt]# salt '*' state.sls host_file
到salt-test-minion上验证是否真的分发成功
或
[root@salt-master salt]# salt-cp '*' /etc/hosts /etc #不用创建上面的host_file.sls即可实现(不建议此方法)
当前文章:CentOS-6.5-saltstack-安装
链接URL:http://myzitong.com/article/gicooi.html