saltstack 实现redis主从
centos7.4
172.16.80.5 redis 主
172.16.80.6 redis 从
目录结构如下
file_roots:
base:
- /srv/salt/base
dev:
- /srv/salt/dev
test:
- /srv/salt/test
prod:
- /srv/salt/prod
[root@zabbix redis]# vim /srv/salt/base/top.sls
[root@zabbix redis]# cat redis.sls
redis-install:
pkg.installed:
- name: redis redis-config:
file.managed:
- name: /etc/redis.conf
- source: salt://redis/files/redis.conf
- user: root
- group: root
- mode: 644
- template: jinja
- defaults:
IPADDR: {{ grains['fqdn_ip4'][] }}
PORT: redis-service:
service.running:
- name: redis
- enable: True
- reload: True [root@zabbix redis]# cat master.sls
include:
- redis.redis
[root@zabbix redis]# cat slave.sls
include:
- redis.redis slave_config:
cmd.run:
- name: redis-cli -h 172.16.80.6 slaveof 172.16.80.5
- unless: redis-cli -h 172.16.80.6 info|grep role:slave
- require:
- service: redis-service
Vim files/redis.conf 修改如下配置文件
bind {{ IPADDR }}
port {{ PORT }}
daemonize yes
[root@zabbix redis]# salt '*' state.highstate
zabbix:
----------
ID: redis-install
Function: pkg.installed
Name: redis
Result: True
Comment: The following packages were installed/updated: redis
Started: ::42.414507
Duration: 20238.065 ms
Changes:
----------
redis:
----------
new:
3.2.-.el7
old:
----------
ID: redis-config
Function: file.managed
Name: /etc/redis.conf
Result: True
Comment: File /etc/redis.conf updated
Started: ::02.743576
Duration: 421.028 ms
Changes:
----------
diff:
---
+++
@@ -, +, @@
# Examples:
#
# bind 192.168.1.100 10.0.0.1
-# bind 127.0.0.1 ::
+bind 172.16.80.5
#
# ~~~ WARNING ~~~ If the computer running Redis is directly exposed to the
# internet, binding to all the interfaces is dangerous and will expose the
@@ -, +, @@
# IF YOU ARE SURE YOU WANT YOUR INSTANCE TO LISTEN TO ALL THE INTERFACES
# JUST COMMENT THE FOLLOWING LINE.
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-bind 127.0.0.1 # Protected mode is a layer of security protection, in order to avoid that
# Redis instances left open on the internet are accessed and exploited.
@@ -, +, @@ # 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:
mode: user:
root
----------
ID: redis-service
Function: service.running
Name: redis
Result: True
Comment: Service redis has been enabled, and is running
Started: ::04.982412
Duration: 174.844 ms
Changes:
----------
redis:
True Summary for zabbix
------------
Succeeded: (changed=)
Failed:
------------
Total states run:
Total run time: 20.834 s
k8s-node1:
----------
ID: redis-install
Function: pkg.installed
Name: redis
Result: True
Comment: The following packages were installed/updated: redis
Started: ::41.350432
Duration: 47371.887 ms
Changes:
----------
redis:
----------
new:
3.2.-.el7
old:
----------
ID: redis-config
Function: file.managed
Name: /etc/redis.conf
Result: True
Comment: File /etc/redis.conf updated
Started: ::28.751141
Duration: 179.74 ms
Changes:
----------
diff:
---
+++
@@ -, +, @@
# Examples:
#
# bind 192.168.1.100 10.0.0.1
-# bind 127.0.0.1 ::
+bind 172.16.80.6
#
# ~~~ WARNING ~~~ If the computer running Redis is directly exposed to the
# internet, binding to all the interfaces is dangerous and will expose the
@@ -, +, @@
# IF YOU ARE SURE YOU WANT YOUR INSTANCE TO LISTEN TO ALL THE INTERFACES
# JUST COMMENT THE FOLLOWING LINE.
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-bind 127.0.0.1 # Protected mode is a layer of security protection, in order to avoid that
# Redis instances left open on the internet are accessed and exploited.
@@ -, +, @@ # 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:
mode: user:
root
----------
ID: redis-service
Function: service.running
Name: redis
Result: True
Comment: Service redis has been enabled, and is running
Started: ::29.930887
Duration: 147.004 ms
Changes:
----------
redis:
True
----------
ID: slave_config
Function: cmd.run
Name: redis-cli -h 172.16.80.6 slaveof 172.16.80.5
Result: True
Comment: Command "redis-cli -h 172.16.80.6 slaveof 172.16.80.5 6379" run
Started: ::30.079706
Duration: 33.352 ms
Changes:
----------
pid: retcode: stderr:
stdout:
OK Summary for k8s-node1
------------
Succeeded: (changed=)
Failed:
------------
Total states run:
Total run time: 47.732 s
验证结果
saltstack 实现redis主从的更多相关文章
- SaltStack部署redis主从
需求: 一,部署redis主从,一台主一台从 二,redis监听自己的IP地址,而不是0.0.0.0 主:安装,配置,启动 从:安装,配置,启动,主从
- 5 LAMP配置管理:模块(state、file、pkg、service)、jinja模板、job管理、redis主从
1. 配置管理:state和file https://docs.saltstack.com/en/latest/topics/states/index.html Full list of states ...
- SaltStack入门篇(六)之部署Redis主从实现和Job管理
一.部署Redis主从 需求: 192.168.56.11是主,192.168.56.12是从 redis监听自己的ip地址,而不是0.0.0.0 分析: linux-node1 安装 配置 启动 l ...
- puppet工作原理及部署redis主从篇
一.简介 1.国际惯例什么是puppet puppet是一种Linux.Unix.windows平台的集中配置管理系统,使用自有的puppet描述语言,可管理配置文件.用户.cron任务.软件包.系统 ...
- Redis系列之(二):Redis主从同步,读写分离
1. Redis主从同步 Redis支持主从同步.数据可以从主服务器向任意数量的从服务器上同步,同步使用的是发布/订阅机制. 2. 配置主从同步 Mater Slave的模式,从Slave向Maste ...
- Redis 主从配置和参数详解
安装redis 下载redis wget http://download.redis.io/releases/redis-3.0.7.tar.gz 解压redis tar -xvf redis-.ta ...
- 基于Windows服务器集群的Redis主从配置指南
前段时间一个项目因并发量大.因防止宕机做了主从备份,首页的表连接查询又非常的耗时.故此拿出利器Redis缓存这个查询结果,并随着用户操作而更新. 因官方目前只有linux版,Windows版下载: ...
- redis 主从同步
修改redis.conf配置文件 vi redis.conf 在编辑模式下 输入 /slaveof 来搜索 将slaveof启用 即 将#删除 依次配置所有 slave 并将进程 kill 掉 重启 ...
- redis主从 以及认证配置
以前用redis用的很多,各种数据类型用的飞起,算是用得很溜了.不过那都是封装好的方法,自己直接调用.以前的公司比较规范,开发只是开发,很少去做跟运维相关的事情. 换了一份工作,不过这边项目刚开始起步 ...
随机推荐
- Java数据处理
对于形如“(TYPE=SITA##)&&(((CTYP=FPL##)||(CTYP=CHG##)||(CTYP=CNL##)||(CTYP=DLA##)||(CTYP=DL##)||( ...
- ajax原生js及readystate/status
菜鸟教程 ←← GET: <script> function ajaxGet(){ var xmlhttp; if(window.XMLHttpRequest){ //TE7+ Fi ...
- yii2 的登录注册 轮子
//利用到了yii2 框架之中的验证规则 进行判定而已 也不是很高深的东西 但是 使用框架自身的轮子 会有安全性能的隐患 1注册reg controller 中 我都以admin 为例子 publi ...
- [Uva11178]Morley's Theorem(计算几何)
Description 题目链接 Solution 计算几何入门题 只要求出三角形DEF的一个点就能推出其他两个点 把一条边往内旋转a/3度得到一条射线,再做一条交点就是了 Code #include ...
- 【文件处理】xml 文件 DOM解析
一.Java解析xml.解析xml四种方法.DOM.SAX.JDOM.DOM4j.XPath 此文针对其中的DOM方法具体展开介绍及代码分析 sax.dom是两种对xml文档进行解析的方法(没有具体实 ...
- CSS3 Shape ---使用形状改变旁边内容的布局
注意 本文所实现的功能,在浏览器的支持上并不好,除chrome浏览器外其余的大部分浏览器均不支持,虽然可以使用polyfill解决,但也不能很好的支持,有时也会出错 polyfill使用方法 下载po ...
- CentOS 7.X 防火墙简单配置
CentOS7使用的是Linux Kernel 3.10.0的内核版本,新版的Kernel内核已经有了防火墙netfilter,并且使用效能更高,稳定性更好. 配置防火墙的两种方法: 一.使用xml配 ...
- 为什么工具类App,都要做一个社区?
非著名程序员涩郎 非著名程序员,字耿左直右,号涩郎,爱搞机,爱编程,是爬行在移动互联网中的一名码匠!个人微信号:loonggg,微博:涩郎,专注于移动互联网的开发和研究,本号致力于分享IT技术和程序猿 ...
- 使用系统的某些block api(如UIView的block版本写动画时),是否也考虑循环引用问题?
系统的某些block api中,UIView的block版本写动画时不需要考虑,但也有一些api 需要考虑 以下这些使用方式不会引起循环引用的问题 [UIView animateWithDuratio ...
- linux备忘录-档案与文件系统的压缩与打包
知识点 文件扩展名与压缩解压缩工具 .Z -> compress程序压缩的档案 .gz -> gzip程序压缩的档案 .bz2 -> bzip2程序压缩的档案 .tar -> ...