CentOS 7.2 部署Saltstack

前端之家收集整理的这篇文章主要介绍了CentOS 7.2 部署Saltstack前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

CentOS 7.2部署Saltstack

一、环境介绍:

服务器名称 IP地址
Salt-Master 192.168.30.141
Slave1 192.168.30.131
Slave2 192.168.30.132

二、部署前的准备:

  1、添加host文件

  在Master上操作:

# echo -e "192.168.30.141 Salt-Master\n192.168.30.131 Slave1\n192.168.30.132 Slave2" >> /etc/hosts

#sed -i "s/HOSTNAME=.*/HOSTNAME=Salt-Master/g" /etc/sysconfig/network

#hostname Salt-Master

  

  在Slave1上操作

#sed -i "s/HOSTNAME=.*/HOSTNAME=Slave1/g" /etc/sysconfig/network

#hostname Slave1

  在Slave2上操作

# echo -e "192.168.30.141 Salt-Master\n192.168.30.131 Slave1\n192.168.30.132 Slave2" >> /etc/hosts

#sed -i "s/HOSTNAME=.*/HOSTNAME=Slave2/g" /etc/sysconfig/network

#hostname Slave2

  2、安装编译环境(三台机器都要安装):

 # yum -y install gcc-c++

# yum -y install epel-release

  3、安装Saltstack源(三台机器都要安装):

  #yum install https://repo.saltstack.com/yum/redhat/salt-repo-latest-1.el7.noarch.rpm

  #yum clean expire-cache

三、安装部署Saltstack:

  服务端安装(Master):

  #yum -y install salt-master

  修改配置文件

  # sed -i 's/#interface:.*/interface:192.168.30.141/g' /etc/salt/master #修改master监控的IP地址(即本机IP)

  # sed -i 's/#auto_accept:.*/auto_accept: True/g' /etc/salt/master   #修改签证为自动签证

  # egrep -v "^#|^$" /etc/salt/master

  interface: 192.168.30.141

  auto_accept: True

  启动Master服务:

  # systemctl start salt-master

  # systemctl stop firewalld.servcie         #本文为做实验方便,关闭firewall;在正常生产环境中建议开启

  客户端部署(Minion):

  # yum -y install salt-minion

  # sed -i 's/#master:.*/master: 192.168.30.141/g' /etc/salt/minion  # 指定Master主机

  此项为自定义主机ID(自选):  

  # sed -i 's/#id:.*/id: Server1/g' /etc/salt/minion  

  #egrep -v "^#|^$" /etc/salt/minion

  master: 192.168.30.141
  id: Server1

  启动Minion服务:

  # systemctl start salt-minion

  # netstat -an|egrep '4505|4506'

  tcp 0 0 192.168.30.131:58706 192.168.30.141:4505 ESTABLISHED
  tcp 0 0 192.168.30.131:60583 192.168.30.141:4506 ESTABLISHED
  tcp 0 0 192.168.30.131:60585 192.168.30.141:4506 TIME_WAIT
  tcp 0 0 192.168.30.131:60586 192.168.30.141:4506 TIME_WAIT

  #Slave2的操作与Slave1的部署一样,在此就不多做示范了!

四、测试

  在服务端(Master)操作:

  # salt-key -L            #查看已经签证的Minion节点

  Accepted Keys:
  Slave1
  Slave2
  Denied Keys:
  Unaccepted Keys:
  Rejected Keys:

  # salt '*' cmd.run "uptime"    #获取所有Minion节点的uptime时间

  Slave1:
  03:44:55 up 17:47,2 users,load average: 0.00,0.00,0.00
  Slave2:
  19:04:05 up 1 day,10:13,0.00

  至此Saltstack的部署就已经部署完毕了,详细参考手册见:http://www.jb51.cc/article/p-rhlhonid-ty.html

原文链接:https://www.f2er.com/centos/380641.html

猜你在找的CentOS相关文章