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用的很多,各种数据类型用的飞起,算是用得很溜了.不过那都是封装好的方法,自己直接调用.以前的公司比较规范,开发只是开发,很少去做跟运维相关的事情. 换了一份工作,不过这边项目刚开始起步 ...
随机推荐
- 【版本控制——svn】
reposity_name //版本库 { Passwd //验证密码文件 Authz //权限控制 Server.conf //主配置 } Authz //权限控制 //由[groups]标签控 ...
- JavaScript通过HTML的class来获取HTML元素的方法总结
对于js来说,我想每一个刚接触它的人都应该会抱怨:为什么没有一个通过class来获取元素的方法.尽管现在高版本的浏览器已经支持getElementsByClassName()函数,但是对于低版本浏览器 ...
- Java 算法随笔(一)
1. 最大子序列和问题 给定(可能有负数)整数a(1).a(2).……a(n),求 a(1)+a(2)+……+a(j)的最大值. 也就是:在一系列整数中,找出连续的若干个整数,这若干个整数之和最大.有 ...
- C++基础 new和delete
1.new delete 的使用 (1)基本数据类型 ); delete p; int *p = (int *)malloc(sizeof(int)); *p = ;free(p); (2)数组 ]; ...
- poj 3087 直接模拟
题意:意思就是,s1,和s2两堆牌,然后先s2一张再s1,最后会出现一个s12序列,例如s1 AHAH S2 HAHA 然后s12为HAAHHAAH,然后前面一部分给s1,后面一部分给s2,然后再重复 ...
- 零基础~仿qq登录界面
html代码: <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <t ...
- python re模块实现计算器
def mul_div(exp): #计算乘除 while True: ret = re.search('[\d\.]+[\*\/]-?[\d\.]+', exp) if ret: atom_exp ...
- Kafka消费分组和分区分配策略
Kafka消费分组,消息消费原理 同一个消费组里的消费者不能消费同一个分区,不同消费组的消费组可以消费同一个分区 Kafka分区分配策略 在 Kafka 内部存在两种默认的分区分配策略:Range 和 ...
- 常用正则表达式 -- 费元星 java大神
正则表达式用于字符串处理.表单验证等场合,实用高效.现将一些常用的表达式收集于此,以备不时之需. 匹配中文字符的正则表达式: [\u4e00-\u9fa5]评注:匹配中文还真是个头疼的事,有了这个表达 ...
- 网页图片很多时,加载完后再加载图片(defer:延迟加载)
图片影响页面加载速度,可以先加载完页面,再去加载图片. defer:告诉浏览器,这里面的js代码不影响网页脚本解析,可以解析完html脚本再执行这段js代码(个人理解). 网页代码:<img s ...