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. 网络基础-交换机、路由器、OSI7层模型

    第1章 网络基础 1.1 网络的诞生 网络的诞生使命:通过各种互联网服务提升全球人类生活品质. 让人类的生活更便捷和丰富,从而促进全球人类社会的进步.并且丰富人类的精神世界和物质世界,让人类最便捷地获 ...

  2. Python文件IO(普通文件读写)

    ## 打开一个文件 - fileobj = open(filename, mode) 其中: fileobj是open()返回的文件对象 filename是该文件的字符串名 mode是指明文件类型和操 ...

  3. 虚拟机桥接模式下多台Ubuntu16.04系统互相连接

    1.首先新建一个虚拟机并在该虚拟机上安装Ubuntu16.04系统.为这台虚拟机起名为Ubuntu3. 2.对Ubuntu3进行克隆,为新克隆生成的虚拟机起名为Ubuntu2.(这时我们会发现Ubun ...

  4. .c和.h区别

    本质没有区别: .h是头文件 一般情况下下边内容放在.h文件中 宏定义 结构体,联合,枚举声明 typedef声明 外部函数声明 全局变量声明 .c是程序文件 一般情况下下边内容放在.h文件中 内含函 ...

  5. C语言结构体篇 结构体

    在描述一个物体的属性的时候,单一的变量类型是无法完全描述完全的.所以有了灵活的结构体变量. 结构体变量从意义上来讲是不同数据类型的组合,从内存上来讲是在一个空间内进行不同的大小划分. 1.1 结构体类 ...

  6. Pandas 文本数据

    Pandas针对字符串配备的一套方法,使其易于对数组的每个元素(字符串)进行操作. 1.通过str访问,且自动排除丢失/ NA值 # 通过str访问,且自动排除丢失/ NA值 s = pd.Serie ...

  7. fromkeys语法/set集合/深浅拷贝/列表/字典的删除

    fromkeys语法: dic = {"apple":"苹果", "banana":"香蕉"} 返回新字典. 和原来的没 ...

  8. android的dmtracedump工具生成trace文件图片 'dot' 不是内部或外部命令,也不是可运行的程序 或批处理文件。

    http://jingyan.baidu.com/article/c910274bfa6c1fcd361d2df7.html http://www.cnblogs.com/albert1017/p/3 ...

  9. pycharm的使用二

    一.pycharm设置参数 设置传入程序的参数:Alt+shift+F10 → Edit Configurations → 选中所需要进行设置参数的脚本 → Script parameters:输入设 ...

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

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