In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
This article introduces the relevant knowledge of "what is the method of installation, deployment and switching of redis sentinel Sentinel mode". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
1. Install redis
[root@mdb01 redis-4.0.14] # makecd src & & make allmake [1]: Entering directory `/ u01Accord Reddit 4.0.14u01/redis/redis-4.0.14/src'make CC Makefile.depmake [1]: Leaving directory` / u01/redis/redis-4.0.14/src'make [1]: Entering directory `/ u01RDUDIMART 4.0.14max RDC'CC adlist.oIn file included from adlist.c:34:0:zmalloc.h:50:31: fatal error: Jemalloc/jemalloc.h: No such file or directory # include ^ compilation terminated.make [1]: * * [adlist.o] Error 1make [1]: Leaving directory `/ u01/redis/redis-4.0.14/src'make: * [all] Error 2
Report an error and compile in the following way
[root@mdb01 redis-4.0.14] # make MALLOC=libc [root@mdb01 src] # cd src/ [root@mdb01 src] # make install CC Makefile.depHint: It's a good idea to run 'make test' ) INSTALL install [root@mdb01 redis-4.0.14] # mkdir 6379 / {run,log,conf,rdb}-p [root@mdb01 redis-4.0.14] # cp redis.conf / u01/redis/6379/conf [root@mdb01 redis-4.0.14] # cp sentinel.conf / u01/redis/6379/conf
Conf # # configuration file directory
Log # # Log file directory
Run # # directory of pid files running
Rdb # # Snapshot and AOF file directory
Modify the following parameters of redis.conf
[root@mdb01 conf] # more redis.conf | grep-v'^ #'| grep-v'^ $'bind 127.0.0.1 192.168.61.16protected-mode nodaemonize yespidfile / u01/redis/6379/run/redis_6379.pidlogfile "/ u01/redis/6379/log//redis_6379.log" masterauth redisrequirepass redis
Start
Redis-server / u01/redis/6379/conf/redis.conf
Set password
Config set requirepass redis
two。 Build a slave library
The process of building a slave library is the same as the master library. It's just that the parameter file serves as the main library information for slave:
Slaveof 192.168.61.16 6379
Slave-read-only yes
3. Master-slave switching
Kill the main library.
Execute from the library:
Slaveof no one
After the main library is restored:
Slaveof 192.168.61.16 6379
During the time from the downtime of the master library to the recovery, all the data written from the library will be lost after the master-slave relationship is re-established. Because when re-establishing a synchronization relationship with the main library
Will try to resynchronize the data to the main database.
4081 Apr S 04 Apr 16 Apr 4414. 374 * Connecting to MASTER 192.168.61.16 Apr 63794081 14. 375 * Non blocking connect for SYNC fired the event.4081:S 04 16 Apr 14. 375 * Non blocking connect for SYNC fired the event.4081:S 04 16 Apr 14. 375 * Non blocking connect for SYNC fired the event.4081:S 04 Replication can continue...4081:S 04 Apr 16 Apr 16 Apr 44 request 11331acb42a97da2b6b4300ed50608b7ccf61d7b:5562 14.376 * Trying a partial resynchronization (request 11331acb42a97da2b6b4300ed50608b7ccf61d7b:5562). 4081 receiving 04 MASTER SLAVE sync: receiving 199 bytes from master4081:S 04 Apr 16V 4414. 434 * MASTER SLAVE sync: Flushing old data4081:S 04 Apr 16:44:14. 434 * MASTER SLAVE sync: Loading DB in memory4081:S 04 Apr 16 Apr 4415 14.434 * MASTER SLAVE sync: Finished with success
4. Build Sentinel mode
192.168.61.16 master+sentinel
192.168.61.17 slave+sentinel
192.168.61.18 slave+sentinel
[root@mdb01 conf] # more sentinel.conf | grep-v'^ #'| grep-v'^ $'
Port 26379dir / tmpsentinel monitor mymaster 192.168.61.16 6379 2 # mymaster has its own name, main library IP and port. 2 means that the two sentinels will only switch when they cannot connect to the main library. It is generally set to N _ Sentinel (N is the total number of Sentinel). The timeout for sentinel down-after-milliseconds mymaster 15000 # Sentinel to connect to the main library is 15 seconds. The Sentinel thinks that there is a problem with the master database within 15 seconds. If the two are met, the switch will occur. After sentinel parallel-syncs mymaster 1 # switch, the slave database has to keep data synchronization with the new master every time. At this time, it is not recommended that all slaves start pulling data with the master database again. Although the recovery time is the shortest, there will be no available nodes sentinel failover-timeout mymaster 180000sentinel deny-scripts-reconfig yes.
Note that the down-aafter-milliseconds unit here is millisecond. At first, I matched it to 15 seconds, which I thought was 15 seconds. As a result, there is a problem of frequent switching between master and slave.
Every master turns on from above:
Redis-sentinel / u01/redis/6379/conf/sentinel.conf
You can also use the following ways
Redis-server / u01/redis/6379/conf/sentinel.conf-- sentinel
Analog switching:
Kill the 16 main library.
01
13529 sentinel X 05 Apr 11 7 sentinel 29.846 # + sdown master mymaster 192.168.61.16 6379 # A sentinel thinks that 16 has been down, and this is a subjective referral (sdown) 13529 sentinel X 05 11 sentinel 07down 29.922 # + odown master mymaster 192.168.61.16 6379 # quorum 2 # quorum has reached two sentinel that 16 has been down At this time, a new epoch is opened for the objective downline (odown) 13529 tilt mode entered13529:X X 05 Apr 11 tilt 50.872 # + tilt # tilt mode entered13529:X 05 Apr 11 V 20.942 #-tilt # tilt mode exited13529:X 05 Apr 11 10 Apr 54.650 # + new-epoch 1361 #, and the election will be based on the offset. Then switch 13529 Apr X 05 Apr 11 Apr 11 Apr 54.651 # Next failover delay: I will not start a failover before Sun Apr 5 11:16:55 202013529 I will not start a failover before Sun Apr 5 11:16:55 202013529 I will not start a failover before Sun Apr 55.834 # + config-update-from sentinel 36c1c343cc73638eae2177e5a71d4fff92cf0b97 192.168.61.17 26379 @ mymaster 192.168.61.16 637913529 Apr 1114 55.834 # + switch-master mymaster 192.168.61.16 6379 192 .168.61.17 637913529 Apr 1129 mymaster 192.168.61.18 6379 @ mymaster 192.168.61.17 637913529 slave slave 192.168.61.16 6379 @ mymaster 192.168.61.17 637913529 slave slave 192.168.61.16 6379 @ mymaster 192.168.61.17 637913529 slave slave 192.168.61.17 637913529 mymaster 192.168.61.161.1679 @ mymaster 192.168.61.16 6379
02:
7953 Apr 05 Apr 11 Apr 07 Apr 29.852 # + try-failover master mymaster 192.168.61.16 63797953 Apr 1115 29.921 # + odown master mymaster 192.168.61.16 6379 # quorum 3According 27953 quorum 54.646 # + try-failover master mymaster 13617953 quorum 54.646 # + try-failover master mymaster 192.168.61.16 63797953 quorum 54.648 # + vote-for-leader 36c1c343cc73638eae2177e5a71d4fff92cf0b97 13617953 54.651 # 84bc46cf5364f80a28d073fc012803ce230cdcdc voted for 36c1c343cc73638eae2177e5a71d4fff92cf0b97 13617953 84bc46cf5364f80a28d073fc012803ce230cdcde voted for 36c1c343cc73638eae2177e5a71d4fff92cf0b97 13617953 84bc46cf5364f80a28d073fc012803ce230cdcde voted for 36c1c343cc73638eae2177e5a71d4fff92cf0b97 13617953 elected-leader master mymaster 54.732 # + elected-leader master mymaster 192.168.61.16 63797953 elected-leader master mymaster 554.732 # + failover-state-select-slave master mymaster 192.168.61.16 63797953 Apr 54.808 # + selected-slave slave 192.168.61.176379 192.168.61.17 6379 @ mymaster 192.168.61.17 6379 .16 63797953 Apr 11 Apr 10 Apr 54.808 * + failover-state-send-slaveof-noone slave 192.168.61.17 1979 192.168.61.17 6379 @ mymaster 192.168.61.16 63797953 failover-state-wait-promotion slave 192.168.61.17 failover-state-wait-promotion slave 192.168.61.17 @ mymaster 192.168.61.16 63797953 Apr 05 55.767 # + promoted-slave slave 192.168.61 .17slave-reconf-sent slave 6379 192.168.61.17 6379 @ mymaster 192.168.61.16 63797953 Apr 05 Apr 11 10 mymaster 55.767 # + failover-state-reconf-slaves master mymaster 192.168.61.16 63797953 slave-reconf-sent slave 192.168.61.181979 192.168.61.18 6379 @ mymaster 192.168.61.16 63797953 Apr 05 192.818 #-odown master mymaster 192.168.61.16 63797953 Apr 1110 slave-reconf-inprog slave 56.820 * + 192.168.61.18 mymaster 192.168.61.18 mymaster 192.168.61.16 63797953 mymaster 192.168.61.16 63797953 slave-reconf-done slave 192.168.61.18 6379 @ mymaster 192.168.61.16 63797953 Apr 05 Apr 11slave slave 10slave slave 56.891 # + switch-master mymaster 192.168.61.16 6379 192.168.61.17 63797953 slave slave 192.168.61.18 6379 @ mymaster 192.168.61.17 63797953 Apr 0511slave slave 106.892 * + slave slave 192.168.61.61.192.168.61.16 6379 @ mymaster 192.168.61.17 63797953 slave slave 05 Apr 11:11:11. 932 # + sdown slave 192.168.61.16 sdown slave 6379 192.168.61.16 6379 @ mymaster 192.168.61.17 6379
17 is elected as the new main library, then there will be an action to promote it to the main library.
03:
7732 Apr 05 Apr 11 Apr 192.168.61.16 63797732 Apr 50.921 # + odown master mymaster 192.168.61.16 6379 # quorum 3According to 27732 Apr 05 Apr 11V 54.650 # + new-epoch 13617732X 05 Apr 11mer 104.651 # + vote-for-leader 36c1c343cc73638eae2177e5a71d4fff92cf0b97 13617732X 05 Apr 11 10 Apr 54.716 # Next failover delay: I will not start a failover before Sun Apr 5 11:16:55 20207732 X 05 Apr 11 mymaster 192.168.61.17 26379 @ mymaster 192.168.61.16 63797732 mymaster 55.841 # + switch-master mymaster 192.168.61.16 6379 192.168.61.16 192.168.61.16 6379 192.168.61.17 63797732 X 05 Apr 11v 105.844 * + slave slave 192.168.61.186379 192.168.61.18 6379 @ mymaster 192.168.61.17 63797732VX 05 Apr 11user 55.844 * + slave slave 192.168.61.16 Apr 6379 192.168.61.16 6379 @ mymaster 192.168.61.17 63797732 Apr 11 Apr 11v 10.869 # + sdown slave 192.168.61.16 6379 @ mymaster 192.168.61.17 6379
The node also participated in voting and refactoring.
Pull up the old master library, and the old master library will be added to the cluster as a slave library.
01:
13529 Apr X 05 Apr 11 mymaster 1432. 115 #-sdown slave 192.168.61.16V 6379 192.168.61.17 637913529 @ mymaster 192.168.61.17 637913529 mymaster 192.168.61.16 6379 192.168.61.16 6379 @ mymaster 192.168.61.17 637902 Apr 7953 Apr X 05 1114 fix-slave-config slave 32.573 #-sdown slave 192.168.61.16 61.16 6379 @ mymaster 192.168.61.17 637903 sdown slave 7732 Apr X 05 11V 1432.684 #-sdown slave 192.168.61.16 6379 192.168.61.16 6379 @ mymaster 192.168.61.17 6379
Active handoff:
[root@mdb02] # redis-cli-p 26379 sentinel failover mymaster
OK
01:
13529 Apr X 05 Apr 11 mymaster'13529:X 23 mymaster'13529:X 13.409 # + new-epoch 136213529 X 05 Apr 1115 13.409 # + try-failover master mymaster 192.168.61.17 637913529 new-epoch 1337913529 new-epoch 2313.458 # + vote-for-leader 84bc46cf5364f80a28d073fc012803ce230cdcde 136213529 Apr 1113 13 458 # + elected-leader master mymaster 192.168.61.17 637913529X 05 Apr 11are13.459 # + failover -state-select-slave master mymaster 192.168.61.17 637913529 Apr X 05 Apr 11 selected-slave slave 192.168.61.1679 6379 192.168.61.16 6379 @ mymaster 192.168.61.17 637913529 Apr 1123 Apr 13.512 * + failover-state-send-slaveof-noone slave 192.168.61.16 3379 192.168.61.16 6379 @ mymaster 192.168.61.17 637913529 purl X 05 Apr 11purr 13.589 * + failover-state-wait-promotion slave 192.168.61.16 failover-state-wait-promotion slave 6379 192.168.61.16 6379 @ mymaster 192.168.61.17 637913529 Apr 11V 14.490 # + promoted-slave slave 192.168.61.166379 192.168.61.16 6379 @ mymaster 192.168.61.17 637913529 X 05 Apr 14,490 # + failover-state-reconf-slaves master mymaster 192.168.61.17 637913529X 05 Apr 11rel 2314.516 * + slave -reconf-sent slave 192.168.61.18 reconf-sent slave 6379 192.168.61.18 6379 @ mymaster 192.168.61.17 637913529V 05 Apr 11V 15.579 * + slave-reconf-inprog slave 192.168.61.18V 6379 192.168.61.18 6379 @ mymaster 192.168.61.17 637913529X V 05 Apr 11race 2315.579 * + slave-reconf-done slave 192.168.61.1818 6379 192.168.61.18 6379 @ mymaster. 17 637913529 Apr 11V 2315. 679 # + failover-end master mymaster 192.168.61.17 637913529 Apr 1115. 680 # + switch-master mymaster 192.168.61.17 6379 192.168.61.16 637913529 Apr 11V 2315.680 * + slave slave 192.168.61.18Rd 6379 192.168.61.18 6379 @ mymaster 192.168.61.16 637913529X 05 Apr 11Rue 15.680 * + slave slave 192.168.61. 176379 192.168.61.17 6379 @ mymaster 192.168.61.16 6379
02:
7953 Apr X 05 Apr 1114. 186 # + new-epoch 13627953 Apr 11 Apr 23 14.517 # + config-update-from sentinel 84bc46cf5364f80a28d073fc012803ce230cdcde 192.168.61.16 26379 @ mymaster 192.168.61.17 63797953 Apr 1114. 517 + switch-master mymaster 192.168.61.17 6379 192.168.61.16 63797953 Apr 05 Apr 11race 14.517 * + slave slave 192.168.61.1879 6379 192.168.61.18 6379 @ mymaster 192 .168.61.16 63797953 Apr X 05 11 Apr 23 14. 517 * + slave slave 192.168.61.17 slave slave 6379 192.168.61.17 6379 @ mymaster 192.168.61.16 6379
03:
7732 Apr X 05 Apr 11V 14.186 # + new-epoch 13627732 Apr 11v 2314.519 # + config-update-from sentinel 84bc46cf5364f80a28d073fc012803ce230cdcde 192.168.61.16 26379 @ mymaster 192.168.61.17 63797732 Apr 11v 2314.519 # + switch-master mymaster 192.168.61.17 6379 192.168.61.16 63797732 Apr 05 Apr 11v 2314.519 * + slave slave 192.168.61.1819 6379 192.168.61.18 6379 @ mymaster 192 .168.61.16 63797732 Apr 1114. 519 * + slave slave 192.168.61.17 @ mymaster 192.168.61.17 @ mymaster 192.168.61.16 63797732 Apr 11 Apr 2324.585 * + convert-to-slave slave 192.168.61.176379 192.168.61.17 6379 @ mymaster 192.168.61.16 6379 what is the method of installation, deployment and switching of redis sentinel Sentinel Mode? Thank you for your reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.