In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-06 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
Test environment:
Machine: 192.168.110.132
Redis master port: 6379
Redis slave port: 6380
Redis slave port: 6381
Sentinel port: 26379
Operating system version: CentOS release 6.5 (Final)
Redis version: 3.2.6
Linux system installation redis:
1. Download redis:
Log on to redis's official website https://redis.io/download, to download the latest stable version of the source package redis-3.2.6.tar.gz. Decompress it and compile it.
Tar-zxvf redis-3.2.6.tar.gz
Cd redis-3.2.6/
Make
2. Compile the configuration file redis.conf
Redis.conf profile:
Bind 0.0.0.0protected-mode yesport 6379tcp-backlog 511timeout 0tcp-keepalive 300daemonize yessupervised nopidfile / var/run/redis_6379.pidloglevel noticelogfile "/ tmp/redis6379.log" databases 16save 900 1save 300 10save 60 10000stop-writes-on-bgsave-error yesrdbcompression yesrdbchecksum yesdbfilename dump6379.rdbdir / data/redis/slave-serve-stale-data yesslave-read-only yesrepl-diskless-sync norepl-diskless-sync-delay 5repl-disable-tcp-nodelay noslave-priority 100appendonly yesappendfilename "appendonly6379.aof" appendfsync everysecno-appendfsync-on-rewrite noauto-aof- Rewrite-percentage 100auto-aof-rewrite-min-size 64mbaof-load-truncated yeslua-time-limit 5000slowlog-log-slower-than 10000slowlog-max-len 128latency-monitor-threshold 0notify-keyspace-events "" hash-max-ziplist-entries 512hash-max-ziplist-value 64list-max-ziplist-size-2list-compress-depth 0set-max-intset-entries 512zset-max-ziplist-entries 128zset-max-ziplist-value 64hll-sparse-max-bytes 3000activerehashing yesclient-output-buffer-limit normal 00 0client-output-buffer-limit slave 256mb 64mb 60client-output-buffer-limit pubsub 32mb 8mb 60hz 10aof-rewrite-incremental-fsync yes
Redis6380.cnf profile:
Bind 0.0.0.0protected-mode yesport 6380tcp-backlog 511timeout 0tcp-keepalive 300daemonize yessupervised nopidfile "/ var/run/redis_6380.pid" loglevel noticelogfile "/ tmp/redis6380.log" databases 16save 900 1save 300 10save 60 10000stop-writes-on-bgsave-error yesrdbcompression yesrdbchecksum yesdbfilename "dump6380.rdb" dir "/ data/redis" slave-serve-stale-data yesslave-read-only yesrepl-diskless-sync norepl-diskless-sync-delay 5repl-disable-tcp-nodelay noslave-priority 10appendonly yesappendfilename "appendonly6380.aof" appendfsync everysecno-appendfsync- On-rewrite noauto-aof-rewrite-percentage 100auto-aof-rewrite-min-size 64mbaof-load-truncated yeslua-time-limit 5000slowlog-log-slower-than 10000slowlog-max-len 128latency-monitor-threshold 0notify-keyspace-events "" hash-max-ziplist-entries 512hash-max-ziplist-value 64list-max-ziplist-size-2list-compress-depth 0set-max-intset-entries 512zset-max-ziplist-entries 128zset-max-ziplist-value 64hll-sparse-max-bytes 3000activerehashing yesclient-output-buffer-limit normal 00 0client -output-buffer-limit slave 256mb 64mb 60client-output-buffer-limit pubsub 32mb 8mb 60hz 10aof-rewrite-incremental-fsync yes
Redis6381.conf profile:
Bind 0.0.0.0protected-mode yesport 6381tcp-backlog 511timeout 0tcp-keepalive 300daemonize yessupervised nopidfile "/ var/run/redis_6381.pid" loglevel noticelogfile "/ tmp/redis6381.log" databases 16save 900 1save 300 10save 60 10000stop-writes-on-bgsave-error yesrdbcompression yesrdbchecksum yesdbfilename "dump6381.rdb" dir "/ data/redis" slaveof 192.168.110.132 6380slave-serve-stale-data yesslave-read-only yesrepl-diskless-sync norepl-diskless-sync-delay 5repl-disable-tcp-nodelay noslave-priority 100appendonly yesappendfilename "appendonly6381 .aof "appendfsync everysecno-appendfsync-on-rewrite noauto-aof-rewrite-percentage 100auto-aof-rewrite-min-size 64mbaof-load-truncated yeslua-time-limit 5000slowlog-log-slower-than 10000slowlog-max-len 128latency-monitor-threshold 0notify-keyspace-events"hash-max-ziplist-entries 512hash-max-ziplist-value 64list-max-ziplist-size-2list-compress-depth 0set-max-intset-entries 512zset-max-ziplist-entries 128zset-max-ziplist-value 64hll-sparse-max-bytes 3000activerehashing yesclient-output" -buffer-limit normal 0 0 0client-output-buffer-limit slave 256mb 64mb 60client-output-buffer-limit pubsub 32mb 8mb 60hz 10aof-rewrite-incremental-fsync yes
Sentinel profile:
Bind 0.0.0.0protected-mode yesport 26379dir / tmpsentinel monitor mymaster 192.168.110.132 6379 1sentinel down-after-milliseconds mymaster 10000sentinel parallel-syncs mymaster 1sentinel failover-timeout mymaster 18000
3. Start redis.
Starting redis is very simple, just redis-server / path/redis.conf directly.
Redis-server / usr/local/redis/redis.conf redis-server / usr/local/redis/redis6380.conf redis-server / usr/local/redis/redis6381.conf
4. Check the master-slave status of redis:
Port 6379:
127.0.0.1 hello 6379 > set title helloOK127.0.0.1:6379 > get title "hello" 127.0.0.1 hello 6379 > info Replication# Replicationrole:masterconnected_slaves:1slave0:ip=192.168.110.132,port=6380,state=online,offset=1,lag=0master_repl_offset:1repl_backlog_active:1repl_backlog_size:1048576repl_backlog_first_byte_offset:2repl_backlog_histlen:0
Port 6380:
127.0.0.1 info Replication# Replicationrole:slavemaster_host:192.168.110.132master_port:6379master_link_status:upmaster_last_io_seconds_ago:0master_sync_in_progress:0slave_repl_offset:2115slave_priority:10slave_read_only:1connected_slaves:0master_repl_offset:0repl_backlog_active:0repl_backlog_size:1048576repl_backlog_first_byte_offset:0repl_backlog_histlen:0 6380 > get title "hello" 127.0.0.1
Port 6381:
127.0.0.1 info Replication# Replicationrole:slavemaster_host:192.168.110.132master_port:6379master_link_status:upmaster_last_io_seconds_ago:2master_sync_in_progress:0slave_repl_offset:5970slave_priority:100slave_read_only:1connected_slaves:0master_repl_offset:0repl_backlog_active:0repl_backlog_size:1048576repl_backlog_first_byte_offset:0repl_backlog_histlen:0 > get title "hello" 127.0.0.1
5. Start sentinel:
Redis-server / usr/local/redis/sentinel.conf-- sentinel
6. Kill the port 6379 process of redis and observe failover
46030 Apr X 13 it was originally set to 10 15 it was originally set to 46.085 * Increased maximum number of open files to 10032. _. _.-`. `_. '' -. _ Redis 3.2.6 (00000000Universe 0) 64 bit.-``.- ```. ```\ / _., _'-. _ (.-`|` ) Running in sentinel mode | `-. _`...-.`` -. _ |'`_. -'| Port: 26379 |` -. _ `. _ / _. -'| PID: 46030` -. _ `-. _`. / _. -'_. -'| `-. `-. _` -'_. | | `-. _` -. _ _. -'_. -'| http://redis.io `-. _` -. _ _. -'. | | `-. _` -. _ `. -'_. -'| |` -. _ `-. -'_. -'. _. -'`-. _`. -'. 46030 cannot be enforced because 13 Apr 10 WARNING: The TCP backlog setting of 511 cannot be enforced because / proc/sys/net/core/somaxconn is set to the lower value of 128.46030 proc/sys/net/core/somaxconn is set to the lower value of 13 Apr 10 15 cannot be enforced because 46.097 # Sentinel ID is 89f3e9eeacc7b99b9c95d7c20d25a241d6c1ccd946030:X 13 Apr 10 15 slave slave + monitor master mymaster 192.168.110.132 6379 quorum 146030 cannot be enforced because 13 Apr 1015 slave slave 192.168.110.132 6380 192.168.110.132 637946030 mymaster 192.168.110.132 637946030 slave slave 192.168.110.132 637946030 slave slave 192.168.110.132 6381 192.168.110.132 6381 @ mymaster 192.168.110.132 637946030X Apr mymaster 192.168.110.132 637946030 slave slave 192.168.110.132 6379 # quorum 192.168.110.132 6379 # quorum 192.146030: X 13 Apr 10 try-failover master mymaster 1937 344 # + try-failover master mymaster 192.168.110.132 637946030 Apr 13 Apr 10 19Apr 37.344 # + elected-leader master mymaster 192.168.110.132 637946030 Apr 1937 348 # + failover-state-select-slave master mymaster 192.168.110.132 637946030 Apr 1937.348 # + failover-state-select-slave master mymaster 192.168.110.132 637946030 Apr 1019 : 37.415 # + selected-slave slave 192.168.110.132 6380 192.168.110.132 637946030 mymaster 192.168.110.132 637946030 failover-state-send-slaveof-noone slave 192.168.110.132 6380 192.168.110.132 6380 @ mymaster 192.168.110.132 6380 @ mymaster 192.168.110.132 637946030 failover-state-send-slaveof-noone slave 192.168.110.132 13 Apr 1030 failover-state-send-slaveof-noone slave 192.168.110.132 192.168.110. 1332 6380 @ mymaster 192.168.110.132 637946030 promoted-slave slave 192.168.110.132 6380 192.168.110.132 6380 @ mymaster 192.168.110.132 637946030X 13 Apr 10 Apr 1937.983 # + failover-state-reconf-slaves master mymaster 192.168.110.132 637946030 promoted-slave slave 192.168.110.132 637946030 promoted-slave slave 192.168.110.132 132mer 6381 192.168.110.132 6381 192.168.110.132 6381 Mymaster 192.168.110.132 637946030 Apr 10 slave-reconf-inprog slave 192.168.110.132 6381 192.168.110.132 6381 @ mymaster 192.168.110.132 637946030 slave-reconf-inprog slave 39.217 * + slave-reconf-done slave 192.168.110.132 0.132 6381 192.168.110.132 6381 @ mymaster 192.168.110.132 637946030 slave-reconf-inprog slave 192.168.110.132 637946030 slave-reconf-inprog slave 192.168.110.132 637946030 slave-reconf-inprog slave 192.168.110.132 637946030 slave-reconf-inprog slave 192.168.110.132 637946030 slave-reconf-inprog slave 192.168.110.132 637946030 slave-reconf-inprog slave 192.168.110.132 637946030 slave-reconf-inprog slave 192.168.110.132 637946030 slave-reconf-inprog slave 192.168.110.132 637946030 slave-reconf-inprog slave 192.168.110.132 637946030 slave-reconf-inprog slave 192.168.110.132 637946030 slave-reconf-inprog slave 192.168.110.132 637946030 slave-reconf-inprog slave 192.168.110.132 63794 110.132 637946030 Apr X 13 Apr 10 Apr 1939.299 # + switch-master mymaster 192.168.110.132 6379 192.168.110.132 638046030 Apr 10 19Vo 39.299 * + slave slave 192.168.110.132 Apr 10 1981 192.168.110.132 6381 @ mymaster 192.168.110.132 638046030 slave slave 192.168.110.132 68046030 slave slave 192.168.110.132 192.168.110.132 6379 192.168.110.132 6379 @ mymaster 192.168.110.132 638046030 13 Apr 10 mymaster 1919 49.319 # + sdown slave 192.168.110.132 Virgo 6379 192.168.110.132 6379 @ mymaster
Because the slave-priority in the configuration file of 6380 is configured as 10, which is smaller than that of slave-priority of 6381, 6380 is preferred as master. Because down-after-milliseconds is set to 10s in the sentinel configuration file, failover automatically elects 6380 as the new master after confirming master down after 10s.
7. View the log:
When 6380 is elected as the new master, the original 6381 will repoint to 6380 and clean up its own old data, re-sync the full data from 6380.
6380 of the log:
45995 Apr S 13 Apr 10 Apr 19V 37.342 # Error condition on socket for SYNC: Connection refused45995:M 13 Apr 10 V 19V 37.477 * Discarding previously cached master state.45995:M 13 Apr 10 V 19V 37.478 * MASTER MODE enabled (user request from 'id=4 addr=192.168.110.132:46885 fd=7 name=sentinel-89f3e9ee-cmd age=231 idle=0 flags=x db=0 sub=0 psub=0 multi=3 qbuf=0 qbuf-free=32768 obl=36 oll=0 omem=0 events=r cmd=exec') 45995 V M 13 Apr 10 V 19V 37.478 # CONFIG REWRITE executed with success.45995:M 13 Apr 10 : 19Apr 38.755 * Slave 192.168.110.132 asks for synchronization45995:M 13 Apr 10 Apr 1938.755 * Full resync requested by slave 192.168.110.132V 638145995 Full resync requested by slave 13 Apr 10 19V 38.755 * Starting BGSAVE for SYNC with target: disk45995:M 13 Apr 10 V 1938.756 * Background saving started by pid 460506050 C 13 Apr 10 V V 1938.766 * DB saved on disk46050:C 13 Apr 10 19V 38.767 * RDB: 0 MB of memory used by Copy-on-write45995:M 13 Apr 10 Background saving terminated with success45995:M 13 Apr 10 Apr 1915 Synchronization with slave 192.168.110.132 Background saving terminated with success45995:M 6381 succeeded
6381 of the log:
46039 Apr S 13 Apr 10 Apr 19V 37.746 # Error condition on socket for SYNC: Connection refused46039:S 13 Apr 10 V 19V 38.051 * Discarding previously cached master state.46039:S 13 Apr 10 V 19V 38.051 * SLAVE OF 192.168.110.132 V 6380 enabled (user request from 'id=4 addr=192.168.110.132:41739 fd=7 name=sentinel-89f3e9ee-cmd age=182 idle=0 flags=x db=0 sub=0 psub=0 multi=3 qbuf=145 qbuf-free=32623 obl=36 oll=0 omem=0 events=r cmd=exec') 46039 V V 13 Apr 10 19V 38.052 # CONFIG REWRITE executed With success.46039:S 13 Apr 10 Connecting to MASTER 1938. 755 * Connecting to MASTER 192.168.110.132 Connecting to MASTER 638046039 Apr 10 Apr 10 MASTER SLAVE sync started46039:S 13 Apr 10 Vol 19 Vol 38.755 * Non blocking connect for SYNC fired the event.46039:S 13 Apr 10 Vol 19 Vol 38.755 * Master replied to PING Replication can continue...46039:S 13 Apr 10 bytes from master46039:S 1938. 755 * Partial resynchronization not possible (no cached master) 46039. S 13 Apr 10 Partial resynchronization not possible 1938. 756 * Full resync from master: 065cade6f55c04c839436d5d0d2c6abc56a5d862:146039:S 13 Apr 10 Apr 1938. 855 * MASTER SLAVE sync: receiving 102 bytes from master46039:S 13 Apr 10 no cached master 1938. 855 * MASTER SLAVE sync: Flushing old data46039:S 13 Apr 10 no cached master 1938. 855 * MASTER SLAVE sync: Loading DB in memory46039:S 13 Apr 10 * MASTER SLAVE sync: Finished with success46039:S 13 Apr 10 Background append only file rewriting started by pid 4605146039 Background append only file rewriting started by pid 13 Apr 10 Apr 19V 38.897 * AOF rewrite child asks to stop sending diffs.46051:C 13 Apr 10 V 38.897 * Parent agreed to stop sending diffs. Finalizing AOF...46051:C 13 Apr 10 MB of AOF diff received from parent.46051:C 19 Apr 38.897 * SYNC append only file rewrite performed46051:C 13 Apr 10 Apr 19 Apr 38.897 * AOF rewrite: 0 MB of memory used by copy-on-write46039:S 13 Apr 10 Background AOF rewrite terminated with success46039:S 10 Residual parent diff successfully flushed to the rewritten AOF (0.00 MB) 46039 Apr 13 Apr 10 changes in 19 seconds 38.956 * Background AOF rewrite finished successfully46039:S 13 Apr 10 Apr 31 097 * 1 changes in 900 seconds. Saving...46039:S 13 Apr 10 Apr 31 Background saving started by pid 31.097 * Background saving started by pid 4607146071 13 Apr 10 Apr 31 1.109 * DB saved on disk46071:C 13 Apr 10 DB saved on disk46071:C 10 31 1V 31.109 * RDB: 0 MB of memory used by copy-on-write46039:S 13 Apr 10 15 V 31.198 * Background saving terminated with success
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.