Redis主备数据库同步错误
06 April 2017
问题描述
在两台redis上同步数据数据出现如下错误
[18245] 21 Nov 18:01:44 # Can't handle RDB format version 2
[18245] 21 Nov 18:01:44 # Failed trying to load the MASTER synchronization DB from disk
原因
redis的备机版本小于主机redis版本,升级版本即可
参考链接:
https://github.com/antirez/redis/issues/203
Ask:
Redis 2.4.3 Master
Redis 2.2.8 Slave
Infinte loop trying to sync with master:
[18245] 21 Nov 18:01:38 * Connecting to MASTER...
[18245] 21 Nov 18:01:40 * MASTER <-> SLAVE sync started: SYNC sent
[18245] 21 Nov 18:01:43 * MASTER <-> SLAVE sync: receiving 61774440 bytes from master
[18245] 21 Nov 18:01:44 * MASTER <-> SLAVE sync: Loading DB in memory
[18245] 21 Nov 18:01:44 # Can't handle RDB format version 2
[18245] 21 Nov 18:01:44 # Failed trying to load the MASTER synchronization DB from disk
This ended up making both machines (master and slave) using 100% CPU and a lot of network.
Answer:
Hi, you can't use a Redis slave that is older than the master.
Even the reverse is discouraged in the long run if not used just for the upgrade of the system. So the rules to follow are:
Always have slaves with version >= the one of the master.
When upgrading Redis upgrade both master and slave. To do it incrementally it is safe to start a slave that is newer than the master, but then upgrade the master as well ASAP.