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. linux特殊权限位suid

    特殊权限位基本说明(了解): linux系统基本权限位为9位权限,但还有额外3位权限位,共12位权限: suid       s(x)     S     4     用户对应的权限位(用户对应的3位 ...

  2. python安装教程(面向对象的解释型计算机程序设计语言)

    inux下默认自带的.包括mac,是python2.x 但咱们玩的最新的  python3.x  怎么办呢centos下安装方法:  sudo yum install epel- sudo yum i ...

  3. 判断移动端和pc端最简单的方法

    <!DOCTYPE html><html><head> <title></title> <script type="text ...

  4. GMT 时间格式转换到 TDateTime (Delphi)

    //GMT 时间格式转换到 TDateTime //忽略时区 function GMT2DateTime(const pSour:PAnsiChar):TDateTime; function GetM ...

  5. python系列4之装饰器

    目录 递归算法解析 冒泡排序解析 装饰器解析 一. 递归 1. 递归的定义 递归(Recursion),又成为递回,在数学与计算机科学中,是指在函数的定义中使用函数自身的方法.递归一词还较长用于描述以 ...

  6. java8之list集合中取出某一属性的方法

    上代码 List<User> list = new ArrayList<User>(); User user1 = new User("第一位"," ...

  7. P1282

    题目描述 多米诺骨牌有上下2个方块组成,每个方块中有1~6个点.现有排成行的 上方块中点数之和记为S1,下方块中点数之和记为S2,它们的差为|S1-S2|.例如在图8-1中,S1=6+1+1+1=9, ...

  8. setBackgroundResource和setImageResource的区别

    setBackgroundResource是设置view的背景图片 setImageResource是设置ImageView的图片 对于一个imagevewButton来说,你既可以setBackgr ...

  9. 获取<考试>博文密码!o(*≧▽≦)ツ

    就是CJ高二组通用的密码 如果你想知道,请联系QQ,3057244225,或者直接面对面问博主(...) 是我们的内部材料,原创题目是不能外传的.请谅解. 当然如果是原题的话我们是不会上锁的啦

  10. 使用Windows SFC和DISM工具来解决服务器OS问题

    TechTarget中国原创] 随着使用时间的越来越多,Windows服务器安装的系统文件可能会被损坏或损毁.管理员一般可以通过系统自带的System File Checker (SFC) 或者更健壮 ...