# 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
#---------------------------------------------------------------------------
SaltStack 七
原创
©著作权归作者所有:来自51CTO博客作者大宝天天用的原创作品,请联系作者获取转载授权,否则将追究法律责任
上一篇:SaltStack 九
下一篇:SaltStack 六
提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章
-
java 通用异步记录日志工具类
日志功能本来是一件非常好的事情,能帮助我们分析和解决很多问题。但是,如果让日志影响到性能,这就需要权衡一下了。没关系,本篇博客咱们不仅来解决这个问题,咱们更要眼见为实,带图带真相让你用的明明白白。日志实现异步功能 其实呢就一句话。
java 通用异步记录日志工具类 NLog 日志框架 异步 数据库