环境:操作系统centos7
master:1 台
minion: 1台
1.1、查看CentOS的版本和其内核的版本及安装配置阿里云yum源
[iyunv@salt-master ~]# cat /etc/redhat-release
CentOS Linux release 7.2.1511 (Core)
[iyunv@salt-master ~]# uname -r
3.10.0-327.el7.x86_64
[iyunv@salt-master ~]# wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
#1.2、安装epel-release和salt-master工具包
[iyunv@salt-master ~]# yum install epel-release -y
[iyunv@salt-master ~]# yum install salt-master -y
#1.3、配置saltstack开机自启动服务
[iyunv@salt-master ~]# systemctl enable salt-master.service
#1.4、启动saltstack master 服务
[iyunv@salt-master ~]# systemctl start salt-master.service
#1.5、检查saltstack端口及进程的运行状态,其中4505是saltstack管理服务器发送命令消息的端口,4506是消息返回时所用的端口。saltstack一般是会启动多个进程来进行不同工作的。
[iyunv@salt-master ~]# netstat -tunlp | grep python
tcp 0 0 0.0.0.0:4505 0.0.0.0:* LISTEN 17112/python
tcp 0 0 0.0.0.0:4506 0.0.0.0:* LISTEN 17134/python
#1.6、关闭防火墙
[iyunv@salt-master ~]# systemctl disable firewalld.service
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
Removed symlink /etc/systemd/system/basic.target.wants/firewalld.service.
[iyunv@salt-master ~]# systemctl stop firewalld.service
#1.7、修改selinux为Permissive模式
[iyunv@salt-master ~]# setenforce 0
[iyunv@salt-master ~]# getenforce
Permissive
#2、salt-minion的配置安装
#2.1、查看CentOS的版本和其内核的版本及安装配置阿里云yum源
[iyunv@salt-minion-01 ~]# cat /etc/redhat-release
CentOS Linux release 7.2.1511 (Core)
[iyunv@salt-minion-01 ~]# uname -r
3.10.0-327.el7.x86_64
[iyunv@salt-master ~]#wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
#2.2、安装epel-release工具包和salt-minion客户端
[iyunv@salt-minion-01 ~]# yum install epel-release -y
[iyunv@salt-minion-01 ~]# yum install salt-minion -y
#2.3、在minion端配置master的ip地址
#master: salt
master: 192.168.1.131
#2.4、配置开机minion开启自启动服务
[iyunv@salt-minion-01 ~]# systemctl enable salt-minion.service
Created symlink from /etc/systemd/system/multi-user.target.wants/salt-minion.service to /usr/lib/systemd/system/salt-minion.service.
#2.5、启动salt-minion服务
[iyunv@salt-minion-01 ~]# systemctl start salt-minion.service
#2.6、关闭防火墙服务
[iyunv@salt-minion-01 salt]# systemctl disable firewalld.service
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
Removed symlink /etc/systemd/system/basic.target.wants/firewalld.service.
[iyunv@salt-minion-01 salt]# systemctl stop firewalld.service
#2.7、查看salt-minion进程的启动状况
[iyunv@salt-minion-01 salt]# ps -ef | grep salt | grep -v grep
root 16674 1 0 20:41 ? 00:00:01 /usr/bin/python /usr/bin/salt-minion
root 16677 16674 1 20:41 ? 00:00:07 /usr/bin/python /usr/bin/salt-minion
3.master_saltstack具体操作 ,必须添加key,才能成功操作客户端主机
# salt-key -L #查看salt-key
Accepted Keys:
salt-minion-01
salt-minion-02
Denied Keys:
Unaccepted Keys:
Rejected Keys:
# salt-key -A -y #添加salt-key
The following keys are going to be accepted:
Unaccepted Keys:
salt-minion-01
salt-minion-02
Key for minion salt-minion-01 accepted.
Key for minion salt-minion-02 accepted.
# salt-key -L #查看salt-key
Accepted Keys:
salt-minion-01
salt-minion-02
Denied Keys:
Unaccepted Keys:
Rejected Keys:
# salt salt-minion* test.ping #简单测试
salt-minion-01:
True
salt-minion-02:
True
# salt "*" cmd.run 'uname -r' #运行linux命令
salt-minion-01:
3.10.0-327.el7.x86_64
salt-minion-02:
3.10.0-327.el7.x86_64
master:1 台
minion: 1台
1.1、查看CentOS的版本和其内核的版本及安装配置阿里云yum源
[iyunv@salt-master ~]# cat /etc/redhat-release
CentOS Linux release 7.2.1511 (Core)
[iyunv@salt-master ~]# uname -r
3.10.0-327.el7.x86_64
[iyunv@salt-master ~]# wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
#1.2、安装epel-release和salt-master工具包
[iyunv@salt-master ~]# yum install epel-release -y
[iyunv@salt-master ~]# yum install salt-master -y
#1.3、配置saltstack开机自启动服务
[iyunv@salt-master ~]# systemctl enable salt-master.service
#1.4、启动saltstack master 服务
[iyunv@salt-master ~]# systemctl start salt-master.service
#1.5、检查saltstack端口及进程的运行状态,其中4505是saltstack管理服务器发送命令消息的端口,4506是消息返回时所用的端口。saltstack一般是会启动多个进程来进行不同工作的。
[iyunv@salt-master ~]# netstat -tunlp | grep python
tcp 0 0 0.0.0.0:4505 0.0.0.0:* LISTEN 17112/python
tcp 0 0 0.0.0.0:4506 0.0.0.0:* LISTEN 17134/python
#1.6、关闭防火墙
[iyunv@salt-master ~]# systemctl disable firewalld.service
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
Removed symlink /etc/systemd/system/basic.target.wants/firewalld.service.
[iyunv@salt-master ~]# systemctl stop firewalld.service
#1.7、修改selinux为Permissive模式
[iyunv@salt-master ~]# setenforce 0
[iyunv@salt-master ~]# getenforce
Permissive
#2、salt-minion的配置安装
#2.1、查看CentOS的版本和其内核的版本及安装配置阿里云yum源
[iyunv@salt-minion-01 ~]# cat /etc/redhat-release
CentOS Linux release 7.2.1511 (Core)
[iyunv@salt-minion-01 ~]# uname -r
3.10.0-327.el7.x86_64
[iyunv@salt-master ~]#wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
#2.2、安装epel-release工具包和salt-minion客户端
[iyunv@salt-minion-01 ~]# yum install epel-release -y
[iyunv@salt-minion-01 ~]# yum install salt-minion -y
#2.3、在minion端配置master的ip地址
#master: salt
master: 192.168.1.131
#2.4、配置开机minion开启自启动服务
[iyunv@salt-minion-01 ~]# systemctl enable salt-minion.service
Created symlink from /etc/systemd/system/multi-user.target.wants/salt-minion.service to /usr/lib/systemd/system/salt-minion.service.
#2.5、启动salt-minion服务
[iyunv@salt-minion-01 ~]# systemctl start salt-minion.service
#2.6、关闭防火墙服务
[iyunv@salt-minion-01 salt]# systemctl disable firewalld.service
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
Removed symlink /etc/systemd/system/basic.target.wants/firewalld.service.
[iyunv@salt-minion-01 salt]# systemctl stop firewalld.service
#2.7、查看salt-minion进程的启动状况
[iyunv@salt-minion-01 salt]# ps -ef | grep salt | grep -v grep
root 16674 1 0 20:41 ? 00:00:01 /usr/bin/python /usr/bin/salt-minion
root 16677 16674 1 20:41 ? 00:00:07 /usr/bin/python /usr/bin/salt-minion
3.master_saltstack具体操作 ,必须添加key,才能成功操作客户端主机
# salt-key -L #查看salt-key
Accepted Keys:
salt-minion-01
salt-minion-02
Denied Keys:
Unaccepted Keys:
Rejected Keys:
# salt-key -A -y #添加salt-key
The following keys are going to be accepted:
Unaccepted Keys:
salt-minion-01
salt-minion-02
Key for minion salt-minion-01 accepted.
Key for minion salt-minion-02 accepted.
# salt-key -L #查看salt-key
Accepted Keys:
salt-minion-01
salt-minion-02
Denied Keys:
Unaccepted Keys:
Rejected Keys:
# salt salt-minion* test.ping #简单测试
salt-minion-01:
True
salt-minion-02:
True
# salt "*" cmd.run 'uname -r' #运行linux命令
salt-minion-01:
3.10.0-327.el7.x86_64
salt-minion-02:
3.10.0-327.el7.x86_64