Redis 哨兵

Redis Sentinel 物理结构

角色ipport别名
master127.0.0.16379主节点
slave1127.0.0.16380从节点1
slave2127.0.0.16381从节点2
sentinel1127.0.0.16382Sentinel节点1
sentinel2127.0.0.16383Sentinel节点2

master节点

port 6379
daemonize yes
logfile "6379.log"
dbfilename dump.rdb
dir /usr/local/var/db/redis/
➜  bin ./redis-server myredisconf/redis-6379.conf&
# 校验是否启动成功
➜  bin ./redis-cli -h 127.0.0.1 -p 6379 ping

slave1节点

port 6380
daemonize yes
logfile "6380.log"
dbfilename dump.rdb
dir /usr/local/var/db/redis/
slaveof 127.0.0.1 6379

slave1节点

port 6381
daemonize yes
logfile "6381.log"
dbfilename dump.rdb
dir /usr/local/var/db/redis/
slaveof 127.0.0.1 6379

启动从节点

➜  bin ./redis-server myredisconf/redis-6380.conf&
➜  bin ./redis-server myredisconf/redis-6381.conf&

主节点配置信息

➜  bin ./redis-cli -h 127.0.0.1 -p 6379 info replication
# Replication
role:master
connected_slaves:2
slave0:ip=127.0.0.1,port=6380,state=online,offset=280,lag=1
slave1:ip=127.0.0.1,port=6381,state=online,offset=280,lag=1
master_replid:70d5bbe7ee9201d195fb8a743a686b12f35c1fea
master_replid2:0000000000000000000000000000000000000000
master_repl_offset:280
second_repl_offset:-1
repl_backlog_active:1
repl_backlog_size:1048576
repl_backlog_first_byte_offset:1
repl_backlog_histlen:280

从节点配置信息

➜  bin ./redis-cli -h 127.0.0.1 -p 6381 info replication
# Replication
role:slave
master_host:127.0.0.1
master_port:6379
master_link_status:up
master_last_io_seconds_ago:4
master_sync_in_progress:0
slave_repl_offset:182
slave_priority:100
slave_read_only:1
connected_slaves:0
master_replid:70d5bbe7ee9201d195fb8a743a686b12f35c1fea
master_replid2:0000000000000000000000000000000000000000
master_repl_offset:182
second_repl_offset:-1
repl_backlog_active:1
repl_backlog_size:1048576
repl_backlog_first_byte_offset:1
repl_backlog_histlen:182

哨兵节点配置

port 6382
daemonize yes
logfile "6382.log"
dir /usr/local/var/db/redis/
sentinel monitor mymaster 127.0.0.1 6379 2
sentinel down-after-milliseconds mymaster 3000
sentinel parallel-syncs mymaster 1
sentinel failover-timeout mymaster 180000

启动哨兵节点

➜  bin redis-sentinel myredisconf/redis-6382.conf&

哨兵配置信息

➜  bin ./redis-cli -h 127.0.0.1 -p 6382 info Sentinel
# Sentinel
sentinel_masters:1
sentinel_tilt:0
sentinel_running_scripts:0
sentinel_scripts_queue_length:0
sentinel_simulate_failure_flags:0
master0:name=mymaster,status=ok,address=127.0.0.1:6379,slaves=2,sentinels=1
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值