redis 哨兵_docker里创建redis哨兵
參考:https://www.jianshu.com/p/ba4667e242f3
https://www.jocat.cn/archives/51908
https://www.runoob.com/docker/docker-install-redis.html
背景:想看看docker-redis哨兵怎么搭建的
redis 拓展方案較為常見的有三種:
為什么用哨兵模式:
哨兵工作原理:
哨兵的工作流程主要分為以下幾個階段:
業務流程圖:
==================docker安裝==================
前提:網絡正常(ping baidu.com ok即可)
使用官方安裝腳本自動安裝
安裝命令: curl -fsSL https://get.docker.com | bash -s docker --mirror Aliyun 設置開啟開機啟動 sudo systemctl enable docker 查看安裝dockers 版本 docker versiondocker 啟動/查看狀態/關閉/重啟 systemctl start docker systemctl status docker systemctl stop docker systmctl restart docker當docker安裝,啟動全部成功,此時查看docker version 如下
============docker下載redis鏡像============
搜索可用redis鏡像命令 docker search redis #拉取最新版redis鏡像 docker pull redis:latest#查看拉取鏡像 docker images#鏡像拉取成功,啟動rdis容器,使用redis # -d 允許后臺運行 # -p 端口映射 # --requirepass 設置redis密碼 # --masterauth 設置連接主服務密碼,需要和requirepass設置一樣 docker run -d --name redis -p 6379:6379 redis --requirepass 123456 --masterauth 123456#查看IP信息, 查看ens33信息,是否包含inet信息 ip addr#查看創建容器 docker ps -a-------------------------------------- 如果下載的東西不合適 # 刪除鏡像 imageName 等于鏡像名稱 docker rmi imageName #強制刪除指定鏡像 docker rmi -f imageName #強制刪除全部鏡像 docker rmi -f $(docker images -q) #強制刪除全部容器 docker rm -f $(docker ps -aq)(一般用不到)這里有一個小東西,主要是下載redis.conf用的:
#下載 wget工具(下載redis.conf用于外網訪問配置) yum -y install wget #下載redis配置文件(后面配置外網訪問) wget http://download.redis.io/redis-stable/redis.conf安裝vim編輯器,編輯redis配置文件/或者使用FTP下載配置文件到本地進行更新 vim安裝 命令 輸入命令:yum -y install vim* 即可自動下載并安裝------------------------------------------------------------------ 打開 redis.conf 注釋下面這行,作用是允許任意IP接入 #bind 127.0.0.1 允許服務后臺運行 daemonize no 關閉保護模式 protected-mode nodocker內拉取redis鏡像,外部訪問成功,下面是使用redis容器搭建集群
=================redis容器搭建集群=================
redis集群最少需要3臺,所以此處建立一主兩從三臺容器
#創建redis容器,注意 命名 和 端口docker run -d --name redis-master -p 6379:6379 redis --requirepass 123456 --masterauth 123456docker run -d --name redis-slave1 -p 6380:6379 redis --requirepass 123456 --masterauth 123456docker run -d --name redis-slave2 -p 6381:6379 redis --requirepass 123456 --masterauth 123456#查看創建成功的容器信息 [root@localhost ~]# docker ps -aCONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMESda16225d81d3 redis "docker-entrypoint.s…" 5 seconds ago Up 4 seconds 0.0.0.0:6381->6379/tcp redis-slave2019704b14b2a redis "docker-entrypoint.s…" 16 seconds ago Up 15 seconds 0.0.0.0:6380->6379/tcp redis-slave133897bab292e redis "docker-entrypoint.s…" 32 seconds ago Up 31 seconds 0.0.0.0:6379->6379/tcp redis-master#查看主節點容器ipdocker inspect containerid 33897bab292e ....."IPAddress": "172.17.0.2",.....#進入容器配置主節點容器 #進入redis容器docker exec -it redis-slave1 bash#進入redis容器內redis命令行并輸入訪問密碼redis-cli -a mima#配置主節點服務器IP地址和端口號slaveof 172.17.0.2 6379#退出exit# 這里有兩個redis容器,需要進行兩次編輯,兩臺容器全部更新后進入主節點容器查看是否配置成功 # 進入redis命令行后輸入下面的命令,作用是查看redis容器的主從角色info replication #################################################################################命令行完整示例:
#查看docker 全部容器(沒創建之前,沒有容器信息) [root@localhost ~]# docker ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES#啟動創建redis容器 [root@localhost ~]# docker run -d --name redis-master -p 6379:6379 redis --requirepass 123456 --masterauth 123456 33897bab292e91706891f8f150689d6013b80a1f28407844062282890099b426 [root@localhost ~]# docker run -d --name redis-slave1 -p 6380:6379 redis --requirepass 123456 --masterauth 123456 019704b14b2a1f588babd3e4dcd6b7c38a7dd00e777eba9442fb5f10cd145f01 [root@localhost ~]# docker run -d --name redis-slave2 -p 6381:6379 redis --requirepass 123456 --masterauth 123456 da16225d81d3a45729ca1eb289ec2ed93f8631cf5d1016ea35a300e2f63a9a73#查看容器是否創建成功 [root@localhost ~]# docker ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES da16225d81d3 redis "docker-entrypoint.s…" 5 seconds ago Up 4 seconds 0.0.0.0:6381->6379/tcp redis-slave2 019704b14b2a redis "docker-entrypoint.s…" 16 seconds ago Up 15 seconds 0.0.0.0:6380->6379/tcp redis-slave1 33897bab292e redis "docker-entrypoint.s…" 32 seconds ago Up 31 seconds 0.0.0.0:6379->6379/tcp redis-master#查看主節點容器ip地址 (CONTAINER ID) [root@localhost ~]# docker inspect containerid 33897bab292e ..... "IPAddress": "172.17.0.2", .....#進入子節點容器,配置主節點 [root@localhost ~]# docker exec -it redis-slave1 bash root@019704b14b2a:/data# redis-cli -a 123456 Warning: Using a password with '-a' or '-u' option on the command line interface may not be safe. 127.0.0.1:6379> SLAVEOF 172.17.0.2 6379 OK 127.0.0.1:6379> exit root@019704b14b2a:/data# exit exit#進入子節點容器2,配置主節點 [root@localhost ~]# docker exec -it redis-slave2 bash root@da16225d81d3:/data# redis-cli -a 123456 Warning: Using a password with '-a' or '-u' option on the command line interface may not be safe. 127.0.0.1:6379> SLAVEOF 172.17.0.2 6379 OK 127.0.0.1:6379> exit root@da16225d81d3:/data# exit exit#進入主節點,查看配置是否成功 [root@localhost ~]# docker exec -it redis-master bash root@33897bab292e:/data# redis-cli -a 123456 Warning: Using a password with '-a' or '-u' option on the command line interface may not be safe. 127.0.0.1:6379> info replication # Replication role:master #connected_slaves內容等于 2,說明對應兩個子節點配置成功 connected_slaves:2 slave0:ip=172.17.0.3,port=6379,state=online,offset=126,lag=0 slave1:ip=172.17.0.4,port=6379,state=online,offset=126,lag=0 ...... 127.0.0.1:6379> exit root@e19745c06ed0:/data# exit exit#docker redis容器集群配置成功,查看IP(ens33--inet信息) [root@localhost ~]# ip addr 1: lo: .... 2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000link/ether 00:0c:29:a0:57:df brd ff:ff:ff:ff:ff:ffinet 192.168.5.129/24 brd 192.168.5.255 scope global noprefixroute dynamic ens33valid_lft 1379sec preferred_lft 1379secinet6 fe80::b784:bd18:2c5c:3e69/64 scope link noprefixroute valid_lft forever preferred_lft forever 3: docker0: .... 5: veth85debb1@if4: .... 7: veth006e33e@if6: .... 9: veth4e082f8@if8: .... [root@localhost ~]# #................................... #docker 一主兩從redis容器集群搭建成功 #...................................測試集群是否正常:
##查看redis拓展集群容器 [root@localhost dokcer]# docker ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 33af52e9eea0 redis "docker-entrypoint.s…" 11 minutes ago Up 11 minutes 0.0.0.0:6381->6379/tcp redis-slave2 f565940c710e redis "docker-entrypoint.s…" 11 minutes ago Up 11 minutes 0.0.0.0:6380->6379/tcp redis-slave1 e398aa598a08 redis "docker-entrypoint.s…" 11 minutes ago Up 11 minutes 0.0.0.0:6379->6379/tcp redis-master[root@localhost dokcer]# docker exec -it redis-master bash root@e398aa598a08:/data# redis-cli -a 123456 Warning: Using a password with '-a' or '-u' option on the command line interface may not be safe. 127.0.0.1:6379> set name zhangsanfeng ex 1000 nx OK 127.0.0.1:6379> get name "zhangsanfeng" 127.0.0.1:6379> exit root@e398aa598a08:/data# exit exit#進入子節點容器,賦值被拒絕,因為子節點容器只開了讀權限,沒有開啟寫入權限,但是主節點數據已經同步成功 [root@localhost dokcer]# docker exec -it redis-slave1 bash root@f565940c710e:/data# redis-cli -a 123456 Warning: Using a password with '-a' or '-u' option on the command line interface may not be safe. 127.0.0.1:6379> set name1 zhangsanfeng EX 1000 NX 100 (error) READONLY You can't write against a read only replica. #寫入數據被拒絕(無權限) 127.0.0.1:6379> get name "zhangsanfeng" 127.0.0.1:6379> exit root@f565940c710e:/data# exit exit#進入子節點容器,賦值被拒絕,因為子節點容器只開了讀權限,沒有開啟寫入權限,但是主節點數據已經同步成功 [root@localhost dokcer]# docker exec -it redis-slave2 bash root@33af52e9eea0:/data# redis-cli -a 123456 Warning: Using a password with '-a' or '-u' option on the command line interface may not be safe. 127.0.0.1:6379> set name2 zhangsanfeng EX 1000 NX 100 (error) READONLY You can't write against a read only replica. #寫入數據被拒絕(無權限) 127.0.0.1:6379> get name "zhangsanfeng" 127.0.0.1:6379> exit root@33af52e9eea0:/data# exit exit [root@localhost dokcer]#============ redis容器搭建哨兵============
創建sentinel配置文件命令
touch sentinel1.conf#####配置文件內容樣例#####
#sentinel 配置文件 #服務名自定義(redis-master)#監聽名為redis-master 主服務 ip為172.18.0.2 端口為6379 sentinel monitor redis-master 172.17.0.2 6379 2#以守護進程方式運行 daemonize yes#驗證主redis密碼 sentinel auth-pass redis-master 123456#10秒無響應下線服務 sentinel down-after-milliseconds redis-master 10000#60秒超時 sentinel failover-timeout redis-master 60000#日志輸出位置(位置自定義) logfile "/data/sentinel/log.txt"然后復制三份配置文件,如圖:
命令流程: 1.創建sentinel容器:[名稱 端口 文件路徑有區別] docker run -it --name sentinel1 -p 26379:6379 -v /root/redis/sentinel1.conf:/data/sentinel.conf -d redis docker run -it --name sentinel2 -p 26380:6379 -v /root/redis/sentinel2.conf:/data/sentinel.conf -d redis docker run -it --name sentinel3 -p 26381:6379 -v /root/redis/sentinel3.conf:/data/sentinel.conf -d redis2.依次啟動sentinel容器 #進入sentinel容器 docker exec -it sentinel1 bash #運行sentinel redis-sentinel sentinel.conf #實時打印sentinel日志 tail -f log.txtsentinel配置文件創建成功后,下面需要創建啟動sentinel容器
#創建sentinel[1.2.3] 容器 #/root/redis/sentinel1.conf 自定義的sentinel配置文件地址 #/data/sentinel.conf 掛載文件地址[root@localhost redis]# docker run -it --name sentinel1 -p 26379:6379 -v /root/redis/sentinel1.conf:/data/sentinel.conf -d redis dc5d83709dbdcea27424e30b6819bac1e8437d56a6405f191dce220bef231b2a [root@localhost redis]# docker run -it --name sentinel2 -p 26380:6379 -v /root/redis/sentinel2.conf:/data/sentinel.conf -d redis 458cf820afd7b439b4ff7d09d3c900c23c244f1db37ca85bff125b331a61564e [root@localhost redis]# docker run -it --name sentinel3 -p 26381:6379 -v /root/redis/sentinel3.conf:/data/sentinel.conf -d redis c48216948abef1c8477ffb6be3ab332e51ce5beae9b1684316a76b242c9f8bb9#查看容器是否創建成功 [root@localhost redis]# docker ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES c48216948abe redis "docker-entrypoint.s…" 8 seconds ago Up 8 seconds 0.0.0.0:26381->6379/tcp sentinel3 458cf820afd7 redis "docker-entrypoint.s…" 15 seconds ago Up 15 seconds 0.0.0.0:26380->6379/tcp sentinel2 dc5d83709dbd redis "docker-entrypoint.s…" 32 seconds ago Up 31 seconds 0.0.0.0:26379->6379/tcp sentinel1 a33351bd84ff redis "docker-entrypoint.s…" 27 hours ago Up 3 hours 0.0.0.0:6381->6379/tcp redis-slave2 e6db14e45ce2 redis "docker-entrypoint.s…" 27 hours ago Up 3 hours 0.0.0.0:6380->6379/tcp redis-slave1 e19745c06ed0 redis "docker-entrypoint.s…" 27 hours ago Up 3 hours 0.0.0.0:6379->6379/tcp redis-master#進入容器[1]啟動sentinel [root@localhost redis]# docker exec -it sentinel1 bash root@dc5d83709dbd:/data# redis-sentinel sentinel.conf root@dc5d83709dbd:/data# tail -f log.txt 22:X 06 Aug 2020 05:41:47.625 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo 22:X 06 Aug 2020 05:41:47.625 # Redis version=6.0.6, bits=64, commit=00000000, modified=0, pid=22, just started 22:X 06 Aug 2020 05:41:47.625 # Configuration loaded 23:X 06 Aug 2020 05:41:47.628 * Running mode=sentinel, port=26379. 23:X 06 Aug 2020 05:41:47.628 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128. 23:X 06 Aug 2020 05:41:47.630 # Sentinel ID is b50ac3497a685c67ec2bb3cb0a4b12128558b2fd 23:X 06 Aug 2020 05:41:47.630 # +monitor master redis-master 172.17.0.4 6379 quorum 2 23:X 06 Aug 2020 05:41:47.631 * +slave slave 172.17.0.3:6379 172.17.0.3 6379 @ redis-master 172.17.0.4 6379 23:X 06 Aug 2020 05:41:47.632 * +slave slave 172.17.0.2:6379 172.17.0.2 6379 @ redis-master 172.17.0.4 6379 ^C#進入容器[2]啟動sentinel [root@localhost redis]# docker exec -it sentinel2 bash root@458cf820afd7:/data# redis-sentinel sentinel.conf root@458cf820afd7:/data# tail -f log.txt 22:X 06 Aug 2020 05:46:15.800 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo 22:X 06 Aug 2020 05:46:15.800 # Redis version=6.0.6, bits=64, commit=00000000, modified=0, pid=22, just started 22:X 06 Aug 2020 05:46:15.800 # Configuration loaded 23:X 06 Aug 2020 05:46:15.803 * Running mode=sentinel, port=26379. 23:X 06 Aug 2020 05:46:15.803 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128. 23:X 06 Aug 2020 05:46:15.805 # Sentinel ID is 2b9656eab4d201fa91e5a03f8d06ee5546bca9f4 23:X 06 Aug 2020 05:46:15.805 # +monitor master redis-master 172.17.0.4 6379 quorum 2 23:X 06 Aug 2020 05:46:15.806 * +slave slave 172.17.0.3:6379 172.17.0.3 6379 @ redis-master 172.17.0.4 6379 23:X 06 Aug 2020 05:46:15.807 * +slave slave 172.17.0.2:6379 172.17.0.2 6379 @ redis-master 172.17.0.4 6379 23:X 06 Aug 2020 05:46:16.357 * +sentinel sentinel b50ac3497a685c67ec2bb3cb0a4b12128558b2fd 172.17.0.5 26379 @ redis-master 172.17.0.4 6379 ^C#進入容器[3]啟動sentinel root@458cf820afd7:/data# exit exit [root@localhost redis]# docker exec -it sentinel3 bash root@c48216948abe:/data# redis-sentinel sentinel.conf root@c48216948abe:/data# tail -f log.txt 22:X 06 Aug 2020 05:47:05.166 # Redis version=6.0.6, bits=64, commit=00000000, modified=0, pid=22, just started 22:X 06 Aug 2020 05:47:05.166 # Configuration loaded 23:X 06 Aug 2020 05:47:05.169 * Running mode=sentinel, port=26379. 23:X 06 Aug 2020 05:47:05.169 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128. 23:X 06 Aug 2020 05:47:05.170 # Sentinel ID is c4852a6c3aac1b5bc482c000aced21297208894c 23:X 06 Aug 2020 05:47:05.170 # +monitor master redis-master 172.17.0.4 6379 quorum 2 23:X 06 Aug 2020 05:47:05.171 * +slave slave 172.17.0.3:6379 172.17.0.3 6379 @ redis-master 172.17.0.4 6379 23:X 06 Aug 2020 05:47:05.171 * +slave slave 172.17.0.2:6379 172.17.0.2 6379 @ redis-master 172.17.0.4 6379 23:X 06 Aug 2020 05:47:05.427 * +sentinel sentinel b50ac3497a685c67ec2bb3cb0a4b12128558b2fd 172.17.0.5 26379 @ redis-master 172.17.0.4 6379 23:X 06 Aug 2020 05:47:06.771 * +sentinel sentinel 2b9656eab4d201fa91e5a03f8d06ee5546bca9f4 172.17.0.6 26379 @ redis-master 172.17.0.4 6379哨兵配置結束,接下來需要驗證是否配置成功,另外開啟一個命令行窗口#查看docker 全部容器 [root@localhost ~]# docker ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES c48216948abe redis "docker-entrypoint.s…" About an hour ago Up About an hour 0.0.0.0:26381->6379/tcp sentinel3 458cf820afd7 redis "docker-entrypoint.s…" About an hour ago Up About an hour 0.0.0.0:26380->6379/tcp sentinel2 dc5d83709dbd redis "docker-entrypoint.s…" About an hour ago Up About an hour 0.0.0.0:26379->6379/tcp sentinel1 a33351bd84ff redis "docker-entrypoint.s…" 29 hours ago Up 4 hours 0.0.0.0:6381->6379/tcp redis-slave2 e6db14e45ce2 redis "docker-entrypoint.s…" 29 hours ago Up 4 hours 0.0.0.0:6380->6379/tcp redis-slave1 e19745c06ed0 redis "docker-entrypoint.s…" 29 hours ago Up 4 hours 0.0.0.0:6379->6379/tcp redis-master#測試哨兵是否搭建成功,我們停掉redis-master(主節點容器) [root@localhost ~]# docker stop redis-master redis-master#過了設置的超時時間后,查看節點容器[1] 是否轉為主節點容器,結果是沒有 [root@localhost ~]# docker exec -it redis-slave1 bash root@e6db14e45ce2:/data# redis-cli -a 123456 Warning: Using a password with '-a' or '-u' option on the command line interface may not be safe. 127.0.0.1:6379> info replication # Replication role:slave master_host:172.17.0.2 master_port:6379 master_link_status:up master_last_io_seconds_ago:0 master_sync_in_progress:0 slave_repl_offset:934437 slave_priority:100 slave_read_only:1 connected_slaves:0 master_replid:8c30de55c5989f809db940f969d0da67a3d0f673 master_replid2:603a2f20bb1aef5f30662331f6c0c735a16c147a master_repl_offset:934437 second_repl_offset:885568 repl_backlog_active:1 repl_backlog_size:1048576 repl_backlog_first_byte_offset:1 repl_backlog_histlen:934437 127.0.0.1:6379> exit root@e6db14e45ce2:/data# exit exit#過了設置的超時時間后,查看節點容器[2] 是否轉為主節點容器,結果是有 [root@localhost ~]# docker exec -it redis-slave2 bash root@a33351bd84ff:/data# redis-cli -a 123456 Warning: Using a password with '-a' or '-u' option on the command line interface may not be safe. 127.0.0.1:6379> info replication # Replication role:master connected_slaves:1 slave0:ip=172.17.0.3,port=6379,state=online,offset=940734,lag=0 master_replid:8c30de55c5989f809db940f969d0da67a3d0f673 master_replid2:603a2f20bb1aef5f30662331f6c0c735a16c147a master_repl_offset:940873 second_repl_offset:885568 repl_backlog_active:1 repl_backlog_size:1048576 repl_backlog_first_byte_offset:183 repl_backlog_histlen:940691 127.0.0.1:6379> ---------------------------------------------------------------------------------------------------------------------------------------- #與此同時,sentinel實時日志仍在打印,發現結果如下: ----------------------------------------------------------------------------------------------------------------------------------------#停掉redis-master容器后,發現哨兵自動切換主節點容器 23:X 06 Aug 2020 06:55:47.401 # +sdown master redis-master 172.17.0.4 6379 23:X 06 Aug 2020 06:55:47.478 # +odown master redis-master 172.17.0.4 6379 #quorum 2/2 23:X 06 Aug 2020 06:55:47.478 # +new-epoch 1 23:X 06 Aug 2020 06:55:47.478 # +try-failover master redis-master 172.17.0.4 6379 23:X 06 Aug 2020 06:55:47.481 # +vote-for-leader c4852a6c3aac1b5bc482c000aced21297208894c 1 23:X 06 Aug 2020 06:55:47.484 # 2b9656eab4d201fa91e5a03f8d06ee5546bca9f4 voted for c4852a6c3aac1b5bc482c000aced21297208894c 1 23:X 06 Aug 2020 06:55:47.484 # b50ac3497a685c67ec2bb3cb0a4b12128558b2fd voted for c4852a6c3aac1b5bc482c000aced21297208894c 1 23:X 06 Aug 2020 06:55:47.534 # +elected-leader master redis-master 172.17.0.4 6379 23:X 06 Aug 2020 06:55:47.534 # +failover-state-select-slave master redis-master 172.17.0.4 6379 23:X 06 Aug 2020 06:55:47.601 # +selected-slave slave 172.17.0.2:6379 172.17.0.2 6379 @ redis-master 172.17.0.4 6379 23:X 06 Aug 2020 06:55:47.601 * +failover-state-send-slaveof-noone slave 172.17.0.2:6379 172.17.0.2 6379 @ redis-master 172.17.0.4 6379 23:X 06 Aug 2020 06:55:47.684 * +failover-state-wait-promotion slave 172.17.0.2:6379 172.17.0.2 6379 @ redis-master 172.17.0.4 6379 23:X 06 Aug 2020 06:55:48.652 # +promoted-slave slave 172.17.0.2:6379 172.17.0.2 6379 @ redis-master 172.17.0.4 6379 23:X 06 Aug 2020 06:55:48.652 # +failover-state-reconf-slaves master redis-master 172.17.0.4 6379 23:X 06 Aug 2020 06:55:48.728 * +slave-reconf-sent slave 172.17.0.3:6379 172.17.0.3 6379 @ redis-master 172.17.0.4 6379 23:X 06 Aug 2020 06:55:49.652 # -odown master redis-master 172.17.0.4 6379 23:X 06 Aug 2020 06:55:49.707 * +slave-reconf-inprog slave 172.17.0.3:6379 172.17.0.3 6379 @ redis-master 172.17.0.4 6379 23:X 06 Aug 2020 06:55:49.708 * +slave-reconf-done slave 172.17.0.3:6379 172.17.0.3 6379 @ redis-master 172.17.0.4 6379 23:X 06 Aug 2020 06:55:49.765 # +failover-end master redis-master 172.17.0.4 6379 23:X 06 Aug 2020 06:55:49.765 # +switch-master redis-master 172.17.0.4 6379 172.17.0.2 6379 23:X 06 Aug 2020 06:55:49.765 * +slave slave 172.17.0.3:6379 172.17.0.3 6379 @ redis-master 172.17.0.2 6379 23:X 06 Aug 2020 06:55:49.765 * +slave slave 172.17.0.4:6379 172.17.0.4 6379 @ redis-master 172.17.0.2 6379 23:X 06 Aug 2020 06:55:59.781 # +sdown slave 172.17.0.4:6379 172.17.0.4 6379 @ redis-master 172.17.0.2 6379至此,發現服務掛掉,故障自動被切掉,哨兵搭建成功
總結
以上是生活随笔為你收集整理的redis 哨兵_docker里创建redis哨兵的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: distinct 排序_自己造一个排序算
- 下一篇: docker镜像内容如何查看_如何快速打