{"id":71202,"date":"2024-08-20T10:31:10","date_gmt":"2024-08-20T02:31:10","guid":{"rendered":"http:\/\/lrxjmw.cn\/?p=71202"},"modified":"2024-08-20T10:31:10","modified_gmt":"2024-08-20T02:31:10","slug":"redis-high-availability","status":"publish","type":"post","link":"https:\/\/lrxjmw.cn\/redis-high-availability.html","title":{"rendered":"Redis\u00a0\u9ad8\u53ef\u7528\u6027\u5b9e\u8df5"},"content":{"rendered":"
Redis \u662f\u4e00\u4e2a\u5f00\u6e90\u7684\u4f7f\u7528 ANSI C \u8bed\u8a00\u7f16\u5199\u3001\u652f\u6301\u7f51\u7edc\u3001\u53ef\u57fa\u4e8e\u5185\u5b58\u4ea6\u53ef\u6301\u4e45\u5316\u7684\u65e5\u5fd7\u578b\u3001Key-Value \u6570\u636e\u5e93\uff0c\u5e76\u63d0\u4f9b\u591a\u79cd\u8bed\u8a00\u7684 API\u3002<\/p>\n
\u5982\u4eca\uff0c\u4e92\u8054\u7f51\u4e1a\u52a1\u7684\u6570\u636e\u6b63\u4ee5\u66f4\u5feb\u7684\u901f\u5ea6\u5728\u589e\u957f\uff0c\u6570\u636e\u7c7b\u578b\u8d8a\u6765\u8d8a\u4e30\u5bcc\uff0c\u8fd9\u5bf9\u6570\u636e\u5904\u7406\u7684\u901f\u5ea6\u548c\u80fd\u529b\u63d0\u51fa\u4e86\u66f4\u9ad8\u8981\u6c42\u3002Redis \u662f\u4e00\u79cd\u5f00\u6e90\u7684\u5185\u5b58\u975e\u5173\u7cfb\u578b\u6570\u636e\u5e93\uff0c\u7ed9\u5f00\u53d1\u4eba\u5458\u5e26\u6765\u7684\u4f53\u9a8c\u662f\u98a0\u8986\u6027\u7684\u3002\u5728\u81ea\u59cb\u81f3\u7ec8\u7684\u8bbe\u8ba1\u8fc7\u7a0b\u4e2d\uff0c\u90fd\u5145\u5206\u8003\u8651\u9ad8\u6027\u80fd\uff0c\u8fd9\u4f7f\u5f97 Redis \u6210\u4e3a\u5f53\u4eca\u901f\u5ea6\u6700\u5feb\u7684 NoSQL \u6570\u636e\u5e93\u3002<\/p>\n
\u8003\u8651\u9ad8\u6027\u80fd\u7684\u540c\u65f6\uff0c\u9ad8\u53ef\u7528\u4e5f\u662f\u5f88\u91cd\u8981\u7684\u8003\u8651\u56e0\u7d20\u3002\u4e92\u8054\u7f51 7\u00d724 \u65e0\u95f4\u65ad\u670d\u52a1\uff0c\u5728\u6545\u969c\u671f\u95f4\u4ee5\u6700\u5feb\u7684\u901f\u5ea6 Failover\uff0c\u80fd\u7ed9\u4f01\u4e1a\u5e26\u6765\u6700\u5c0f\u7684\u635f\u5931\u3002<\/p>\n
\u90a3\u4e48\uff0c\u5728\u5b9e\u9645\u5e94\u7528\u4e2d\uff0c\u90fd\u6709\u54ea\u4e9b\u9ad8\u53ef\u7528\u67b6\u6784\u5462\uff1f\u67b6\u6784\u4e4b\u95f4\u6709\u4f55\u4f18\u52a3\uff1f\u6211\u4eec\u5e94\u8be5\u600e\u4e48\u53d6\u820d\uff1f\u6709\u54ea\u4e9b\u6700\u4f73\u5b9e\u8df5\uff1f<\/p>\n
\u5728\u8bb2\u89e3 Redis \u9ad8\u53ef\u7528\u65b9\u6848\u4e4b\u524d\uff0c\u6211\u4eec\u5148\u6765\u770b\u770b\u00a0Redis Sentinel<\/a>\u00a0\u539f\u7406<\/strong>\u662f\u600e\u4e48\u6837\u7684\u3002<\/p>\n 1 \u5230 3 \u662f\u81ea\u52a8\u53d1\u73b0\u673a\u5236:<\/p>\n 4 \u662f\u68c0\u6d4b\u673a\u5236\uff0c5 \u548c 6 \u662f failover \u673a\u5236\uff0c7 \u662f\u66f4\u65b0\u914d\u7f6e\u673a\u5236\u3002[1]<\/p>\n \u8bb2\u89e3\u5b8c Redis Sentinel \u539f\u7406\u4e4b\u540e\uff0c\u63a5\u4e0b\u6765\u8bb2\u89e3\u5e38\u7528\u7684\u00a0Redis \u9ad8\u53ef\u7528\u67b6\u6784<\/strong>\u3002<\/p>\n \u63a5\u4e0b\u6765\u914d\u5408\u56fe\u6587\u9010\u4e2a\u8bb2\u89e3\u3002<\/p>\n <\/p>\n \u4e0a\u56fe\u662f\u5df2\u7ecf\u5728\u7ebf\u4e0a\u73af\u5883\u5e94\u7528\u7684\u65b9\u6848\u3002\u5e95\u5c42\u662f Redis Sentinel \u96c6\u7fa4\uff0c\u4ee3\u7406\u7740 Redis \u4e3b\u4ece\uff0cWeb \u7aef\u8fde\u63a5\u5185\u7f51 DNS \u63d0\u4f9b\u670d\u52a1\u3002\u5185\u7f51 DNS \u6309\u7167\u4e00\u5b9a\u7684\u89c4\u5219\u5206\u914d\uff0c\u6bd4\u5982\u00a0xxxx.redis.cache\/queue.port.xxx.xxx<\/span>\uff0c\u7b2c\u4e00\u4e2a\u6bb5\u8868\u793a\u4e1a\u52a1\u7b80\u5199\uff0c\u7b2c\u4e8c\u4e2a\u6bb5\u8868\u793a\u8fd9\u662f Redis \u5185\u7f51\u57df\u540d\uff0c\u7b2c\u4e09\u4e2a\u6bb5\u8868\u793a Redis \u7c7b\u578b\uff0ccache \u8868\u793a\u7f13\u5b58\uff0cqueue \u8868\u793a\u961f\u5217\uff0c\u7b2c\u56db\u4e2a\u6bb5\u8868\u793a Redis \u7aef\u53e3\uff0c\u7b2c\u4e94\u3001\u7b2c\u516d\u4e2a\u6bb5\u8868\u793a\u5185\u7f51\u4e3b\u57df\u540d\u3002<\/p>\n \u5f53\u4e3b\u8282\u70b9\u53d1\u751f\u6545\u969c\uff0c\u6bd4\u5982\u673a\u5668\u6545\u969c\u3001Redis \u8282\u70b9\u6545\u969c\u6216\u8005\u7f51\u7edc\u4e0d\u53ef\u8fbe\uff0cSentinel \u96c6\u7fa4\u4f1a\u8c03\u7528\u00a0client-reconfig-script<\/span>\u00a0\u914d\u7f6e\u7684\u811a\u672c\uff0c\u4fee\u6539\u5bf9\u5e94\u7aef\u53e3\u7684\u5185\u7f51\u57df\u540d\u3002\u5bf9\u5e94\u7aef\u53e3\u7684\u5185\u7f51\u57df\u540d\u6307\u5411\u65b0\u7684 Redis \u4e3b\u8282\u70b9\u3002<\/p>\n \u4f18\u70b9\uff1a<\/p>\n \u7f3a\u70b9\uff1a<\/p>\n <\/p>\n \u6b64\u65b9\u6848\u548c\u4e0a\u4e00\u4e2a\u65b9\u6848\u76f8\u6bd4\uff0c\u7565\u6709\u4e0d\u540c\u3002\u7b2c\u4e00\u4e2a\u65b9\u6848\u4f7f\u7528\u4e86\u5185\u7f51 DNS\uff0c\u7b2c\u4e8c\u4e2a\u65b9\u6848\u628a\u5185\u7f51 DNS \u6362\u6210\u4e86\u865a\u62df IP\u3002\u5e95\u5c42\u662f Redis Sentinel \u96c6\u7fa4\uff0c\u4ee3\u7406\u7740 Redis \u4e3b\u4ece\uff0cWeb \u7aef\u901a\u8fc7 VIP \u63d0\u4f9b\u670d\u52a1\u3002\u5728\u90e8\u7f72 Redis \u4e3b\u4ece\u7684\u65f6\u5019\uff0c\u9700\u8981\u5c06\u865a\u62df IP \u7ed1\u5b9a\u5230\u5f53\u524d\u7684 Redis \u4e3b\u8282\u70b9\u3002\u5f53\u4e3b\u8282\u70b9\u53d1\u751f\u6545\u969c\uff0c\u6bd4\u5982\u673a\u5668\u6545\u969c\u3001Redis \u8282\u70b9\u6545\u969c\u6216\u8005\u7f51\u7edc\u4e0d\u53ef\u8fbe\uff0cSentinel \u96c6\u7fa4\u4f1a\u8c03\u7528\u00a0client-reconfig-script<\/span>\u00a0\u914d\u7f6e\u7684\u811a\u672c\uff0c\u5c06 VIP \u6f02\u79fb\u5230\u65b0\u7684\u4e3b\u8282\u70b9\u4e0a\u3002<\/p>\n \u4f18\u70b9\uff1a<\/p>\n \u7f3a\u70b9\uff1a<\/p>\n <\/p>\n \u90e8\u5206\u4e1a\u52a1\u53ea\u80fd\u901a\u8fc7\u5916\u7f51\u8bbf\u95ee Redis\uff0c\u4e0a\u8ff0\u4e24\u79cd\u65b9\u6848\u5747\u4e0d\u53ef\u7528\uff0c\u4e8e\u662f\u884d\u751f\u51fa\u4e86\u8fd9\u79cd\u65b9\u6848\u3002Web \u4f7f\u7528\u5ba2\u6237\u7aef\u8fde\u63a5\u5176\u4e2d\u4e00\u53f0 Redis Sentinel \u96c6\u7fa4\u4e2d\u7684\u4e00\u53f0\u673a\u5668\u7684\u67d0\u4e2a\u7aef\u53e3\uff0c\u7136\u540e\u901a\u8fc7\u8fd9\u4e2a\u7aef\u53e3\u83b7\u53d6\u5230\u5f53\u524d\u7684\u4e3b\u8282\u70b9\uff0c\u7136\u540e\u518d\u8fde\u63a5\u5230\u771f\u5b9e\u7684 Redis \u4e3b\u8282\u70b9\u8fdb\u884c\u76f8\u5e94\u7684\u4e1a\u52a1\u5458\u64cd\u4f5c\u3002\u9700\u8981\u6ce8\u610f\u7684\u662f\uff0cRedis Sentinel \u7aef\u53e3\u548c Redis \u4e3b\u8282\u70b9\u5747\u9700\u8981\u5f00\u653e\u8bbf\u95ee\u6743\u9650\u3002\u5982\u679c\u524d\u7aef\u4e1a\u52a1\u4f7f\u7528 Java\uff0c\u6709 JedisSentinelPool \u53ef\u4ee5\u590d\u7528\uff1b\u5982\u679c\u524d\u7aef\u4e1a\u52a1\u4f7f\u7528 PHP\uff0c\u53ef\u4ee5\u5728 phpredis \u7684\u57fa\u7840\u4e0a\u505a\u4e8c\u6b21\u5c01\u88c5\u3002<\/p>\n \u4f18\u70b9\uff1a<\/p>\n \u7f3a\u70b9\uff1a<\/p>\n <\/p>\n \u5e95\u5c42\u662f Redis Sentinel \u96c6\u7fa4\uff0c\u4ee3\u7406\u7740 Redis \u4e3b\u4ece\uff0cWeb \u7aef\u901a\u8fc7 VIP \u63d0\u4f9b\u670d\u52a1\u3002\u5f53\u4e3b\u8282\u70b9\u53d1\u751f\u6545\u969c\uff0c\u6bd4\u5982\u673a\u5668\u6545\u969c\u3001Redis \u8282\u70b9\u6545\u969c\u6216\u8005\u7f51\u7edc\u4e0d\u53ef\u8fbe\uff0cRedis \u4e4b\u95f4\u7684\u5207\u6362\u901a\u8fc7 Redis Sentinel \u5185\u90e8\u673a\u5236\u4fdd\u969c\uff0cVIP \u5207\u6362\u901a\u8fc7 Keepalived \u4fdd\u969c\u3002<\/p>\n \u4f18\u70b9\uff1a<\/p>\n \u7f3a\u70b9\uff1a<\/p>\n <\/p>\n \u6b64\u65b9\u6848\u6ca1\u6709\u4f7f\u7528\u5230 Redis Sentinel\u3002\u6b64\u65b9\u6848\u4f7f\u7528\u4e86\u539f\u751f\u7684\u4e3b\u4ece\u548c Keepalived\uff0cVIP \u5207\u6362\u901a\u8fc7 Keepalived \u4fdd\u969c\uff0cRedis \u4e3b\u4ece\u4e4b\u95f4\u7684\u5207\u6362\u9700\u8981\u81ea\u5b9a\u4e49\u811a\u672c\u5b9e\u73b0\u3002<\/p>\n \u4f18\u70b9\uff1a<\/p>\n \u7f3a\u70b9\uff1a<\/p>\n <\/p>\n From:\u00a0http:\/\/intro2libsys.com\/focused-redis-topics\/day-one\/intro-redis-cluster<\/a><\/p>\n Redis 3.0.0<\/a>\u00a0\u5728 2015 \u5e74 4 \u6708 2 \u65e5\u6b63\u5f0f\u53d1\u5e03\uff0c\u8ddd\u4eca\u5df2\u6709\u4e24\u5e74\u591a\u7684\u65f6\u95f4\u3002Redis \u96c6\u7fa4\u91c7\u7528 P2P \u6a21\u5f0f\uff0c\u65e0\u4e2d\u5fc3\u5316\u3002\u628a key \u5206\u6210 16384 \u4e2a slot\uff0c\u6bcf\u4e2a\u5b9e\u4f8b\u8d1f\u8d23\u4e00\u90e8\u5206 slot\u3002\u5ba2\u6237\u7aef\u8bf7\u6c42\u5bf9\u5e94\u7684\u6570\u636e\uff0c\u82e5\u8be5\u5b9e\u4f8b slot \u6ca1\u6709\u5bf9\u5e94\u7684\u6570\u636e\uff0c\u8be5\u5b9e\u4f8b\u4f1a\u8f6c\u53d1\u7ed9\u5bf9\u5e94\u7684\u5b9e\u4f8b\u3002\u53e6\u5916\uff0cRedis \u96c6\u7fa4\u901a\u8fc7 Gossip \u534f\u8bae\u540c\u6b65\u8282\u70b9\u4fe1\u606f\u3002<\/p>\n \u4f18\u70b9\uff1a<\/p>\n \u7f3a\u70b9\uff1a<\/p>\n <\/p>\n From:\u00a0http:\/\/engineering.bloomreach.com\/the-evolution-of-fault-tolerant-redis-cluster<\/a><\/p>\n \u591a\u4e2a\u540c\u6784\u00a0Twemproxy<\/a>\uff08\u914d\u7f6e\u76f8\u540c\uff09\u540c\u65f6\u5de5\u4f5c\uff0c\u63a5\u53d7\u5ba2\u6237\u7aef\u7684\u8bf7\u6c42\uff0c\u6839\u636e hash \u7b97\u6cd5\uff0c\u8f6c\u53d1\u7ed9\u5bf9\u5e94\u7684 Redis\u3002<\/p>\n Twemproxy \u65b9\u6848\u6bd4\u8f83\u6210\u719f\u4e86\uff0c\u4e4b\u524d\u6211\u4eec\u56e2\u961f\u957f\u671f\u4f7f\u7528\u6b64\u65b9\u6848\uff0c\u4f46\u662f\u6548\u679c\u5e76\u4e0d\u662f\u5f88\u7406\u60f3\u3002\u4e00\u65b9\u9762\u662f\u5b9a\u4f4d\u95ee\u9898\u6bd4\u8f83\u56f0\u96be\uff0c\u53e6\u4e00\u65b9\u9762\u662f\u5b83\u5bf9\u81ea\u52a8\u5254\u9664\u8282\u70b9\u7684\u652f\u6301\u4e0d\u662f\u5f88\u53cb\u597d\u3002<\/p>\n \u4f18\u70b9\uff1a<\/p>\n \u7f3a\u70b9\uff1a<\/p>\n <\/p>\n From:\u00a0https:\/\/github.com\/CodisLabs\/codis<\/a><\/p>\n Codis<\/a>\u00a0\u662f\u7531\u8c4c\u8c46\u835a\u5f00\u6e90\u7684\u4ea7\u54c1\uff0c\u6d89\u53ca\u7ec4\u4ef6\u4f17\u591a\uff0c\u5176\u4e2d ZooKeeper \u5b58\u653e\u8def\u7531\u8868\u548c\u4ee3\u7406\u8282\u70b9\u5143\u6570\u636e\u3001\u5206\u53d1 Codis-Config \u7684\u547d\u4ee4\uff1bCodis-Config \u662f\u96c6\u6210\u7ba1\u7406\u5de5\u5177\uff0c\u6709 Web \u754c\u9762\u4f9b\u4f7f\u7528\uff1bCodis-Proxy \u662f\u4e00\u4e2a\u517c\u5bb9 Redis \u534f\u8bae\u7684\u65e0\u72b6\u6001\u4ee3\u7406\uff1bCodis-Redis \u57fa\u4e8e Redis 2.8 \u7248\u672c\u4e8c\u6b21\u5f00\u53d1\uff0c\u52a0\u5165 slot \u652f\u6301\uff0c\u65b9\u4fbf\u8fc1\u79fb\u6570\u636e\u3002<\/p>\n \u4f18\u70b9\uff1a<\/p>\n \u7f3a\u70b9\uff1a<\/p>\n \u6240\u8c13\u7684\u6700\u4f73\u5b9e\u8df5\uff0c\u90fd\u662f\u6700\u9002\u5408\u5177\u4f53\u573a\u666f\u7684\u5b9e\u8df5\u3002<\/strong><\/p>\n \u4e3b\u63a8\u4ee5\u4e0b\u65b9\u6848\uff1a<\/p>\n \u4ee5\u4e0b\u662f\u5b9e\u6218\u8fc7\u7a0b\u4e2d\u603b\u7ed3\u51fa\u7684\u6700\u4f73\u5b9e\u8df5\uff1a<\/p>\n \u6b64\u6b21\u6d3b\u52a8\u5206\u4eab\u4e86 Redis \u9ad8\u53ef\u7528\u7684\u5fc5\u8981\u6027\u3001Sentinel \u539f\u7406\u3001Redis \u9ad8\u53ef\u7528\u5e38\u7528\u67b6\u6784\u548c\u5b9e\u6218\u8fc7\u7a0b\u4e2d\u603b\u7ed3\u51fa\u7684\u6700\u4f73\u5b9e\u8df5\uff0c\u5e0c\u671b\u5bf9\u8bfb\u8005\u6709\u6240\u5e2e\u52a9\uff0c\u5982\u679c\u6709\u9700\u8981\u540e\u7eed\u4ea4\u6d41\u7684\uff0c\u53ef\u4ee5\u6dfb\u52a0\u6211\u7684\u5fae\u4fe1\uff08Wentasy<\/strong>\uff09\uff0c\u6216\u8005\u53d1\u90ae\u4ef6\u5230\uff1adbarobinwen@gmail.com<\/strong><\/p>\n \u9644 PPT \u4e0b\u8f7d\uff1ahttps:\/\/github.com\/dbarobin\/slides<\/a><\/p>\n \u89c6\u9891\u56de\u653e\uff1aRedis \u9ad8\u53ef\u7528\u67b6\u6784\u6700\u4f73\u5b9e\u8df5<\/a><\/p>\n \u611f\u8c22\u542c\u4e91\u548c\u8fd0\u7ef4\u5e2e\u7684\u7cbe\u5fc3\u7ec4\u7ec7\uff0c\u611f\u8c22\u5927\u5bb6\u5192\u7740\u5927\u96e8\u524d\u6765\u53c2\u52a0\u6b64\u6b21\u6d3b\u52a8\u3002\u6b64\u6b21\u5206\u4eab\u7531 IT \u5927\u5496\u8bf4\u5168\u7a0b\u5f55\u50cf\uff0c\u611f\u8c22 IT \u5927\u5496\u8bf4\u7684\u6280\u672f\u652f\u6301\u3002<\/p>\n [1] jyzhou (2016-06-12). Redis \u590d\u5236\u3001Sentinel \u7684\u642d\u5efa\u548c\u539f\u7406\u8bf4\u660e. Retrieved from\u00a0http:\/\/www.cnblogs.com\/zhoujinyi\/p\/5570024.html<\/a>.<\/p>\n \u539f\u6587\u6765\u81ea\uff1ahttp:\/\/www.codeceo.com\/article\/redis-architecture.html<\/a><\/p>\n\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n