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主从的更多相关文章

  1. SaltStack部署redis主从

    需求: 一,部署redis主从,一台主一台从 二,redis监听自己的IP地址,而不是0.0.0.0 主:安装,配置,启动 从:安装,配置,启动,主从

  2. 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 ...

  3. SaltStack入门篇(六)之部署Redis主从实现和Job管理

    一.部署Redis主从 需求: 192.168.56.11是主,192.168.56.12是从 redis监听自己的ip地址,而不是0.0.0.0 分析: linux-node1 安装 配置 启动 l ...

  4. puppet工作原理及部署redis主从篇

    一.简介 1.国际惯例什么是puppet puppet是一种Linux.Unix.windows平台的集中配置管理系统,使用自有的puppet描述语言,可管理配置文件.用户.cron任务.软件包.系统 ...

  5. Redis系列之(二):Redis主从同步,读写分离

    1. Redis主从同步 Redis支持主从同步.数据可以从主服务器向任意数量的从服务器上同步,同步使用的是发布/订阅机制. 2. 配置主从同步 Mater Slave的模式,从Slave向Maste ...

  6. Redis 主从配置和参数详解

    安装redis 下载redis wget http://download.redis.io/releases/redis-3.0.7.tar.gz 解压redis tar -xvf redis-.ta ...

  7. 基于Windows服务器集群的Redis主从配置指南

    前段时间一个项目因并发量大.因防止宕机做了主从备份,首页的表连接查询又非常的耗时.故此拿出利器Redis缓存这个查询结果,并随着用户操作而更新. 因官方目前只有linux版,Windows版下载:  ...

  8. redis 主从同步

    修改redis.conf配置文件 vi redis.conf 在编辑模式下 输入  /slaveof 来搜索 将slaveof启用 即 将#删除 依次配置所有 slave 并将进程 kill 掉 重启 ...

  9. redis主从 以及认证配置

    以前用redis用的很多,各种数据类型用的飞起,算是用得很溜了.不过那都是封装好的方法,自己直接调用.以前的公司比较规范,开发只是开发,很少去做跟运维相关的事情. 换了一份工作,不过这边项目刚开始起步 ...

随机推荐

  1. Go单元测试与基准测试

    Go单元测试 Go单元测试框架,遵循规则整理如下: 1.文件命名规则: 含有单元测试代码的go文件必须以_test.go结尾,Go语言测试工具只认符合这个规则的文件 单元测试文件名_test.go前面 ...

  2. 协议 - DNS

    目录 1 DNS 1.1 域名解析的历史:/etc/hosts, DNS, FQDN 1.2 域名解析流程: 域名架构 查询流程, DNS端口 1.3 合法 DNS :申请域查询授权 1.4 主机名交 ...

  3. 学习python第十六天,正则表达式

    正则表达式是一个特殊的字符序列,它能帮助你方便的检查一个字符串是否与某种模式匹配.采取动态模糊的匹配,最大的应用是爬虫. re 模块使 Python 语言拥有全部的正则表达式功能. compile 函 ...

  4. Codeforces Round #460 (Div. 2): D. Substring(DAG+DP+判环)

    D. Substring time limit per test 3 seconds memory limit per test 256 megabytes input standard input ...

  5. [CodeChef]RIN(最小割)

    Description  有m门课可以在n个学期内学习,第i门课在第j个学期的收益是\(X_{i,j}\),一个学期可以学多门课,有的课之间有依赖关系,即必须先学a再学b,求最大收益.n,m<= ...

  6. 17-比赛1 D - IPC Trainers (贪心 + 优先队列)

    题目描述 本次印度编程训练营(Indian Programming Camp,IPC)共请到了 N 名教练.训练营的日程安排有 M 天,每天最多上一节课.第 i 名教练在第 Di 天到达,直到训练营结 ...

  7. 17-比赛1 A - Weak in the Middle (栈)

    题目描述 给定长度为 N 的序列 A.每天,序列 A 中所有比两侧元素都小的元素都会消失.对于原序列中所有元素,请求出它会在第几天之后消失(天数从 1 开始计算),或者指出它不会消失. 数据范围 1 ...

  8. Oozie 安装及 examples app 的使用

    参考文档 一.Building OOzie 特别注意的是修改Pom.xml文件中的版本与本机中安装的版本相同 二. install Oozie 1.为 hadoop 添加 Oozie 的代理用户,添加 ...

  9. 一步一步学Linq to sql(一):预备知识

    什么是Linq to sql Linq to sql(或者叫DLINQ)是LINQ(.NET语言集成查询)的一部分,全称基于关系数据的 .NET 语言集成查询,用于以对象形式管理关系数据,并提供了丰富 ...

  10. 4 CSS的20/80个知识点

    1.css的基本构成 样式选择器 id选择器 元素选择器 2.css的盒模型 border padding margin 3.Atom快捷键 4.程序 (1)初始程序 <!DOCTYPE htm ...