主库发生RDB以及缓存命令到从库:
- 33565:M 26 Aug 2019 11:54:48.918 * Replica 127.0.0.1:6380 asks for synchronization
- 33565:M 26 Aug 2019 11:54:48.918 * Partial resynchronization not accepted: Replication ID mismatch (Replica asked for 'fc71b19242e8145254ba7751d346a8f4bb4c53c6', my replication IDs are '1e531f295fc2dcf986a18889e8f8c3b6e6fdc7b6' and '0000000000000000000000000000000000000000')
- 33565:M 26 Aug 2019 11:54:48.918 * Starting BGSAVE for SYNC with target: disk
- 33565:M 26 Aug 2019 11:54:48.919 * Background saving started by pid 33574
- 33574:C 26 Aug 2019 11:54:48.929 * DB saved on disk
- 33574:C 26 Aug 2019 11:54:48.929 * RDB: 4 MB of memory used by copy-on-write
- 33565:M 26 Aug 2019 11:54:49.002 * Background saving terminated with success
- 33565:M 26 Aug 2019 11:54:49.003 * Synchronization with replica 127.0.0.1:6380 succeeded
场景二,中断后同步
如果由于某种故障导致了从数据库暂停了与主数据库的同步后,从数据库重新连接到主数据库,主数据库只需要将中断期间执行的命令传送到从库(基于命令记录格式),这样就可以继续进行同步,保持数据一致性。
注:该特效在Redis 2.8版本后实现,2.6版本之前均需要重新初始化。
简易过程如下:
(1) 模拟从库中断,将其kill掉
- [redis@albert src]$ ps -ef | grep redis
- redis 33565 33500 0 11:54 pts/4 00:00:01 ./redis-server *:6379
- redis 33570 33476 0 11:54 pts/5 00:00:01 ./redis-server 127.0.0.1:6380
- redis 33744 33688 0 12:03 pts/0 00:00:00 ./redis-server 127.0.0.1:6382
- [redis@albert src]$
- [redis@albert src]$ kill -9 33744
(2) 主库接收到中断信息
- 33565:M 26 Aug 2019 12:03:17.736 * Replica 127.0.0.1:6382 asks for synchronization
- 33565:M 26 Aug 2019 12:03:17.736 * Partial resynchronization request from 127.0.0.1:6382 accepted. Sending 714 bytes of backlog starting from offset 1.
- 33565:M 26 Aug 2019 12:13:43.494 # Connection with replica 127.0.0.1:6382 lost.
(3) 根据偏移量进行同步
- 33565:M 26 Aug 2019 12:14:12.019 * Replica 127.0.0.1:6382 asks for synchronization
- 33565:M 26 Aug 2019 12:14:12.019 * Partial resynchronization request from 127.0.0.1:6382 accepted. Sending 436 bytes of backlog starting from offset 1315.
场景三,增量复制 (编辑:西安站长网)
【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!
|