Home  >  Article  >  Database  >  What are the problems encountered in redis replication?

What are the problems encountered in redis replication?

WBOY
WBOYforward
2023-05-28 22:43:321280browse

Failure to see data synchronization for a long time may lead to the mistaken belief that the replication function is invalid or the configuration is incorrect. In this case, you may consider using the salveof command. Don't worry, there are two ways to determine whether replication is being established.

When creating redis replication, you may find that the slave does not start to synchronize data for a long time. The amount of data may be too large, causing the master to be slow in dumping data. At this time, you can execute top -p $ on the master. {pgrep -d,redis-sever} command, you can see the dump process.

[root@img1_u ~]# top -p $(pgrep -d, redis-server)
top - 14:06:24 up 54 days,  6:13,  1 user,  load average: 1.18, 1.32, 1.20
Tasks:   2 total,   1 running,   1 sleeping,   0 stopped,   0 zombie
Cpu(s): 15.2%us,  1.7%sy,  0.6%ni, 81.9%id,  0.2%wa,  0.0%hi,  0.4%si,  0.0%st
Mem:  24542176k total, 22771848k used,  1770328k free,  2245720k buffers
Swap:   524280k total,        0k used,   524280k free,  4369452k cached

  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND
21619 root      20   0 5654m 5.4g  388 R 99.9 23.0   0:23.70 redis-server
 1663 root      20   0 5654m 5.4g 1068 S 15.3 23.0   5042:31 redis-server

redis-server is a single process. Now you can check there are 2 processes through the top command. Because as mentioned before, when redis establishes replication, it will execute the bgsave command on the main service and fork one. Subprocess, dump RDB file. First complete the dump of the master database, and then transfer the snapshot file to the slave database

Method 2: Enter the master's redis-cli through the rdb_bgsave_in_progress identifier

When rdb_bgsave_in_progress When the value is 1, it means that the main server is executing the background save command (bgsave). rdb_current_bgsave_time_sec indicates the execution time of the bgsave command. Since RDB and AOF logs are not enabled by default on the master server, if rdb_bgsave_in_progress is 1, then you can definitely send a bgsave command to dump the RDB file due to replication reasons.

The above is the detailed content of What are the problems encountered in redis replication?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:yisu.com. If there is any infringement, please contact admin@php.cn delete