当前位置:网站首页>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
边栏推荐
- 调整数组顺序使奇数位于偶数前面(C语言)
- Network protocol of yyds dry goods inventory: datagram socket for detailed explanation of socket protocol
- ELK - Hearthbeat实现服务监控
- yapi安装
- Android 11+ 配置SqlServer2014+
- Node connects to MySQL database and writes fuzzy query interface
- JS to realize the rotation chart (riding light). Pictures can be switched left and right. Moving the mouse will stop the rotation
- Zhejiang University and Microsoft Asia Research Institute released a new method of video recognition, which can recognize video frame by frame without data marking, or can be used for sign language tr
- iframe 传值
- 数据如何在 Splunk 中老化?
猜你喜欢

(推荐)splunk 多少数量search head 才合适

让你搞懂冒泡排序(C语言)

C # set or verify the format of text field in PDF

微信web开发者,如何学习web开发
![[file upload vulnerability 06] server file content detection and bypass experiment + image horse production method (based on upload-labs-14 shooting range)](/img/30/79516390c2b2b50a224eaa84a0c1c9.jpg)
[file upload vulnerability 06] server file content detection and bypass experiment + image horse production method (based on upload-labs-14 shooting range)

Linux changes the MySQL password after forgetting it

Software project management 7.1 Basic concept of project schedule

centos安装mysql5.7

读取geo表达矩阵

The role of Gerber file in PCB manufacturing
随机推荐
苹果MobileOne: 移动端仅需1ms的高性能骨干
Splunk Bucket 背后的秘密
深度学习与CV教程(14) | 图像分割 (FCN,SegNet,U-Net,PSPNet,DeepLab,RefineNet)
Node connects to MySQL database and writes fuzzy query interface
Adjust the array order so that odd numbers precede even numbers (C language)
Gestion de projets logiciels 7.1. Concept de base du calendrier du projet
Secret derrière le seau splunk
Read geo expression matrix
CVPR 2022 𞓜 text guided entity level image manipulation manitrans
Problems encountered in installing mysql8 under centos7.x couldn't open file /etc/pki/rpm-gpg/rpm-gpg-key-mysql-2022
C# 设置或验证 PDF中的文本域格式
Network protocol of yyds dry goods inventory: datagram socket for detailed explanation of socket protocol
【LeetCode】494. Objective and (2 wrong questions)
Fast build elk7.3
Qt中radioButton使用
Uncaught TypeError: Cannot set property ‘next‘ of undefined 报错解决
解决swagger文档接口404的问题
How should ordinary people choose annuity insurance products?
Dominating set, independent set, covering set
[file upload vulnerability 05] server suffix detection and bypass experiment (based on upload-labs-3 shooting range)