Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Redis automatic master-slave switching

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

127.0.0.1 7000 master

127.0.0.1 7001 slave

127.0.0.1 7002 slave

127.0.0.1 7003 slave

View the slave connected above the master

Redis-cli-p 7000 info Replication

# Replication

Role:master

Connected_slaves:3

Slave0:ip=127.0.0.1,port=7001,state=online,offset=2532,lag=0

Slave1:ip=127.0.0.1,port=7002,state=online,offset=2532,lag=0

Slave2:ip=127.0.0.1,port=7003,state=online,offset=2532,lag=1

Master_repl_offset:2532

Repl_backlog_active:1

Repl_backlog_size:1048576

Repl_backlog_first_byte_offset:2

Repl_backlog_histlen:2531

Create a sentinel profile

Vim / redis_test/7000/sentinel.conf

Port 26379

Sentinel monitor master 127.0.0.1 7000 2

Sentinel down-after-milliseconds master 5000

Sentinel failover-timeout master 60000

Sentinel config-epoch master 12

Vim / redis_test/7001/sentinel.conf

Port 26479

Sentinel monitor master 127.0.0.1 7000 2

Sentinel down-after-milliseconds master 5000

Sentinel failover-timeout master 60000

Sentinel config-epoch master 12

Vim / redis_test/7002/sentinel.conf

Port 26579

Sentinel monitor master 127.0.0.1 7000 2

Sentinel down-after-milliseconds master 5000

Sentinel failover-timeout master 60000

Sentinel config-epoch master 12

Start sentinel

/ usr/src/redis/src/redis-server / redis_database/7000/sentinel.conf-- sentinel &

/ usr/src/redis/src/redis-server / redis_database/7001/sentinel.conf-- sentinel &

/ usr/src/redis/src/redis-server / redis_database/7002/sentinel.conf-- sentinel &

Turn off master 7000

Redis-cli-p 7000 shutdown

Redis-cli-p 7002 info replication

# Replication

Role:master

Connected_slaves:2

Slave0:ip=127.0.0.1,port=7001,state=online,offset=6345,lag=0

Slave1:ip=127.0.0.1,port=7003,state=online,offset=6345,lag=0

Master_repl_offset:6345

Repl_backlog_active:1

Repl_backlog_size:1048576

Repl_backlog_first_byte_offset:2

Repl_backlog_histlen:6344

You can find that 7002 has become the new main library.

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.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report