当前位置:网站首页>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
边栏推荐
- Notes on brushing questions (13) -- binary tree: traversal of the first, middle and last order (review)
- Hamiltonian graph
- Interview experience of Xiaomi Android development post~
- 让你理解选择排序(C语言)
- Queuing theory model
- Secret derrière le seau splunk
- 【LeetCode】494. Objective and (2 wrong questions)
- C# 在PDF文档中应用多种不同字体
- 刷题笔记(十四)--二叉树:层序遍历和DFS,BFS
- [Chapter II Relationship between genes and chromosomes] summary of biological knowledge - Biology in grade one of senior high school
猜你喜欢

C reads TXT file to generate word document

Uncaught TypeError: Cannot set property ‘next‘ of undefined 报错解决

解决Splunk kvstore “starting“ 问题

Yapi installation

Streaking? Baa!

Elk - hearthbeat implements service monitoring

安全工程师发现PS主机重大漏洞 用光盘能在系统中执行任意代码

.net core 抛异常对性能影响的求证之路

Let you understand bubble sorting (C language)

C# 读取txt文件生成Word文档
随机推荐
[file upload vulnerability 06] server file content detection and bypass experiment + image horse production method (based on upload-labs-14 shooting range)
Centos7.x下安装mysql8遇到的问题Couldn‘t open file /etc/pki/rpm-gpg/RPM-GPG-KEY-mysql-2022
Fast build elk7.3
How does Sister Feng change to ice?
Where is it safer to open an account for soda ash futures? How is the deposit calculated?
CVPR 2022 𞓜 text guided entity level image manipulation manitrans
Intl.NumberFormat 设置数字格式
Streaking? Baa!
爱可可AI前沿推介(6.11)
yapi安装
【LeetCode】1049. Weight of the last stone II (wrong question 2)
centos安装mysql5.7
Four ways to create threads
浙大联合微软亚研院发布视频识别新方法,可对视频逐帧识别且无需,数据标记,或可用于手语翻译等
阶乘后的零(C语言)
How to solve the problem that high-precision positioning technologies such as ultra wideband UWB, Bluetooth AOA and RTK cannot be widely used due to their high cost? Adopt the idea of integrated deplo
01_ Description object_ Class diagram
微信web开发者,如何学习web开发
P2580 "so he started the wrong roll call"
Linux changes the MySQL password after forgetting it