欧美一级特黄大片做受成人-亚洲成人一区二区电影-激情熟女一区二区三区-日韩专区欧美专区国产专区

redis演練(7)redisSentinel實現(xiàn)故障轉(zhuǎn)移-創(chuàng)新互聯(lián)

書接上文<redis演練(6) redis主從模式搭建>.

<redis演練(6) redis主從模式搭建>中僅僅配置了redis主從環(huán)境。分別配置了2個主從結(jié)構(gòu)。

創(chuàng)新互聯(lián)建站是專業(yè)的武清網(wǎng)站建設(shè)公司,武清接單;提供做網(wǎng)站、網(wǎng)站制作,網(wǎng)頁設(shè)計,網(wǎng)站設(shè)計,建網(wǎng)站,PHP網(wǎng)站建設(shè)等專業(yè)做網(wǎng)站服務(wù);采用PHP框架,可快速的進行武清網(wǎng)站開發(fā)網(wǎng)頁制作和功能擴展;專業(yè)做搜索引擎喜愛的網(wǎng)站,專業(yè)的做網(wǎng)站團隊,希望更多企業(yè)前來合作!

分別是1.有向無環(huán),2星型模型。配置起來非常簡單。但是,遺留了一個尾巴,沒有闡述。如果master宕掉了怎么辦?redis如何實現(xiàn)fail-over故障轉(zhuǎn)移?本文,就重點說一下這塊。主要內(nèi)容

  1. 手動實現(xiàn)fail-over效果

  2. sentinel實現(xiàn)自動fail-over效果

手動實現(xiàn)fail-over效果

#有向無環(huán)模型(參照redis演練(6) redis主從模式搭建內(nèi)容)
[root@hadoop2 redis]# ps -ef |grep redis
root      2495     1  2 20:06 ?        00:00:01 bin/redis-server *:6379
root      2503     1  1 20:06 ?        00:00:00 bin/redis-server *:6381
root      2508     1  1 20:06 ?        00:00:00 bin/redis-server *:6380

#Master(有一個從6380)
127.0.0.1:6379> info Replication
# Replication
role:master
connected_slaves:1
slave0:ip=127.0.0.1,port=6380,state=online,offset=99,lag=1
master_repl_offset:99
repl_backlog_active:1
repl_backlog_size:1048576
repl_backlog_first_byte_offset:2
repl_backlog_histlen:98


#Slave1 連接主6379
127.0.0.1:6380> info Replication
# Replication
role:slave
master_host:127.0.0.1
master_port:6379
master_link_status:up
master_last_io_seconds_ago:5
master_sync_in_progress:0
slave_repl_offset:197
slave_priority:100
slave_read_only:1
connected_slaves:1
slave0:ip=127.0.0.1,port=6381,state=online,offset=197,lag=0
master_repl_offset:197
repl_backlog_active:1
repl_backlog_size:1048576
repl_backlog_first_byte_offset:2
repl_backlog_histlen:196

#6380的從
127.0.0.1:6381> info Replication
# Replication
role:slave
master_host:127.0.0.1
master_port:6380
master_link_status:up
master_last_io_seconds_ago:6
master_sync_in_progress:0
slave_repl_offset:573
slave_priority:100
slave_read_only:1
connected_slaves:0
master_repl_offset:0
repl_backlog_active:0
repl_backlog_size:1048576
repl_backlog_first_byte_offset:0
repl_backlog_histlen:0

####################################
模擬6379 宕機
#####################################
[root@hadoop2 redis]# bin/redis-cli shutdown
[root@hadoop2 redis]# bin/redis-cli -p 6379 shutdown
Could not connect to Redis at 127.0.0.1:6379: Connection refused
#觀察,發(fā)現(xiàn)master_link_status:down,表示主一定宕掉了
127.0.0.1:6380> info  Replication
# Replication
role:slave
master_host:127.0.0.1
master_port:6379
master_link_status:down
master_last_io_seconds_ago:-1
master_sync_in_progress:0
slave_repl_offset:1049
master_link_down_since_seconds:42
slave_priority:100
slave_read_only:1
connected_slaves:1
slave0:ip=127.0.0.1,port=6381,state=online,offset=1105,lag=0
master_repl_offset:1105
repl_backlog_active:1
repl_backlog_size:1048576
repl_backlog_first_byte_offset:2
repl_backlog_histlen:1104
#開始從主切換(6380 -->6379)
# 只需要簡單執(zhí)行下面兩句命令,就將6380主切換為主
127.0.0.1:6380> slaveof no one
OK
127.0.0.1:6380> config set slave-read-only no
OK
127.0.0.1:6380> set title "sentinel"
OK
#連到從服務(wù)上,沒有問題
127.0.0.1:6381> get title
"sentinel"

日志(6379)

2495:M 05 Sep 20:06:23.615 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
2495:M 05 Sep 20:06:23.615 # Server started, Redis version 3.2.3
2495:M 05 Sep 20:06:23.617 # WARNING overcommit_memory is set to 0! Background save may fail under low memory condition. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect.
2495:M 05 Sep 20:06:24.815 * DB loaded from append only file: 1.199 seconds
2495:M 05 Sep 20:06:24.816 * The server is now ready to accept connections on port 6379
2495:M 05 Sep 20:06:24.816 - DB 0: 20019 keys (0 volatile) in 32768 slots HT.
2495:M 05 Sep 20:06:24.816 - 0 clients connected (0 slaves), 3764336 bytes in use
2495:M 05 Sep 20:06:29.841 - DB 0: 20019 keys (0 volatile) in 32768 slots HT.
2495:M 05 Sep 20:06:29.841 - 0 clients connected (0 slaves), 3764336 bytes in use
2495:M 05 Sep 20:06:34.867 - DB 0: 20019 keys (0 volatile) in 32768 slots HT.
2495:M 05 Sep 20:06:34.875 - 0 clients connected (0 slaves), 3764336 bytes in use
2495:M 05 Sep 20:06:39.919 - DB 0: 20019 keys (0 volatile) in 32768 slots HT.
2495:M 05 Sep 20:06:39.921 - 0 clients connected (0 slaves), 3764336 bytes in use
2495:M 05 Sep 20:06:44.971 - DB 0: 20019 keys (0 volatile) in 32768 slots HT.
2495:M 05 Sep 20:06:44.971 - 0 clients connected (0 slaves), 3764336 bytes in use
2495:M 05 Sep 20:06:50.022 - DB 0: 20019 keys (0 volatile) in 32768 slots HT.
2495:M 05 Sep 20:06:50.022 - 0 clients connected (0 slaves), 3764336 bytes in use
2495:M 05 Sep 20:06:55.134 - DB 0: 20019 keys (0 volatile) in 32768 slots HT.
2495:M 05 Sep 20:06:55.134 - 0 clients connected (0 slaves), 3764336 bytes in use
2495:M 05 Sep 20:06:58.775 - Accepted 127.0.0.1:44408
2495:M 05 Sep 20:06:58.775 * Slave 127.0.0.1:6380 asks for synchronization
2495:M 05 Sep 20:06:58.775 * Full resync requested by slave 127.0.0.1:6380
2495:M 05 Sep 20:06:58.775 * Starting BGSAVE for SYNC with target: disk
2495:M 05 Sep 20:06:58.776 * Background saving started by pid 2511
2511:C 05 Sep 20:06:58.868 * DB saved on disk
2511:C 05 Sep 20:06:58.870 * RDB: 0 MB of memory used by copy-on-write
2495:M 05 Sep 20:06:58.916 * Background saving terminated with success
2495:M 05 Sep 20:06:58.920 * Synchronization with slave 127.0.0.1:6380 succeeded

....

2495:M 05 Sep 20:19:19.471 # User requested shutdown...
2495:M 05 Sep 20:19:19.471 * Calling fsync() on the AOF file.
2495:M 05 Sep 20:19:19.471 * Removing the pid file.
2495:M 05 Sep 20:19:19.472 # Redis is now ready to exit, bye bye...

日志(6380)

2508:S 05 Sep 20:06:58.714 # Server started, Redis version 3.2.3
2508:S 05 Sep 20:06:58.714 # WARNING overcommit_memory is set to 0! Background save may fail under low memory condition. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect.
2508:S 05 Sep 20:06:58.775 * DB loaded from disk: 0.060 seconds
2508:S 05 Sep 20:06:58.775 * The server is now ready to accept connections on port 6380
2508:S 05 Sep 20:06:58.775 * Connecting to MASTER 127.0.0.1:6379
2508:S 05 Sep 20:06:58.775 * MASTER <-> SLAVE sync started
2508:S 05 Sep 20:06:58.775 * Non blocking connect for SYNC fired the event.
2508:S 05 Sep 20:06:58.775 * Master replied to PING, replication can continue...
2508:S 05 Sep 20:06:58.775 * Partial resynchronization not possible (no cached master)
2508:S 05 Sep 20:06:58.802 * Full resync from master: 8d0d86237c36a8d6ace4eed9b5f6e5871b40da29:1
2508:S 05 Sep 20:06:58.917 * MASTER <-> SLAVE sync: receiving 489615 bytes from master
2508:S 05 Sep 20:06:58.922 * MASTER <-> SLAVE sync: Flushing old data
2508:S 05 Sep 20:06:58.938 * MASTER <-> SLAVE sync: Loading DB in memory
2508:S 05 Sep 20:06:58.969 * MASTER <-> SLAVE sync: Finished with success
2508:S 05 Sep 20:06:59.788 * Slave 127.0.0.1:6381 asks for synchronization
2508:S 05 Sep 20:06:59.788 * Full resync requested by slave 127.0.0.1:6381
2508:S 05 Sep 20:06:59.788 * Starting BGSAVE for SYNC with target: disk
2508:S 05 Sep 20:06:59.788 * Background saving started by pid 2512
2512:C 05 Sep 20:06:59.832 * DB saved on disk
2512:C 05 Sep 20:06:59.832 * RDB: 0 MB of memory used by copy-on-write
2508:S 05 Sep 20:06:59.896 * Background saving terminated with success
2508:S 05 Sep 20:06:59.899 * Synchronization with slave 127.0.0.1:6381 succeeded
2508:S 05 Sep 20:10:46.786 * 10000 changes in 60 seconds. Saving...
2508:S 05 Sep 20:10:46.786 * Background saving started by pid 2595
2595:C 05 Sep 20:10:46.800 * DB saved on disk
2595:C 05 Sep 20:10:46.801 * RDB: 0 MB of memory used by copy-on-write
2508:S 05 Sep 20:10:46.887 * Background saving terminated with success
2508:S 05 Sep 20:19:19.472 # Connection with master lost.
2508:S 05 Sep 20:19:19.472 * Caching the disconnected master state.
2508:S 05 Sep 20:19:19.594 * Connecting to MASTER 127.0.0.1:6379
2508:S 05 Sep 20:19:19.595 * MASTER <-> SLAVE sync started
2508:S 05 Sep 20:19:19.595 # Error condition on socket for SYNC: Connection refused
2508:S 05 Sep 20:19:20.619 * Connecting to MASTER 127.0.0.1:6379
2508:S 05 Sep 20:19:20.619 * MASTER <-> SLAVE sync started

...

2508:S 05 Sep 20:20:49.783 # Error condition on socket for SYNC: Connection refused
2508:M 05 Sep 20:20:50.283 * Discarding previously cached master state.
2508:M 05 Sep 20:20:50.283 * MASTER MODE enabled (user request from 'id=6 addr=127.0.0.1:54717 fd=8 name= age=696 idle=0 flags=N db=0 sub=0 psub=0 multi=-1 qbuf=0 qbuf-free=32768 obl=0 oll=0 omem=0 events=r cmd=slaveof')
2508:M 05 Sep 20:25:47.073 * 1 changes in 900 seconds. Saving...
2508:M 05 Sep 20:25:47.074 * Background saving started by pid 2722
2722:C 05 Sep 20:25:47.087 * DB saved on disk
2722:C 05 Sep 20:25:47.088 * RDB: 0 MB of memory used by copy-on-write
2508:M 05 Sep 20:25:47.176 * Background saving terminated with success
2508:M 05 Sep 20:40:48.064 * 1 changes in 900 seconds. Saving...
2508:M 05 Sep 20:40:48.064 * Background saving started by pid 2813
2813:C 05 Sep 20:40:48.075 * DB saved on disk
2813:C 05 Sep 20:40:48.075 * RDB: 0 MB of memory used by copy-on-write
2508:M 05 Sep 20:40:48.165 * Background saving terminated with success

6381日志

2503:S 05 Sep 20:06:54.667 * DB loaded from disk: 0.087 seconds
2503:S 05 Sep 20:06:54.667 * The server is now ready to accept connections on port 6381
2503:S 05 Sep 20:06:54.667 * Connecting to MASTER 127.0.0.1:6380
2503:S 05 Sep 20:06:54.667 * MASTER <-> SLAVE sync started
2503:S 05 Sep 20:06:54.667 # Error condition on socket for SYNC: Connection refused
2503:S 05 Sep 20:06:55.691 * Connecting to MASTER 127.0.0.1:6380
2503:S 05 Sep 20:06:55.692 * MASTER <-> SLAVE sync started
2503:S 05 Sep 20:06:55.692 # Error condition on socket for SYNC: Connection refused
2503:S 05 Sep 20:06:56.716 * Connecting to MASTER 127.0.0.1:6380
2503:S 05 Sep 20:06:56.717 * MASTER <-> SLAVE sync started
2503:S 05 Sep 20:06:56.717 # Error condition on socket for SYNC: Connection refused
2503:S 05 Sep 20:06:57.741 * Connecting to MASTER 127.0.0.1:6380
2503:S 05 Sep 20:06:57.742 * MASTER <-> SLAVE sync started
2503:S 05 Sep 20:06:57.742 # Error condition on socket for SYNC: Connection refused
2503:S 05 Sep 20:06:58.764 * Connecting to MASTER 127.0.0.1:6380
2503:S 05 Sep 20:06:58.764 * MASTER <-> SLAVE sync started
2503:S 05 Sep 20:06:58.764 * Non blocking connect for SYNC fired the event.
2503:S 05 Sep 20:06:58.775 * Master replied to PING, replication can continue...
2503:S 05 Sep 20:06:58.775 * Partial resynchronization not possible (no cached master)
2503:S 05 Sep 20:06:58.776 * Master does not support PSYNC or is in error state (reply: -ERR Can't SYNC while not connected with my master)
2503:S 05 Sep 20:06:58.776 * Retrying with SYNC...
2503:S 05 Sep 20:06:58.803 # MASTER aborted replication with an error: ERR Can't SYNC while not connected with my master
2503:S 05 Sep 20:06:59.786 * Connecting to MASTER 127.0.0.1:6380
2503:S 05 Sep 20:06:59.787 * MASTER <-> SLAVE sync started
2503:S 05 Sep 20:06:59.787 * Non blocking connect for SYNC fired the event.
2503:S 05 Sep 20:06:59.787 * Master replied to PING, replication can continue...
2503:S 05 Sep 20:06:59.787 * Partial resynchronization not possible (no cached master)
2503:S 05 Sep 20:06:59.788 * Full resync from master: e1bfca531c87795977333fca30c7a75eea64a1de:1
2503:S 05 Sep 20:06:59.897 * MASTER <-> SLAVE sync: receiving 489615 bytes from master
2503:S 05 Sep 20:06:59.900 * MASTER <-> SLAVE sync: Flushing old data
2503:S 05 Sep 20:06:59.917 * MASTER <-> SLAVE sync: Loading DB in memory
2503:S 05 Sep 20:06:59.969 * MASTER <-> SLAVE sync: Finished with success

2.sentinel實現(xiàn)fail-over自動切換

從源文件中復(fù)制sentinel.conf
cp /usr/local/src/redis-3.2.3/sentinel.conf  /usr/local/redis/
#修改確認(rèn)如下參數(shù)
sentinel monitor mymaster 127.0.0.1 6379 1
sentinel down-after-milliseconds mymaster 5000
sentinel failover-timeout mymaster 180000
sentinel parallel-syncs mymaster 1

參照

http://www.redis.cn/topics/sentinel.html

 bin/redis-server redis.conf  
 bin/redis-server redis6380.conf  
 bin/redis-server redis6381.conf 
 bin/redis-server sentinel.conf  --sentinel
端口
標(biāo)志
6379
Master
6380
Slave
6381
Slave

使用sentinel 監(jiān)控(正常初始化狀態(tài),使用sentinel監(jiān)控如下)

2.1 Master狀態(tài)

127.0.0.1:26379> sentinel masters
1) 1) "name"
   2) "mymaster"
   3) "ip"
   4) "127.0.0.1"
   5) "port"
   6) "6379"
   7) "runid"
   8) "4d2b8e087e297f5d6347e1599a37c4998ad056d6"
   9) "flags"
  10) "master"
  11) "link-pending-commands"
  12) "0"
  13) "link-refcount"
  14) "1"
  15) "last-ping-sent"
  16) "0"
  17) "last-ok-ping-reply"
  18) "410"
  19) "last-ping-reply"
  20) "410"
  21) "down-after-milliseconds"
  22) "5000"
  23) "info-refresh"
  24) "7817"
  25) "role-reported"
  26) "master"
  27) "role-reported-time"
  28) "58045"
  29) "config-epoch"
  30) "0"
  31) "num-slaves"
  32) "2"
  33) "num-other-sentinels"
  34) "0"
  35) "quorum"
  36) "1"
  37) "failover-timeout"
  38) "180000"
  39) "parallel-syncs"
  40) "1"

可以知道Master的端口,備節(jié)點等信息。

2.2 查看初始的Slave信息

127.0.0.1:26379> sentinel slaves mymaster
1) 1) "name"
   2) "127.0.0.1:6380"
   3) "ip"
   4) "127.0.0.1"
   5) "port"
   6) "6380"
   7) "runid"
   8) "c344769d6d1cfd814437034b39f04b17851dca66"
   9) "flags"
  10) "slave"
  11) "link-pending-commands"
  12) "0"
  13) "link-refcount"
  14) "1"
  15) "last-ping-sent"
  16) "0"
  17) "last-ok-ping-reply"
  18) "693"
  19) "last-ping-reply"
  20) "693"
  21) "down-after-milliseconds"
  22) "5000"
  23) "info-refresh"
  24) "6445"
  25) "role-reported"
  26) "slave"
  27) "role-reported-time"
  28) "96788"
  29) "master-link-down-time"
  30) "0"
  31) "master-link-status"
  32) "ok"
  33) "master-host"
  34) "127.0.0.1"
  35) "master-port"
  36) "6379"
  37) "slave-priority"
  38) "100"
  39) "slave-repl-offset"
  40) "6058"
2) 1) "name"
   2) "127.0.0.1:6381"
   3) "ip"
   4) "127.0.0.1"
   5) "port"
   6) "6381"
   7) "runid"
   8) "9f8666ce6e7b30d01449f6fb10d8556030a96186"
   9) "flags"
  10) "slave"
  11) "link-pending-commands"
  12) "0"
  13) "link-refcount"
  14) "1"
  15) "last-ping-sent"
  16) "0"
  17) "last-ok-ping-reply"
  18) "693"
  19) "last-ping-reply"
  20) "693"
  21) "down-after-milliseconds"
  22) "5000"
  23) "info-refresh"
  24) "6444"
  25) "role-reported"
  26) "slave"
  27) "role-reported-time"
  28) "96788"
  29) "master-link-down-time"
  30) "0"
  31) "master-link-status"
  32) "ok"
  33) "master-host"
  34) "127.0.0.1"
  35) "master-port"
  36) "6379"
  37) "slave-priority"
  38) "100"
  39) "slave-repl-offset"
  40) "6058"

此時,sentinel日志風(fēng)平浪靜

2847:X 07 Sep 21:01:27.567 # Sentinel ID is 1b9d1d720b11ecf5568c3dc0194305e86c47ed9a
2847:X 07 Sep 21:01:27.567 # +monitor master mymaster 127.0.0.1 6379 quorum 1

2.3 模擬Master6379宕機)

127.0.0.1:6379> debug sleep 100
OK

2.4 sentinel自動進行failover切換

觀看sentinel日志(sentinel具體工作詳情)

2847:X 07 Sep 21:01:27.567 # +monitor master mymaster 127.0.0.1 6379 quorum 1
2847:X 07 Sep 21:03:49.117 # +sdown master mymaster 127.0.0.1 6379
2847:X 07 Sep 21:03:49.117 # +odown master mymaster 127.0.0.1 6379 #quorum 1/1
2847:X 07 Sep 21:03:49.117 # +new-epoch 4
2847:X 07 Sep 21:03:49.117 # +try-failover master mymaster 127.0.0.1 6379
2847:X 07 Sep 21:03:49.128 # +vote-for-leader 1b9d1d720b11ecf5568c3dc0194305e86c47ed9a 4
2847:X 07 Sep 21:03:49.129 # +elected-leader master mymaster 127.0.0.1 6379
2847:X 07 Sep 21:03:49.129 # +failover-state-select-slave master mymaster 127.0.0.1 6379
2847:X 07 Sep 21:03:49.185 # +selected-slave slave 127.0.0.1:6381 127.0.0.1 6381 @ mymaster 127.0.0.1 6379
2847:X 07 Sep 21:03:49.185 * +failover-state-send-slaveof-noone slave 127.0.0.1:6381 127.0.0.1 6381 @ mymaster 127.0.0.1 6379
2847:X 07 Sep 21:03:49.252 * +failover-state-wait-promotion slave 127.0.0.1:6381 127.0.0.1 6381 @ mymaster 127.0.0.1 6379
2847:X 07 Sep 21:03:50.262 # +promoted-slave slave 127.0.0.1:6381 127.0.0.1 6381 @ mymaster 127.0.0.1 6379
2847:X 07 Sep 21:03:50.262 # +failover-state-reconf-slaves master mymaster 127.0.0.1 6379
2847:X 07 Sep 21:03:50.315 * +slave-reconf-sent slave 127.0.0.1:6380 127.0.0.1 6380 @ mymaster 127.0.0.1 6379
2847:X 07 Sep 21:03:51.308 * +slave-reconf-inprog slave 127.0.0.1:6380 127.0.0.1 6380 @ mymaster 127.0.0.1 6379
2847:X 07 Sep 21:03:51.308 * +slave-reconf-done slave 127.0.0.1:6380 127.0.0.1 6380 @ mymaster 127.0.0.1 6379
2847:X 07 Sep 21:03:51.365 # +failover-end master mymaster 127.0.0.1 6379
2847:X 07 Sep 21:03:51.365 # +switch-master mymaster 127.0.0.1 6379 127.0.0.1 6381
2847:X 07 Sep 21:03:51.365 * +slave slave 127.0.0.1:6380 127.0.0.1 6380 @ mymaster 127.0.0.1 6381
2847:X 07 Sep 21:03:51.365 * +slave slave 127.0.0.1:6379 127.0.0.1 6379 @ mymaster 127.0.0.1 6381
2847:X 07 Sep 21:03:56.399 # +sdown slave 127.0.0.1:6379 127.0.0.1 6379 @ mymaster 127.0.0.1 6381
2847:X 07 Sep 21:05:23.708 # -sdown slave 127.0.0.1:6379 127.0.0.1 6379 @ mymaster 127.0.0.1 6381
2847:X 07 Sep 21:05:33.730 * +convert-to-slave slave 127.0.0.1:6379 127.0.0.1 6379 @ mymaster 127.0.0.1 6381

2.6 failover切換后監(jiān)控信息

127.0.0.1:26379> sentinel masters
1) 1) "name"
   2) "mymaster"
   3) "ip"
   4) "127.0.0.1"
   5) "port"
   6) "6381" (這兒變成了6381)
   7) "runid"
   8) "9f8666ce6e7b30d01449f6fb10d8556030a96186"
   9) "flags"
  10) "master"
  11) "link-pending-commands"
  12) "0"
  13) "link-refcount"
  14) "1"
  15) "last-ping-sent"
  16) "0"
  17) "last-ok-ping-reply"
  18) "190"
  19) "last-ping-reply"
  20) "190"
  21) "down-after-milliseconds"
  22) "5000"
  23) "info-refresh"
  24) "1905"
  25) "role-reported"
  26) "master"
  27) "role-reported-time"
  28) "42128"
  29) "config-epoch"
  30) "4"
  31) "num-slaves"
  32) "2"
  33) "num-other-sentinels"
  34) "0"
  35) "quorum"
  36) "1"
  37) "failover-timeout"
  38) "180000"
  39) "parallel-syncs"
  40) "1"

備庫信息

127.0.0.1:26379> sentinel slaves mymaster
1) 1) "name"
   2) "127.0.0.1:6379"
   3) "ip"
   4) "127.0.0.1"
   5) "port"
   6) "6379"
   7) "runid"
   8) ""
   9) "flags"
  10) "s_down,slave"(此時6379 還處在sleep狀態(tài),過了休眠時間會更新該狀態(tài))
  11) "link-pending-commands"
  12) "44"
  13) "link-refcount"
  14) "1"
  15) "last-ping-sent"
  16) "48488"
  17) "last-ok-ping-reply"
  18) "48488"
  19) "last-ping-reply"
  20) "48488"
  21) "s-down-time"
  22) "43454"
  23) "down-after-milliseconds"
  24) "5000"
  25) "info-refresh"
  26) "1473253479853"
  27) "role-reported"
  28) "slave"
  29) "role-reported-time"
  30) "48488"
  31) "master-link-down-time"
  32) "0"
  33) "master-link-status"
  34) "err"
  35) "master-host"
  36) "?"
  37) "master-port"
  38) "0"
  39) "slave-priority"
  40) "100"
  41) "slave-repl-offset"
  42) "0"
2) 1) "name"
   2) "127.0.0.1:6380"
   3) "ip"
   4) "127.0.0.1"
   5) "port"
   6) "6380"
   7) "runid"
   8) "c344769d6d1cfd814437034b39f04b17851dca66"
   9) "flags"
  10) "slave"
  11) "link-pending-commands"
  12) "0"
  13) "link-refcount"
  14) "1"
  15) "last-ping-sent"
  16) "0"
  17) "last-ok-ping-reply"
  18) "308"
  19) "last-ping-reply"
  20) "308"
  21) "down-after-milliseconds"
  22) "5000"
  23) "info-refresh"
  24) "8265"
  25) "role-reported"
  26) "slave"
  27) "role-reported-time"
  28) "48488"
  29) "master-link-down-time"
  30) "0"
  31) "master-link-status"
  32) "ok"
  33) "master-host"
  34) "127.0.0.1"
  35) "master-port"
  36) "6381"
  37) "slave-priority"
  38) "100"
  39) "slave-repl-offset"
  40) "11780"

127.0.0.1:26379> sentinel slaves mymaster
1) 1) "name"
   2) "127.0.0.1:6379"
   3) "ip"
   4) "127.0.0.1"
   5) "port"
   6) "6379"
   7) "runid"
   8) "4d2b8e087e297f5d6347e1599a37c4998ad056d6"
   9) "flags"
  10) "slave" s_down沒有了
  11) "link-pending-commands"
  12) "0"
  13) "link-refcount"
  14) "1"
  15) "last-ping-sent"
  16) "0"
  17) "last-ok-ping-reply"
  18) "869"
  19) "last-ping-reply"
  20) "869"
  21) "down-after-milliseconds"
  22) "5000"
  23) "info-refresh"
  24) "3426"
  25) "role-reported"
  26) "slave"
  27) "role-reported-time"
  28) "3426"
  29) "master-link-down-time"
  30) "0"
  31) "master-link-status"
  32) "ok"
  33) "master-host"
  34) "127.0.0.1"
  35) "master-port"
  36) "6381"
  37) "slave-priority"
  38) "100"
  39) "slave-repl-offset"
  40) "16556"
...

手動切換failover

127.0.0.1:26379> SENTINEL failover mymaster
OK
#切換為6379
127.0.0.1:26379> SENTINEL get-master-addr-by-name mymaster
1) "127.0.0.1"
2) "6379"

2847:X 07 Sep 21:46:46.793 # +switch-master mymaster 127.0.0.1 6381 127.0.0.1 6379
2847:X 07 Sep 21:46:46.794 * +slave slave 127.0.0.1:6380 127.0.0.1 6380 @ mymaster 127.0.0.1 6379
2847:X 07 Sep 21:46:46.794 * +slave slave 127.0.0.1:6381 127.0.0.1 6381 @ mymaster 127.0.0.1 6379
2847:X 07 Sep 21:46:56.910 * +convert-to-slave slave 127.0.0.1:6381 127.0.0.1 6381 @ mymaster 127.0.0.1 6379

sentinel 發(fā)生failover,會更新對應(yīng)主備庫的redis.conf文件。

6379對應(yīng)的配置文件,添加了slaveof參數(shù)

[root@hadoop2 redis]# cat redis.conf | grep slaveof
# Master-Slave replication. Use slaveof to make a Redis instance a copy of
# slaveof <masterip> <masterport>
slaveof 127.0.0.1 6381

6380對應(yīng)的配置文件,修改了slaveof參數(shù)

[root@hadoop2 redis]# cat redis6380.conf | grep slaveof
# Master-Slave replication. Use slaveof to make a Redis instance a copy of
slaveof 127.0.0.1 6381

至此演練結(jié)束

3其他

3.1 重要的quorum參數(shù)。

演練設(shè)置quorum=1,純粹為了簡單,線上環(huán)境不能重要。

http://redis.io/topics/sentinel 中提供了討論了4個場景,在以后慢慢演練討論下。

復(fù)制sentinel.conf時, 需要處理sentinel生成的信息如

sentinel myid 575cb680ff3d3cbad55cdb978c1d6b5962abe7ac

否則,sentinel之間通信存在問題

另外有需要云服務(wù)器可以了解下創(chuàng)新互聯(lián)scvps.cn,海內(nèi)外云服務(wù)器15元起步,三天無理由+7*72小時售后在線,公司持有idc許可證,提供“云服務(wù)器、裸金屬服務(wù)器、高防服務(wù)器、香港服務(wù)器、美國服務(wù)器、虛擬主機、免備案服務(wù)器”等云主機租用服務(wù)以及企業(yè)上云的綜合解決方案,具有“安全穩(wěn)定、簡單易用、服務(wù)可用性高、性價比高”等特點與優(yōu)勢,專為企業(yè)上云打造定制,能夠滿足用戶豐富、多元化的應(yīng)用場景需求。

本文標(biāo)題:redis演練(7)redisSentinel實現(xiàn)故障轉(zhuǎn)移-創(chuàng)新互聯(lián)
當(dāng)前路徑:http://aaarwkj.com/article24/ccdoce.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供關(guān)鍵詞優(yōu)化用戶體驗、網(wǎng)頁設(shè)計公司、面包屑導(dǎo)航、網(wǎng)站營銷外貿(mào)建站

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)

商城網(wǎng)站建設(shè)
6080yy精品一区二区三区| 曰韩av毛片在线观看| 国产精品水嫩水嫩粉嫩| 欧美日韩欧美国产精品| 一区二区三区国产欧美日本| 首页亚洲一区二区三区| 亚洲一区二区日韩人妻| 精品一区二区三区毛卡片| 亚洲日本av一区二区| av永久天堂一区二区三区| 国产精品三级玖玖玖电影| 久久精品国产亚洲av高清一区| 欧美成人一区二区三区片| 色噜噜色一区二区三区| 久久亚洲精品中文字幕馆| 亚洲综合美女极品啪啪啪| 天天爽天天看天天射天天操| 久久人妻一区二区三区免费密臀| 毛片一区二区三区免费看| 成人福利午夜一区二区| 成年人国产免费在线观看| 少妇视频资源一区二区三区| 国产麻豆精品传媒av| 97国产在线视频观看| 欧美一区二区三区情色| 国产一区国产二区中文字幕| 国产亚洲综合一区二区三区| 清纯美女爱爱高潮av| 午夜午色夜之日本福利片| 丝袜美腿精尽福利视频网址大全| 欧美大片在线观看高清| 国产精品日产三级在线观看| 久久免费欧美日韩亚洲| 欧美高清一区二区三区精品| 午夜黄色福利在线观看| 亚洲av乱码久久精品蜜桃| 国产欧美色日韩综合在线| 亚洲成人日韩成人av| 在线看日本十八禁网站| 天堂av好男人亚洲精品| 欧美日韩黄色在线观看|