Redis安装,主从,主备切换

网络环境:

主:10.187.120.5

从:10.187.69.58

从:10.187.69.59


一.安装

mv redis-2.8.19.tar.gz /export/servers/

cd /export/servers/

tar zxf redis-2.8.19.tar.gz

cd redis-2.8.19

make && make install


二,主从环境搭建

主:10.187.120.5

conf/redis_6379.conf

(src/redis-server conf/redis_6379.conf)

daemonize yes
pidfile /export/Data/redis_pid/redis_6379.pid
port 6379
# tcp-backlog 511
timeout 300
tcp-keepalive 0
loglevel notice
logfile /export/Logs/redis/redis_6379.log
databases 16
stop-writes-on-bgsave-error yes
rdbcompression yes
dbfilename 6379.rdb
dir /export/Data/redis_data/6379
slave-serve-stale-data yes
slave-read-only yes
repl-disable-tcp-nodelay no
repl-backlog-size 128mb
maxmemory 2g
appendonly no
appendfilename 6379.aof
appendfsync everysec
no-appendfsync-on-rewrite no
auto-aof-rewrite-percentage 100
auto-aof-rewrite-min-size 64mb
lua-time-limit 5000
slowlog-log-slower-than 10000
slowlog-max-len 1024
# notify-keyspace-events ""
hash-max-ziplist-entries 512
hash-max-ziplist-value 64
list-max-ziplist-entries 512
list-max-ziplist-value 64
set-max-intset-entries 512
zset-max-ziplist-entries 128
zset-max-ziplist-value 64
# hll-sparse-max-bytes 3000
activerehashing yes
client-output-buffer-limit normal 0 0 0
client-output-buffer-limit slave 512mb 256mb 60
client-output-buffer-limit pubsub 32mb 8mb 60
hz 10
rename-command keys jkeys

从:10.187.69.58

conf/redis_6379.conf

(src/redis-server conf/redis_6379.conf)

daemonize yes
slaveof  10.187.120.5 6379
pidfile /export/Data/redis_pid/redis_6379.pid
port 6379
# tcp-backlog 511
timeout 300
tcp-keepalive 0
loglevel notice
logfile /export/Logs/redis/redis_6379.log
databases 16
stop-writes-on-bgsave-error yes
rdbcompression yes
dbfilename 6379.rdb
dir /export/Data/redis_data/6379
slave-serve-stale-data yes
slave-read-only yes
repl-disable-tcp-nodelay no
repl-backlog-size 128mb
maxmemory 2g
appendonly no
appendfilename 6379.aof
appendfsync everysec
no-appendfsync-on-rewrite no
auto-aof-rewrite-percentage 100
auto-aof-rewrite-min-size 64mb
lua-time-limit 5000
slowlog-log-slower-than 10000
slowlog-max-len 1024
# notify-keyspace-events ""
hash-max-ziplist-entries 512
hash-max-ziplist-value 64
list-max-ziplist-entries 512
list-max-ziplist-value 64
set-max-intset-entries 512
zset-max-ziplist-entries 128
zset-max-ziplist-value 64
# hll-sparse-max-bytes 3000
activerehashing yes
client-output-buffer-limit normal 0 0 0
client-output-buffer-limit slave 512mb 256mb 60
client-output-buffer-limit pubsub 32mb 8mb 60
hz 10
rename-command keys jkeys

从:10.187.69.59

conf/redis_6379.conf

(src/redis-server conf/redis_6379.conf)

daemonize yes
slaveof  10.187.120.5 6379
pidfile /export/Data/redis_pid/redis_6379.pid
port 6379
# tcp-backlog 511
timeout 300
tcp-keepalive 0
loglevel notice
logfile /export/Logs/redis/redis_6379.log
databases 16
stop-writes-on-bgsave-error yes
rdbcompression yes
dbfilename 6379.rdb
dir /export/Data/redis_data/6379
slave-serve-stale-data yes
slave-read-only yes
repl-disable-tcp-nodelay no
repl-backlog-size 128mb
maxmemory 2g
appendonly no
appendfilename 6379.aof
appendfsync everysec
no-appendfsync-on-rewrite no
auto-aof-rewrite-percentage 100
auto-aof-rewrite-min-size 64mb
lua-time-limit 5000
slowlog-log-slower-than 10000
slowlog-max-len 1024
# notify-keyspace-events ""
hash-max-ziplist-entries 512
hash-max-ziplist-value 64
list-max-ziplist-entries 512
list-max-ziplist-value 64
set-max-intset-entries 512
zset-max-ziplist-entries 128
zset-max-ziplist-value 64
# hll-sparse-max-bytes 3000
activerehashing yes
client-output-buffer-limit normal 0 0 0
client-output-buffer-limit slave 512mb 256mb 60
client-output-buffer-limit pubsub 32mb 8mb 60
hz 10
rename-command keys jkeys


三.主备切换

主:10.187.120.5

conf/sentinel_26379.conf

(src/redis-sentinel conf/sentinel_26379.conf)

port 26379
daemonize yes
sentinel monitor mymaster 10.187.120.5 6379 2
sentinel down-after-milliseconds mymaster 10000
sentinel failover-timeout mymaster 900000
#sentinel can-failover mymaster yes
sentinel config-epoch mymaster 0
# Generated by CONFIG REWRITE
dir "/export/servers/redis-2.8.19"
sentinel leader-epoch mymaster 0
sentinel known-slave mymaster 10.187.69.59 6379
sentinel known-slave mymaster 10.187.69.58 6379
#sentinel known-sentinel mymaster 10.187.69.59 26379 84ac24684dc485bc0c4bcf84a03d7cdb12d32ac9
#sentinel known-sentinel mymaster 10.187.69.58 26379 68da3e5c7d7da1ac1dfb542741bd89181fdda580
sentinel current-epoch 0

从:10.187.69.58

sentinel_26379.conf

(src/redis-sentinel conf/sentinel_26379.conf)

daemonize yes
port 26379
sentinel monitor mymaster 10.187.120.5 6379 2
sentinel down-after-milliseconds mymaster 10000
sentinel failover-timeout mymaster 900000
#sentinel can-failover mymaster yes
sentinel config-epoch mymaster 0
#Generated by CONFIG REWRITE
dir "/export/servers/redis-2.8.19"
sentinel leader-epoch mymaster 0
sentinel known-slave mymaster 10.187.69.58 6379
# Generated by CONFIG REWRITE
sentinel known-slave mymaster 10.187.69.59 6379
sentinel current-epoch 0

从:10.187.69.59

sentinel_26379.conf

(src/redis-sentinel conf/sentinel_26379.conf)

daemonize yes
port 26379
sentinel monitor mymaster 10.187.120.5 6379 2
sentinel down-after-milliseconds mymaster 10000
sentinel failover-timeout mymaster 900000
#sentinel can-failover mymaster yes
sentinel config-epoch mymaster 0
#Generated by CONFIG REWRITE
dir "/export/servers/redis-2.8.19"
sentinel leader-epoch mymaster 0
sentinel known-slave mymaster 10.187.69.58 6379
# Generated by CONFIG REWRITE
sentinel known-slave mymaster 10.187.69.58 6379
sentinel known-slave mymaster 10.187.69.59 6379
sentinel current-epoch 0
时间: 2024-10-09 15:39:07

Redis安装,主从,主备切换的相关文章

keepalived实现redis主备切换

试验目标: 1:主redis发生故障时,从redis自动切换为主redis. 2:主redis恢复正常后,自动降级为从redis. 试验环境: 主redis:192.168.189.138 从redis:192.168.189.131 VIP:192.168.189.123 主从redis均安装了keepalived与redis,redis已配置好主从.Redis端口44444. 1:制作redis监控与主备切换脚本: Redis监控脚本:(监控redis是否正常) # cat /usr/loc

测试redis+keepalived实现简单的主备切换

转自: 测试redis+keepalived实现简单的主备切换 - Try My Best 尽力而为 - ITeye技术网站http://raising.iteye.com/blog/2311757 keepalived是一个是集群管理中保证集群高可用的一个服务软件,它具备心跳检测的功能.运用在redis上,则是具备主备切换的控制功能. keepalived的主备切换方案的设计思想如下: 当 Master 与 Slave 均运作正常时, Master负责服务,Slave负责Standby: 当 

mysql主从配置&&基于keepalived的主备切换

mysql互为主从设置 && 主备切换配置 需求说明: 1.公司架构一直是一台单独的mysql在线上跑,虽然一直没有出现什么宕机事件,但是出于一个高可用的考虑,提出主从备份.主备切换的需求: 2.实现这个需求的前一段时间只是在做数据库备份的时候实现了主从热备,为了实现主备切换功能,继续操作上述需求: 实验环境: master1:10.1.156.3:3306 master2:10.1.156.5:3306 my.cnf配置文件关于主从这块的修改: master1: server-id =

Oracle11g搭建DataGuard及主备切换方法总结【亲测可用】

2019-04-11 分类:Oracle 阅读(2626) 评论(0) 文章目录[隐藏] 一.DataGuard 工作原理 二.搭建环境 三.主库配置 四.备库配置 五.主备切换 一.DataGuard 工作原理 Data Gurad 通过冗余数据来提供数据保护,Data Gurad 通过日志同步机制保证冗余数据和主数之前的同步,这种同步可以是实时,延时,同步,异步多种形式.Data Gurad 常用于异地容灾和小企业的高可用性方案,虽然可以在Standby 机器上执行只读查询,从而分散Prim

DRBD主备切换

DRBD主备切换 在系统维护的时候,或者在高可用群集中,当主用节点出现故障的时候,就需要将主备节点的角色互换,主备节点切换有两种形式,分别是停止DRBD服务切换和正常切换 (1) 停止DRBD服务切换 关闭主用节点服务,此时挂载的DRBD分区就自动在主用节点卸载了,操作如下, /etc/init.d/drbd stop cat /proc/drbd (细节请看http://liumingyuan.blog.51cto.com/9065923/1712824) 从输出结果可以看到,现在主用节点的状

Nginx+Keepalived主备切换(包含nginx服务停止)

原文地址:http://blog.sina.com.cn/s/blog_79ac6aa80101bmed.html Nginx+Keepalived主备切换(包含nginx服务停止) 环境: VM中4台CentOS 本机PC充当测试机win8 步骤: 1.搭建 nginx+keepalived主备切换(不考虑主nginx停掉现象)文章中的环境 2.修改两台部署的keepalived的配置文件 3.编写观察nginx进程情况的脚本内容 #!/bin/bash A=`ps -C nginx --no

主备切换,双机热备,负载均衡,nginx

MySQL主备切换 数据库由主服务器和备份服务器组成,主备同时运行,主服务器有数据改动后,立刻会同步到备份服务器.在日常运维中,为了防患未然,切换的操作只需要将连接池中数据库服务器的IP换成备份服务器的IP就可以了.Nginx高性能的http和反向代理服务,能实现主备切换工作. 双机热备 双机热备特指基于高可用系统中的两台服务器的热备(或高可用),因两机高可用在国内使用较多,故得名双机热备,双机高可用按工作中的切换方式分为:主-备 方式(Active-Standby方式)和双主机方式(Activ

Spark系列(五)Master主备切换机制

Spark Master主备切换主要有两种机制,之中是基于文件系统,一种是基于Zookeeper.基于文件系统的主备切换机制需要在Active Master挂掉后手动切换到Standby Master上,而基于Zookeeper的主备切换机制可以实现自动切换Master. 切换流程图 流程说明: Standby Master模式 1. 使用持久化引擎读取持久化的storeApps.storeDrivers.storeWorkers,持久化引擎有FileSystemPersistenceEngin

Oracle 11.2.0.4.0 Dataguard部署和日常维护(5)-Datauard 主备切换和故障转移篇

1. dataguard主备切换 1.1. 查看当前主备库是否具备切换条件 on slave select sequence#,first_time,next_time,archived,applied from v$archived_log where SEQUENCE#=(select max(SEQUENCE#) from v$archived_log); SEQUENCE# FIRST_TIME NEXT_TIME ARCHIVED APPLIED ---------- --------