redis主従配置と哨兵モード
4390 ワード
マスタスレーブ構成
redis.conf redis-6379.conf。 :
bind 0.0.0.0
#
daemonize yes
#pid
pidfile /var/run/redis_6379.pid
#
logfile "6379.log"
redis-server redis-6379.conf
redis.conf redis-6380.conf。 :
bind 0.0.0.0
port 6380
daemonize yes
pidfile /var/run/redis_6380.pid
logfile "6380.log"
#slaveof
slaveof 127.0.0.1 6379
#
slave-read-only yes
#
masterauth
redis-server redis-6380.conf
- redis-cli -p 6379 info replication
role:master
connected_slaves:1
slave0:ip=127.0.0.1,port=6380,state=online,offset=1183,lag=0
master_replid:32125185597f85a2155d187ccd57168cf6681395
master_replid2:0000000000000000000000000000000000000000
master_repl_offset:1183
second_repl_offset:-1
repl_backlog_active:1
repl_backlog_size:1048576
repl_backlog_first_byte_offset:1
repl_backlog_histlen:1183
-
role:slave
master_host:127.0.0.1
master_port:6379
master_link_status:up
master_last_io_seconds_ago:0
master_sync_in_progress:0
slave_repl_offset:1239
slave_priority:100
slave_read_only:1
connected_slaves:0
master_replid:32125185597f85a2155d187ccd57168cf6681395
master_replid2:0000000000000000000000000000000000000000
master_repl_offset:1239
second_repl_offset:-1
repl_backlog_active:1
repl_backlog_size:1048576
repl_backlog_first_byte_offset:1
repl_backlog_histlen:1239
-
./redis-cli -p 6379 set a aaa
OK
./redis-cli -p 6380 get a
"aaa"
歩哨モード
1. sentinel master
2. sentinel
3. slave master
4. slave master slave
5.
6. master master slave
port 26379
daemonize yes
# sentinel announce-ip
# sentinel announce-port
dir /opt/redis-4.0.11/data
sentinel monitor mymaster 127.0.0.1 6379 2
# sentinel auth-pass
sentinel down-after-milliseconds mymaster 30000
sentinel parallel-syncs mymaster 1
sentinel failover-timeout mymaster 180000
# sentinel notification-script
- port : Sentinel
- dir : Sentinel
3.sentinel monitor master001 192.168.110.10163792:Sentinel master001 redis , IP 192.168.110.101, 6379, 2 Sentinel , Sentinel , failover
4.sentinel down-after-milliseconds master001 30000: Sentinel Redis 。 PING, , Sentinel 。 Sentinel : Sentinel , ,
5.sentinel parallel-syncs master001 1: , Redis , Redis , ,
6.sentinel failover-timeout master001 180000: (ms) failover , failover
7.sentinel notification-script : sentinel redis , 。 ,
(1) 10s sentinel master slave info slave , , redis-Sentinel master , slave
(2) ,sentinel master channel ( )
master Sentinel master
(3) sentinel redis (master,slave,sentinel) ping , master 30s , master Sentinel
1.
: sentenel 。
:
1). sentinel sentinel , 。
2). sentinel sentinel ( ), , 。
3). sentinel quorum , 。
4). sentinel , 。
2. master
redis sentinel slave master, , slave ? :
1). slave-priority slave ( )。
2). 。
3). , runId ( )。
3. slave master
master , master slave , master , master slave 。
4.
,sentinel 。
5. master
, master 。