当前位置:网站首页>saltstack安装与使用
saltstack安装与使用
2022-06-11 12:05:00 【乌托邦为什么被占用了】
一、拓扑结构:
如图所示:

其中,S-C7作为最高级别的master,管理线上的minions、线下SA0221接入的sycdic以及接入SA0221的所有线下的minions
二、安装:
说明:
1、使用yum方式安装的saltstack均已注册系统服务,CentOS6使用service命令管理服务进程,CentOS7使用systemctl管理;
2、服务默认使用端口4505、4506,保证端口空闲且可用(未被防火墙拦截)
3、大量minion端的安装可以使用salt-ssh安装,也可以写脚本完成安装,包括修改配置文件,服务管理等;
2.1 添加salt安装源:
线上线下系统均为CentOS6/7,采用yum方式安装,首先为所有的服务器添加指定版本salt安装源,操作如下:
CentOS6:yum -y install https://repo.saltstack.com/yum/redhat/salt-repo-latest-2.el6.noarch.rpm
CentOS7:yum -y install https://repo.saltstack.com/yum/redhat/salt-repo-latest-2.el7.noarch.rpm
(若执行报异常则为原系统中配置的一些yum源存在问题,根据提示信息将这些源做处理:不用的可以删掉,或者重命名备份存储,然后执行yum clean all 清理缓存后重新安装)
或者:
sudo rpm --import https://repo.saltproject.io/py3/redhat/7/x86_64/latest/SALTSTACK-GPG-KEY.pub
curl -fsSL https://repo.saltproject.io/py3/redhat/7/x86_64/latest.repo | sudo tee /etc/yum.repos.d/salt.repo2.2 分角色安装:
===最高级别master(S-C7)===:
yum -y install salt-master
若自动检测依赖报错,最可能的原因就是自带的yum源中不包含所需的基础依赖内容,可以通过换源解决,比较好用的有163或者阿里云,阿里云yum源地址如下:
CentOS 6:
base:http://mirrors.aliyun.com/repo/Centos-6.repo
epel:http://mirrors.aliyun.com/repo/epel-6.repo
CentOS 7:
base:http://mirrors.aliyun.com/repo/Centos-7.repo
epel:http://mirrors.aliyun.com/repo/epel-7.repo
安装好后修改配置文件:/etc/salt/master,修改内容如下:
auto_accept: True #该选项用于使master自动接受所有发送公钥的minions
order_masters: True #该选项确保额外的数据被发送至syndic
启动master,验证:netstat -antlp | grep python
===中间层syndic安装(SA221)===:
yum install -y salt-master
yum install -y salt-syndic
修改配置文件/etc/salt/master,修改内容如下:
auto_accept: True
syndic_master: 60.191.84.230 #更高级master的IP,这里是S-C7
file_roots: #file_roots需要在syndic上配置,因为它不会在master之间传递
base:
- /srv/salt
启动master、syndic
===minion端安装===:
yum -y install salt-minion
修改配置文件/etc/salt/minion,修改内容如下:
master: 192.168.0.221
启动minion
三、使用:
3.1、命令行执行
配置无误后可以在master端使用salt-key -L 认证key信息,认证成功后可以使用一下格式命令直接命令行执行,格式为:
salt -选项参数 目标minions 执行函数 函数参数
示例:salt '*' cmd.run 'ls -l /etc'
3.2、sls文件执行
state是Saltstack最核心的功能,通过预先定制好的sls(salt state file)文件对被控制主机进行状态管理,支持包括程序包(pkg)、文件(file)、网络配置(network)、系统服务(service)、系统用户(user)等,
master端添加配置文件,配置文件(/srv/salt/logstash)示例:

/etc/logrotate.d/tomcat:
file.managed:
- user: root
- group: root
- mode: 644
- source: salt://base/logrotate/file/tomcat
logrotate.run:
cmd.run:
- name: /usr/sbin/logrotate /etc/logrotate.conf >/dev/null 2>&1 |
master端运行(仅已一台minitor为例):
salt "SA0102" state.sls base.logrotate
边栏推荐
- 纯数据业务的机器打电话进来时回落到了2G/3G
- C # apply many different fonts in PDF documents
- Elk - elastalert largest pit
- mysql 导入宝塔中数据库data为0000-00-00,enum为null出错
- [file upload vulnerability 06] server file content detection and bypass experiment + image horse production method (based on upload-labs-14 shooting range)
- [Chapter II Relationship between genes and chromosomes] summary of biological knowledge - Biology in grade one of senior high school
- 2020-07 study notes sorting
- 【LeetCode】494. Objective and (2 wrong questions)
- Queuing theory model
- Template engine - thymeleaf
猜你喜欢
随机推荐
纯数据业务的机器打电话进来时回落到了2G/3G
Four ways to create threads
Golang uses XOR ^ to exchange two variables and encrypt / decrypt them
广东市政安全施工资料管理软件2022新表格来啦
typescript 编译选项和配置文件
C reads TXT file to generate word document
Zhouhongyi's speech at the China Network Security Annual Conference: 360 secure brain builds a data security system
Command symbols commonly used by programmers
Merge two ordered arrays (C language)
Hamiltonian graph
Use of Chinese input method input event composition
微信web开发者,如何学习web开发
调整数组顺序使奇数位于偶数前面(C语言)
Use compiler option ‘--downlevelIteration‘ to allow iterating of iterators 报错解决
Splunk 手工同步search head
Gerber文件在PCB制造中的作用
Is the SSL certificate reliable in ensuring the information security of the website?
Pan domain SSL certificate, sectigo cheap wildcard certificate popularization plan
Fast build elk7.3
. The way to prove the effect of throwing exceptions on performance in. Net core





![[JUC supplementary] atomic class, unsafe](/img/24/e51cfed39fe820fb46cca548af1782.jpg)


