加入收藏 | 设为首页 | 会员中心 | 我要投稿 西安站长网 (https://www.029zz.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 建站 > 正文

一文带你揭开Redis复制原理的神秘面纱

发布时间:2019-09-17 12:29:18 所属栏目:建站 来源:陈龙
导读:副标题#e# Redis作为一个非结构化的内存数据库,在某些应用场景具备相应优势,在实际的场景设计中也得到广泛的关注和使用。但是,大部分企业的Redis数据库架构为单机运行,没有设计容灾复制,这样对于Redis的容错特性没有发挥出来,而且无持久化情况下,数

从数据库1同步到缓存:

  1. 127.0.0.1:6380> keys * 
  2. 1) "test02" 
  3. 2) "c" 
  4. 3) "d" 
  5. 4) "a" 
  6. 5) "test" 
  7. 6) "kebo" 
  8. 7) "slavetest" 
  9. 8) "b" 
  10. 9) "redisfast" 
  11. 127.0.0.1:6380> get slavetest 
  12. "0851" 

重启从数据库2:

  1. 34855:S 26 Aug 2019 13:34:39.561 * DB loaded from disk: 0.000 seconds 
  2. 34855:S 26 Aug 2019 13:34:39.561 * Before turning into a replica, using my master parameters to synthesize a cached master: I may be able to synchronize with the new master with just a partial transfer. 
  3. 34855:S 26 Aug 2019 13:34:39.561 * Ready to accept connections 
  4. 34855:S 26 Aug 2019 13:34:39.561 * Connecting to MASTER 127.0.0.1:6379 
  5. 34855:S 26 Aug 2019 13:34:39.561 * MASTER <-> REPLICA sync started 
  6. 34855:S 26 Aug 2019 13:34:39.561 * Non blocking connect for SYNC fired the event. 
  7. 34855:S 26 Aug 2019 13:34:39.561 * Master replied to PING, replication can continue... 
  8. 34855:S 26 Aug 2019 13:34:39.562 * Trying a partial resynchronization (request d41f950be7593a93620b1fd872b7552668f0b355:888). 
  9. 34855:S 26 Aug 2019 13:34:39.562 * Successful partial resynchronization with master. 
  10. 34855:S 26 Aug 2019 13:34:39.562 * MASTER <-> REPLICA sync: Master accepted a Partial Resynchronization. 

从库启动后,加载本地数据,开始向主数据库进行请求同步,这里同步起点是根据从数据库的offset开始。

(编辑:西安站长网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

热点阅读