当前位置:网站首页>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
边栏推荐
- Gestion de projets logiciels 7.1. Concept de base du calendrier du projet
- Guangdong municipal safety construction data management software 2022 new forms are coming
- What is a Gerber file? Introduction to PCB Gerber file
- Where is it safer to open an account for soda ash futures? How much does it cost to buy soda ash futures?
- Notes on topic brushing (XIV) -- binary tree: sequence traversal and DFS, BFS
- ELK - X-Pack设置用户密码
- JVM class loading process
- 异或的妙用(C语言)
- C # convert ofd to PDF
- 读取geo表达矩阵
猜你喜欢

Splunk 最佳实践-减轻captain 负担

Template engine - thymeleaf

CVPR 2022 | 文本引导的实体级别图像操作ManiTrans

Notes on brushing questions (13) -- binary tree: traversal of the first, middle and last order (review)

How does Sister Feng change to ice?

Apple mobileone: the mobile terminal only needs 1ms of high-performance backbone

Splunk 健康检查之关闭THP

Generate statement is not synthesized

ELK - Hearthbeat实现服务监控

Secret derrière le seau splunk
随机推荐
Node connects to MySQL database and writes fuzzy query interface
Live app development to determine whether the user is logging in to the platform for the first time
【LeetCode】494. Objective and (2 wrong questions)
Software project management 7.1 Basic concept of project schedule
How should ordinary people choose annuity insurance products?
Objectinputstream read file object objectoutputstream write file object
Typescript compilation options and configuration files
Linux changes the MySQL password after forgetting it
Four ways to create threads
Qt中radioButton使用
让你搞懂冒泡排序(C语言)
Elk - x-pack set user password
JS 加法乘法错误解决 number-precision
Live source code, floating window rolling gradient effect
Weekly Postgres world news 2022w08
Linux忘记MySQL密码后修改密码
Adjust the array order so that odd numbers precede even numbers (C language)
Elk - hearthbeat implements service monitoring
Deep learning and CV tutorial (14) | image segmentation (FCN, segnet, u-net, pspnet, deeplab, refinenet)
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