首页 > 其他分享 >SaltStack 七

SaltStack 七

时间:2022-11-25 12:02:32浏览次数:38  
标签:file redis Redis master conf ---------- SaltStack


# salt Redis部署

/srv/salt/prod/
├── modules
│ ├── apache
│ ├── haproxy
│ ├── keepalived
│ ├── mysql
│ └── redis
│ └── redis-install.sls
└── redis-cluster
├── files
│ └── redis-master.conf
└── redis-master.sls


1. vim redis-install.sls
redis-install:
pkg.installed:
- name: redis
2. redis-master.sls
include:
- modules.redis.redis-install

redis-master-config:
file.managed:
- name: /etc/redis.conf
- source: salt://redis-cluster/files/redis-master.conf
- user: root
- group: root
- mode: 644
- template: jinja
- defaults:
REDIS_MEM: 100M

redis-master-service:
service.running:
- name: redis
- enable: True
- watch:
- file: redis-master-config

3. salt '*' state.sls redis-cluster.redis-master saltenv=prod # 默认 base环境
# 执行效果如下:
#---------------------------------------------------------------------------
192.168.2.102:
----------
ID: redis-install
Function: pkg.installed
Name: redis
Result: None
Comment: The following packages are set to be installed/updated: redis
Started: 00:33:34.239727
Duration: 1015.057 ms
Changes:
----------
ID: redis-master-config
Function: file.managed
Name: /etc/redis.conf
Result: None
Comment: The file /etc/redis.conf is set to be changed
Started: 00:33:35.257619
Duration: 288.224 ms
Changes:
----------
newfile:
/etc/redis.conf
----------
ID: redis-master-service
Function: service.running
Name: redis
Result: None
Comment: Service is set to be started
Started: 00:33:35.601150
Duration: 226.642 ms
Changes:

Summary
------------
Succeeded: 3 (unchanged=3, changed=1)
Failed: 0
------------
Total states run: 3
192.168.2.104:
----------
ID: redis-install
Function: pkg.installed
Name: redis
Result: True
Comment: Package redis is already installed.
Started: 06:20:39.511771
Duration: 999.409 ms
Changes:
----------
ID: redis-master-config
Function: file.managed
Name: /etc/redis.conf
Result: None
Comment: The file /etc/redis.conf is set to be changed
Started: 06:20:40.513646
Duration: 299.917 ms
Changes:
----------
diff:
---
+++
@@ -58,7 +58,7 @@
# IF YOU ARE SURE YOU WANT YOUR INSTANCE TO LISTEN TO ALL THE INTERFACES
# JUST COMMENT THE FOLLOWING LINE.
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-bind 127.0.0.1
+bind 0.0.0.0

# Protected mode is a layer of security protection, in order to avoid that
# Redis instances left open on the internet are accessed and exploited.
@@ -125,7 +125,7 @@

# By default Redis does not run as a daemon. Use 'yes' if you need it.
# Note that Redis will write a pid file in /var/run/redis.pid when daemonized.
-daemonize no
+daemonize yes

# If you run Redis from upstart or systemd, Redis can interact with your
# supervision tree. Options:
@@ -534,7 +534,7 @@
# limit for maxmemory so that there is some free RAM on the system for slave
# output buffers (but this is not needed if the policy is 'noeviction').
#
-# maxmemory <bytes>
+ maxmemory 100M

# MAXMEMORY POLICY: how Redis will select what to remove when maxmemory
# is reached. You can select among five behaviors:
mode:
0644
user:
root
----------
ID: redis-master-service
Function: service.running
Name: redis
Result: None
Comment: Service is set to be started
Started: 06:20:41.150092
Duration: 239.849 ms
Changes:

Summary
------------
Succeeded: 3 (unchanged=2, changed=1)
Failed: 0
------------
Total states run: 3
#---------------------------------------------------------------------------

标签:file,redis,Redis,master,conf,----------,SaltStack
From: https://blog.51cto.com/u_13940603/5886230

相关文章

  • SaltStack 六
    #salt本地管理无master架构#file_client:remote#将remote改为localsalt-call--localstate.slsweb.tomcat#zabbix-agent案例/srv/salt/├──base#......
  • SaltStack 五
    #salt的生产实践不推荐使用file目录模块模块进行代码部署不建议salt管理项目的配置文件,建议分层管理,salt只管理应用服务若有固定的文件服务器,可以使用source:......
  • SaltStack 四
    #Apache监听本地IP地址结合jinjia模板变量使用Grains:{{grains['fqdn_ip4'][0]}}变量使用执行模块:{{salt['network.hw_addr']('eth0')}}变量使用Pillar:{{pil......
  • SaltStack 三
    #salt数据系统:Grains&Pillar#Minion启动时收集(静态数据)#grains应用场景:grains可以再salt系统中用于配置管理模块Grains可以以target中使用,用来匹配Minion......
  • SaltStack 二
    #Tomcat安装管理1.vimtomcat.slsjdk-install:pkg.installed:-name:java-1.8.0-openjdktomcat-install:file.managed:-name:/usr/local/src/apache-tomc......
  • saltstack服务端与客户端通信问题处理
    jenkins发布报错:ERROR:NoreturnreceivedNominionsmatchedthetarget.Nocommandwassent,nojidwasassigned.saltstack分为服务端master与客户端minion配置文......