{"id":201460,"date":"2025-05-10T10:32:08","date_gmt":"2025-05-10T02:32:08","guid":{"rendered":"https:\/\/server.hk\/cnblog\/201460\/"},"modified":"2025-05-10T10:32:08","modified_gmt":"2025-05-10T02:32:08","slug":"%e5%88%86%e4%ba%abredis%e9%ab%98%e5%8f%af%e7%94%a8%e6%9e%b6%e6%9e%84%e8%ae%be%e8%ae%a1%e5%ae%9e%e8%b7%b5","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/201460\/","title":{"rendered":"\u5206\u4eabRedis\u9ad8\u53ef\u7528\u67b6\u6784\u8bbe\u8ba1\u5b9e\u8df5"},"content":{"rendered":"<p><b><\/b> <\/p>\n<h1>\u5206\u4eabRedis\u9ad8\u53ef\u7528\u67b6\u6784\u8bbe\u8ba1\u5b9e\u8df5<\/h1>\n<p><span style=\"cursor: pointer\"><i><\/i>\u6536\u85cf<\/span> <\/p>\n<p>\u5c0f\u4f19\u4f34\u4eec\u6709\u6ca1\u6709\u89c9\u5f97\u5b66\u4e60<span style=\"color: #FF6600;font-family:\">\u6570\u636e\u5e93<\/span>\u5f88\u6709\u610f\u601d\uff1f\u6709\u610f\u601d\u5c31\u5bf9\u4e86\uff01\u4eca\u5929\u5c31\u7ed9\u5927\u5bb6\u5e26\u6765<span style=\"color: #FF6600;font-family:\">\u300a\u5206\u4eabRedis\u9ad8\u53ef\u7528\u67b6\u6784\u8bbe\u8ba1\u5b9e\u8df5\u300b<\/span>\uff0c\u4ee5\u4e0b\u5185\u5bb9\u5c06\u4f1a\u6d89\u53ca\u5230<span style=\"color: #FF6600;font-family:\">Redis\u3001\u4ee3\u7801\u3001\u67b6\u6784<\/span>\uff0c\u82e5\u662f\u5728\u5b66\u4e60\u4e2d\u5bf9\u5176\u4e2d\u90e8\u5206\u77e5\u8bc6\u70b9\u6709\u7591\u95ee\uff0c\u6216\u8bb8\u770b\u4e86\u672c\u6587\u5c31\u80fd\u5e2e\u5230\u4f60\uff01<\/p>\n<p><strong>&nbsp;\u4e00\u3001\u9ad8\u53ef\u7528\u67b6\u6784\u8bbe\u8ba1\u539f\u7406<\/strong><\/p>\n<p><strong>1\u3001\u6982\u8ff0<\/strong><\/p>\n<p>Qunar Redis \u96c6\u7fa4\u662f\u4e00\u4e2a\u5206\u5e03\u5f0f\u7684\u9ad8\u53ef\u7528\u67b6\u6784\uff0c\u6574\u4e2a\u67b6\u6784\u4e3b\u8981\u7531\u4ee5\u4e0b\u51e0\u4e2a\u91cd\u8981\u90e8\u5206\u7ec4\u6210\uff1a<\/p>\n<ul>\n<li>\n<p>&nbsp;Redis Server \u8282\u70b9\uff1a\u6bcf\u4e2a\u8282\u70b9\u6709\u4e00\u4e3b\u4e00\u4ece\u4e24\u4e2a\u5b9e\u4f8b\uff0c\u591a\u4e2a\u8282\u70b9\u7ec4\u6210\u4e00\u4efd\u5b8c\u6574\u7684\u96c6\u7fa4\u6570\u636e\uff0c\u5176\u4e2d\u6bcf\u4e2a\u8282\u70b9\u53ea\u6709\u4e3b\u5e93\u5bf9\u5916\u63d0\u4f9b\u670d\u52a1\uff0c\u4ece\u5e93\u4ec5\u4ec5\u7528\u4e8e\u8282\u70b9\u9ad8\u53ef\u7528\u3001\u6570\u636e\u6301\u4e45\u5316\u53ca\u5b9a\u65f6\u5907\u4efd\u3002<\/p>\n<\/li>\n<li>\n<p>&nbsp;Zookeeper \u96c6\u7fa4\uff1a\u7531\u4e94\u4e2a zk \u8282\u70b9\u7ec4\u6210\uff0cRedis \u96c6\u7fa4\u914d\u7f6e\u53d8\u66f4\u540e\uff0c\u901a\u77e5\u5ba2\u6237\u7aef\u8fdb\u884c\u91cd\u8fde\u3002<\/p>\n<\/li>\n<li>\n<p>&nbsp;Redis Sentinel \u96c6\u7fa4\uff1a\u7531\u4e94\u4e2a Sentinel \u8282\u70b9\u7ec4\u6210\uff0c\u7528\u4e8e Reids Server \u8282\u70b9\u7684\u9ad8\u53ef\u7528\uff0c\u4e3b\u4ece\u5207\u6362\u3001\u6545\u969c\u8f6c\u79fb\u3001\u914d\u7f6e\u66f4\u65b0\u7b49\u3002<\/p>\n<\/li>\n<li>\n<p>&nbsp;\u914d\u7f6e\u4e2d\u5fc3\u96c6\u7fa4\uff1a\u7531\u4e94\u4e2a MySQL \u8282\u70b9\u7ec4\u6210\u7684 PXC \u96c6\u7fa4\uff0c\u7528\u4e8e\u5b58\u50a8 Redis \u96c6\u7fa4\u7684\u5206\u7247\u4fe1\u606f\uff0c\u5373\u6bcf\u4e2a\u8282\u70b9\u7684 Master \u5b9e\u4f8b\u4fe1\u606f\u53ca\u5206\u914d key \u7684\u4e00\u81f4\u6027 hash \u503c\u8303\u56f4\u3002<\/p>\n<\/li>\n<li>\n<p>&nbsp;\u5e94\u7528\u7a0b\u5e8f\u5ba2\u6237\u7aef\uff1a\u76d1\u542c zk \u53d8\u5316\uff0c\u5728\u914d\u7f6e\u4e2d\u5fc3\u83b7\u53d6 Redis \u5b9e\u4f8b\u4fe1\u606f\u8fdb\u884c\u8fde\u63a5\u3002<\/p>\n<\/li>\n<\/ul>\n<p><strong>2\u3001\u67b6\u6784\u539f\u7406\u56fe<\/strong><\/p>\n<\/p>\n<p><strong>3\u3001\u5ba2\u6237\u7aef\u5b9e\u73b0<\/strong><\/p>\n<p>1\uff09\u5f53\u5ba2\u6237\u7aef\u6839\u636e Redis \u96c6\u7fa4\u7684 namespace \u5efa\u7acb\u8fde\u63a5\u65f6\uff0c\u4f1a\u5148\u4ece zk \u4e2d\u67e5\u627e\/config_addr \u8282\u70b9\uff0c \u8be5\u8282\u70b9\u4e0b\u5b58\u653e\u7684\u662f\u914d\u7f6e\u4e2d\u5fc3\u96c6\u7fa4\u7684\u5b9e\u4f8b\u4fe1\u606f\uff0c\u4ece\u4e2d\u968f\u673a\u9009\u62e9\u4e00\u4e2a\u6570\u636e\u5e93\u5b9e\u4f8b\u8fdb\u884c\u8fde\u63a5\u3002<\/p>\n<p>2\uff09\u5728\u914d\u7f6e\u4e2d\u5fc3\u7684\u7279\u5b9a\u5e93\u8868\u4e2d\uff0c\u6839\u636e Redis \u7684 namespace \u67e5\u8be2\u96c6\u7fa4\u7684\u8282\u70b9\u7684\u8fde\u63a5\u914d\u7f6e\uff0c\u7136\u540e\u5efa\u7acb Redis \u8fde\u63a5\u3002<\/p>\n<p>3\uff09\u5ba2\u6237\u7aef\u5efa\u7acb Redis \u8fde\u63a5\u540e\uff0c\u4f1a\u542f\u52a8\u4e86\u4e24\u4e2a\u7ebf\u7a0b\uff1a<\/p>\n<ul>\n<li>\n<p>&nbsp;\u4e00\u4e2a\u7528\u4e8e\u76d1\u542c zk \u7684\u5730\u5740\u7684\u53d8\u5316\u3002\u6bcf\u4e2a Redis \u96c6\u7fa4\u5728 zk \u4e2d\u90fd\u4f1a\u6709\u4e00\u4e2a\/redis\/namespace \u7684\u8282\u70b9 \uff0c\u5982\u679c\u96c6\u7fa4\u914d\u7f6e\u53d1\u751f\u53d8\u5316\uff0c\u54e8\u5175\u4f1a\u901a\u77e5 zk \u66f4\u65b0\u6b64\u8282\u70b9\u7684\u503c\uff0c\u5ba2\u6237\u7aef\u611f\u77e5\u5230 zk \u914d\u7f6e\u53d8\u5316\uff0c \u5c06\u4f1a\u53bb\u914d\u7f6e\u4e2d\u5fc3\u83b7\u53d6\u65b0\u7684\u8fde\u63a5\u914d\u7f6e\uff0c\u91cd\u65b0\u5efa\u7acb\u8fde\u63a5\u3002<\/p>\n<\/li>\n<li>\n<p>&nbsp;\u4e00\u4e2a\u7528\u4e8e\u8f6e\u8be2\u914d\u7f6e\u4e2d\u5fc3\u7684\u8fde\u63a5\u914d\u7f6e\u3002\u4e3a\u4e86\u9632\u6b62 zk \u901a\u77e5\u5931\u8d25\uff0c\u5ba2\u6237\u7aef\u4f1a\u901a\u8fc7\u8fd9\u4e2a\u7ebf\u7a0b\uff0c\u6bcf\u9694 10s \u53bb\u8f6e\u8be2\u914d\u7f6e\u4e2d\u5fc3\u7684\u914d\u7f6e\u4fe1\u606f\uff0c\u5982\u679c\u53d1\u73b0\u914d\u7f6e\u4e2d\u5fc3\u7684\u914d\u7f6e\u548c\u672c\u5730\u7f13\u5b58\u7684\u4e0d\u4e00\u6837\uff0c\u5c31\u4f1a\u4f7f\u7528\u914d\u7f6e\u4e2d\u5fc3\u7684\u914d\u7f6e\u5efa\u7acb\u65b0\u7684\u8fde\u63a5\u3002<\/p>\n<\/li>\n<\/ul>\n<p>\u5ba2\u6237\u7aef\u4e0e\u5176\u4ed6\u7ec4\u4ef6\u7684\u5173\u7cfb\u793a\u610f\u56fe\u5982\u4e0b\uff1a<\/p>\n<\/p>\n<p><strong>4\u3001\u6570\u636e\u5206\u7247\u65b9\u6cd5<\/strong><\/p>\n<p>\u5f00\u53d1\u4eba\u5458\u63d0\u4ea4 Redis \u96c6\u7fa4\u7533\u8bf7\u5de5\u5355\u4fe1\u606f\u540e\uff0cDBA \u4f1a\u4f9d\u636e\u5de5\u5355\u4e2d\u7684\u5185\u5b58\u5927\u5c0f\u3001QPS \u5927\u5c0f\u7b49\u51e0\u9879\u4e3b\u8981\u7684\u6570\u636e\uff0c\u89c4\u5212\u96c6\u7fa4\u5206\u7247\u8282\u70b9\u6570\u91cf\u4e3a N\uff0c\u6240\u6709\u8282\u70b9\u5e73\u5747\u5206\u914d 0~4294967295 \u8303\u56f4\u5185\u7684\u503c\uff0c\u5373\u5171\u6709 2 \u7684 32 \u6b21\u65b9\u4e2a key \u7684\u503c\uff0c\u67d0\u4e00\u4e2a key \u4f7f\u7528 murmurhash2 \u7b97\u6cd5\u8ba1\u7b97\u54c8\u5e0c\u503c\u540e\uff0c\u53ea\u4f1a\u843d\u5728\u96c6\u7fa4\u7684\u4e00\u4e2a\u8282\u70b9\u4e0a\u3002<\/p>\n<p>\u5206\u7247\u8282\u70b9\u793a\u610f\u56fe\u5982\u4e0b\uff1a<\/p>\n<\/p>\n<p>\u5206\u7247\u8282\u70b9\u4fe1\u606f\u5728\u914d\u7f6e\u4e2d\u5fc3\u7684\u5b58\u50a8\u4fe1\u606f\u5982\u4e0b\uff1a<\/p>\n<\/p>\n<p><strong>5\u3001\u67b6\u6784\u7279\u70b9<\/strong><\/p>\n<p>Quanr Redis \u9ad8\u53ef\u7528\u67b6\u6784\u5177\u6709\u4ee5\u4e0b\u7279\u70b9\uff1a<\/p>\n<ul>\n<li>\n<p>&nbsp;\u5b9e\u73b0\u81ea\u5df1\u7684 Redis \u5ba2\u6237\u7aef\uff0c\u5ba2\u6237\u7aef\u4e0d\u518d\u8bbf\u95ee Sentinel\uff0c Sentinel \u53ea\u8d1f\u8d23\u9ad8\u53ef\u7528\u3002<\/p>\n<\/li>\n<li>\n<p>&nbsp;\u901a\u8fc7 ZK \u96c6\u7fa4\u548c\u914d\u7f6e\u4e2d\u5fc3\u6765\u5b9e\u73b0\u914d\u7f6e\u7684\u96c6\u4e2d\u7ba1\u7406\u3002<\/p>\n<\/li>\n<li>\n<p>&nbsp;\u5c06\u7aef\u53e3\u89c6\u4f5c\u4e00\u79cd\u8d44\u6e90\uff0c\u5373\u96c6\u7fa4\u7684\u4e00\u4e2a\u8282\u70b9\u7684\u4e3b\u4ece\u5b9e\u4f8b\u4f7f\u7528\u4e00\u4e2a\u7aef\u53e3\uff0c\u4e0b\u7ebf\u7684\u96c6\u7fa4\u7aef\u53e3\u53ef\u590d\u7528\u3002<\/p>\n<\/li>\n<li>\n<p>&nbsp;\u5f31\u5316\u4e86\u54e8\u5175\u673a\u5668\u7684\u5730\u4f4d\uff0c \u964d\u4f4e\u4e86\u54e8\u5175\u548c\u96c6\u7fa4\u4e4b\u95f4\u76f4\u63a5\u7684\u8026\u5408\u5ea6\u3002<\/p>\n<\/li>\n<li>\n<p>&nbsp;\u51cf\u5c11\u4e86\u54e8\u5175\u673a\u5668\u7684\u4f7f\u7528\u91cf\uff0c \u76ee\u524d\u53ea\u4f7f\u7528\u4e86 5 \u53f0\u54e8\u5175\u673a\u5668\u7ec4\u6210\u96c6\u7fa4\u3002<\/p>\n<\/li>\n<li>\n<p>&nbsp;\u5ba2\u6237\u7aef\u4f7f\u7528 namespace \u8bbf\u95ee\u96c6\u7fa4\uff0c \u5c06\u7aef\u53e3\u548c namespace \u5bf9\u5e94\uff0cnamespace \u548c\u4e1a\u52a1\u90e8\u95e8\u5bf9\u5e94\uff0c\u65b9\u4fbf DBA \u7ba1\u7406\u548c\u8fd0\u7ef4\uff0c\u5bf9\u5e94\u7528\u900f\u660e\u3002<\/p>\n<\/li>\n<\/ul>\n<p><strong>6\u3001\u67b6\u6784\u5c40\u9650\u6027<\/strong><\/p>\n<p>Quanr Redis \u9ad8\u53ef\u7528\u67b6\u6784\u5177\u6709\u4ee5\u4e0b\u5c40\u9650\u6027\uff1a<\/p>\n<ul>\n<li>\n<p>&nbsp;\u652f\u6301\u7684\u5ba2\u6237\u7aef\u6bd4\u8f83\u5c11\u3002\u76ee\u524d\u5ba2\u6237\u7aef\u4ec5\u652f\u6301 Java \u548c Python\u3002<\/p>\n<\/li>\n<li>\n<p>&nbsp;\u4e0d\u652f\u6301\u5feb\u901f\u6c34\u5e73\u6269\u5bb9\u3002\u5f53\u96c6\u7fa4\u5185\u5b58\u4e0d\u8db3\u65f6\u53ef\u4ee5\u5feb\u901f\u6269\u5927\u5404\u4e2a\u8282\u70b9\u5b9e\u4f8b\u7684\u5185\u5b58\u5927\u5c0f\uff0c\u4ee5\u6b64\u6765\u589e\u52a0\u6574\u4e2a\u96c6\u7fa4\u5927\u5c0f\uff0c\u4f46\u5355\u4e2a\u5b9e\u4f8b\u7684\u5185\u5b58\u5927\u5c0f\u4e5f\u6709\u4e00\u5b9a\u7684\u9650\u5ea6\uff0c\u4e0d\u80fd\u65e0\u9650\u6269\u5c55\u3002\u5f53\u9700\u8981\u589e\u52a0\u96c6\u7fa4\u8282\u70b9\u4e2a\u6570\u65f6\uff0c\u7531\u4e8e\u5404\u4e2a\u8282\u70b9\u7684\u4e00\u81f4\u6027\u54c8\u5e0c\u8303\u56f4\u53d1\u751f\u4e86\u53d8\u5316\uff0c\u6240\u6709\u7684 key \u9700\u8981\u91cd\u65b0\u5206\u914d\uff0c\u5bf9\u4e8e\u6bd4\u8f83\u5927\u7684\u96c6\u7fa4\uff0c\u8fc7\u7a0b\u6bd4\u8f83\u7e41\u7410\u548c\u8017\u65f6\u3002<\/p>\n<\/li>\n<li>\n<p>&nbsp;\u6574\u4e2a\u67b6\u6784\u4f9d\u8d56\u7684\u7ec4\u4ef6\u6bd4\u8f83\u591a\u3002\u867d\u7136\u67b6\u6784\u4e2d\u7684 zookeeper\u3001\u914d\u7f6e\u4e2d\u5fc3\u3001Sentinel \u7b49\u90fd\u662f\u591a\u8282\u70b9\u7684\u9ad8\u53ef\u7528\u96c6\u7fa4\uff0c\u4f46\u4f9d\u8d56\u7684\u7ec4\u4ef6\u8d8a\u591a\uff0c\u53d1\u751f\u6545\u969c\u7684\u53ef\u80fd\u6027\u4e5f\u8d8a\u5927\uff0c\u8fd0\u7ef4\u96be\u5ea6\u548c\u5de5\u4f5c\u91cf\u4e5f\u4f1a\u968f\u7740\u589e\u52a0\uff0c\u65e0\u7591\u5bf9\u8fd0\u7ef4\u4eba\u5458\u6709\u66f4\u9ad8\u7684\u8981\u6c42\u3002<\/p>\n<\/li>\n<li>\n<p>&nbsp;\u90e8\u5206 Redis \u539f\u751f\u529f\u80fd\u65e0\u6cd5\u4f7f\u7528\u3002\u7531\u4e8e\u5ba2\u6237\u7aef\u7684\u9650\u5236\uff0c\u90e8\u5206 Redis \u539f\u751f\u529f\u80fd\u65e0\u6cd5\u4f7f\u7528\uff0c\u5982\u4e0d\u652f\u6301\u4e8b\u52a1\u3001Lua \u811a\u672c\u7b49\u3002<\/p>\n<\/li>\n<\/ul>\n<p><strong>\u4e8c\u3001\u5b89\u5168\u673a\u5236<\/strong><\/p>\n<p>Redis \u88ab\u8bbe\u8ba1\u6210\u4ec5\u4f9b\u53ef\u4fe1\u73af\u5883\u4e0b\u7684\u53ef\u4fe1\u7528\u6237\u624d\u53ef\u4ee5\u8bbf\u95ee\uff0c\u5e76\u6ca1\u6709\u6700\u5927\u5316\u7684\u53bb\u4f18\u5316\u5b89\u5168\u65b9\u9762\uff0c\u800c\u662f\u5c3d\u91cf\u53ef\u80fd\u7684\u53bb\u4f18\u5316\u9ad8\u6027\u80fd\u548c\u6613\u7528\u6027\uff0c\u56e0\u6b64 Redis \u6ca1\u6709\u7c7b\u4f3c\u5173\u7cfb\u578b\u6570\u636e\u5e93\u90a3\u6837\u4e25\u683c\u7684\u6743\u9650\u63a7\u5236\uff0c\u56e0\u6b64\u5c06 Redis \u5b9e\u4f8b\u76f4\u63a5\u66b4\u9732\u5728\u7f51\u7edc\u4e0a\u6216\u8005\u8ba9\u4e0d\u53ef\u4fe1\u7684\u7528\u6237\u76f4\u63a5\u8bbf\u95ee Redis \u7684 TCP \u7aef\u53e3\uff0c\u662f\u975e\u5e38\u5371\u9669\u7684\u884c\u4e3a\u3002<\/p>\n<p>\u4e3a\u4e86\u63d0\u9ad8 Redis \u4f7f\u7528\u7684\u5b89\u5168\u6027\uff0c\u53bb\u54ea\u513f\u7f51\u4f7f\u7528\u7684 Redis Server \u662f\u5728\u5b98\u65b9 Redis 4.0.14 \u7248\u672c\u4e0a\u8fdb\u884c\u4e86\u90e8\u5206\u7684\u6e90\u4ee3\u7801\u6539\u9020\uff0c\u589e\u52a0\u4e86\u4e00\u4e2a\u767d\u540d\u5355\u53c2\u6570 trustedip\uff0c\u5c4f\u853d\u4e86\u90e8\u5206\u9ad8\u5371\u6307\u4ee4\uff0c\u9664\u4e86 trustedip \u4e2d\u914d\u7f6e\u7684 IP \u4e4b\u5916\uff0c\u4efb\u4f55\u5176\u4ed6\u5ba2\u6237\u7aef\u8fde\u63a5\u90fd\u65e0\u6cd5\u6267\u884c\u8fd9\u4e9b\u9ad8\u5371\u6307\u4ee4\uff0c\u540c\u65f6\u4e3a\u4e86\u63d0\u9ad8 Redis \u7684\u6027\u80fd\uff0c\u5bf9\u4e3b\u4ece\u5b9e\u4f8b\u8fdb\u884c\u4e86\u5dee\u5f02\u6027\u914d\u7f6e\u3002<\/p>\n<p><strong>1\u3001clientcipher\u548cIP\u767d\u540d\u5355<\/strong><\/p>\n<p>Qunar Redis \u5ba2\u6237\u7aef\u5e76\u6ca1\u6709\u76f4\u63a5\u901a\u8fc7 TCP \u65b9\u5f0f\u53bb\u8fde\u63a5 Redis \u5b9e\u4f8b\uff0c\u800c\u662f\u9996\u5148\u8981\u901a\u8fc7\u96c6\u7fa4 namespace \u548c\u8be5\u96c6\u7fa4\u552f\u4e00\u7684 clientcipher \u7684\u9a8c\u8bc1\uff0c\u7136\u540e\u4ece\u914d\u7f6e\u4e2d\u5fc3\u83b7\u53d6\u771f\u6b63\u7684\u8fde\u63a5\u4fe1\u606f\u540e\uff0c\u624d\u53ef\u4ee5\u8fde\u63a5 Redis \u5b9e\u4f8b\u3002\u540c\u65f6\u767d\u540d\u5355\u673a\u5236\u5bf9\u5ba2\u6237\u7aef\u8bf7\u6c42\u4e2d\u7684\u9ad8\u5371\u6307\u4ee4\u8fdb\u884c\u8fc7\u6ee4\uff0c\u907f\u514d\u5bf9\u7ebf\u4e0a Redis \u6267\u884c\u4e0d\u5408\u7406\u7684\u64cd\u4f5c\uff0c\u8fdb\u4e00\u6b65\u52a0\u5f3a\u4e86\u5176\u5b89\u5168\u6027\u3002<\/p>\n<ul>\n<li>\n<p>&nbsp;\u5ba2\u6237\u7aef\u4f7f\u7528 namespace \u548c clientcipher \u65b9\u5f0f\u8bbf\u95ee\u96c6\u7fa4\u3002<\/p>\n<\/li>\n<li>\n<p>&nbsp;\u4e0d\u540c namespace \u5bf9\u5e94\u7684 clientcipher \u4e0d\u540c\uff0c\u5728\u521b\u5efa\u96c6\u7fa4\u65f6\u901a\u8fc7\u968f\u673a\u751f\u6210\u7684\u5bc6\u7801\u518d\u6b21\u52a0\u5bc6\u751f\u6210 clientcipher\u3002<\/p>\n<\/li>\n<li>\n<p>&nbsp;\u5373\u4f7f\u77e5\u9053\u5bc6\u7801\uff0c\u4e5f\u65e0\u6cd5\u4f7f\u7528\u5c4f\u853d\u7684\u5371\u9669\u547d\u4ee4\uff0c\u9664\u975e IP \u5730\u5740\u5728\u767d\u540d\u5355\u4e2d\u3002<\/p>\n<\/li>\n<li>\n<p>&nbsp;\u672c\u5730\u767b\u9646\u548c IP \u767d\u540d\u5355\u767b\u9646\uff0c\u547d\u4ee4\u4e0d\u53d7\u9650\u5236\uff0c\u65b9\u4fbf DBA \u7ba1\u7406\u548c\u517c\u5bb9\u5404\u79cd\u76d1\u63a7\u7edf\u8ba1\u811a\u672c\u3002<\/p>\n<\/li>\n<li>\n<p>&nbsp;IP \u767d\u540d\u5355\u53ef\u4ee5\u52a8\u6001\u914d\u7f6e\uff0c\u6700\u5927\u652f\u6301 32 \u4e2a IP \u767d\u540d\u5355\u3002<\/p>\n<\/li>\n<\/ul>\n<p>IP \u767d\u540d\u5355\u529f\u80fd\u6d89\u53ca\u4fee\u6539\u4ee3\u7801\u7684\u5730\u65b9\uff1a<\/p>\n<p><strong>1\uff09\u5728 config.c \u6587\u4ef6\u7684 configGetCommand \u65b9\u6cd5\u4e2d\u589e\u52a0\u53c2\u6570 trustedip<\/strong>&nbsp;<\/p>\n<\/p>\n<ol>\n<li>\n<p>void&nbsp;configGetCommand(client&nbsp;*c)&nbsp;{&nbsp;&nbsp;<\/p>\n<\/li>\n<li>\n<p>robj&nbsp;*<span>o<\/span>&nbsp;=&nbsp;<span>c<\/span>&#8211;<span>&gt;<\/span>argv[2];&nbsp;&nbsp;<\/p>\n<\/li>\n<li>\n<p>void&nbsp;*<span>replylen<\/span>&nbsp;=&nbsp;<span>addDeferredMultiBulkLength<\/span>(c);&nbsp;&nbsp;<\/p>\n<\/li>\n<li>\n<p>char&nbsp;*<span>pattern<\/span>&nbsp;=&nbsp;<span>o<\/span>&#8211;<span>&gt;<\/span>ptr;&nbsp;&nbsp;<\/p>\n<\/li>\n<li>\n<p>char&nbsp;buf[128];&nbsp;&nbsp;<\/p>\n<\/li>\n<li>\n<p>int&nbsp;<span>matches<\/span>&nbsp;=&nbsp;<span>0<\/span>;&nbsp;&nbsp;<\/p>\n<\/li>\n<li>\n<p>serverAssertWithInfo(c,o,sdsEncodedObject(o));&nbsp;&nbsp;<\/p>\n<\/li>\n<li>\n<p>&#8230;&nbsp;&nbsp;<\/p>\n<\/li>\n<li>\n<p>\/*&nbsp;\u589e\u52a0trustedip\u53c2\u6570&nbsp;*\/&nbsp;&nbsp;<\/p>\n<\/li>\n<li>\n<p>if&nbsp;(stringmatch(pattern,&#8221;trustedip&#8221;,0))&nbsp;{&nbsp;&nbsp;<\/p>\n<\/li>\n<li>\n<p>sds&nbsp;<span>buf<\/span>&nbsp;=&nbsp;<span>sdsempty<\/span>();&nbsp;&nbsp;<\/p>\n<\/li>\n<li>\n<p>int&nbsp;j;&nbsp;&nbsp;<\/p>\n<\/li>\n<li>\n<p>int&nbsp;numips;&nbsp;&nbsp;<\/p>\n<\/li>\n<li>\n<p><span>numips<\/span>&nbsp;=&nbsp;<span>server<\/span>.trusted_ips.numips;&nbsp;&nbsp;<\/p>\n<\/li>\n<li>\n<p>for&nbsp;(<span>j<\/span>&nbsp;=&nbsp;<span>0<\/span>;&nbsp;j&nbsp;<span>&nbsp;<span>numips<\/span>;&nbsp;j++)&nbsp;{&nbsp;<\/span><\/p>\n<\/li>\n<li>\n<p><span>buf<\/span>&nbsp;=&nbsp;<span>sdscat<\/span>(buf,&nbsp;server.trusted_ips.ips[j]);&nbsp;&nbsp;<\/p>\n<\/li>\n<li>\n<p>if&nbsp;(j&nbsp;!=&nbsp;numips&nbsp;&#8211;&nbsp;1)&nbsp;&nbsp;<\/p>\n<\/li>\n<li>\n<p><span>buf<\/span>&nbsp;=&nbsp;<span>sdscatlen<\/span>(buf,&#8221;&nbsp;&#8220;,1);&nbsp;&nbsp;<\/p>\n<\/li>\n<li>\n<p>}&nbsp;&nbsp;<\/p>\n<\/li>\n<li>\n<p>addReplyBulkCString(c,&#8221;trustedip&#8221;);&nbsp;&nbsp;<\/p>\n<\/li>\n<li>\n<p>addReplyBulkCString(c,buf);&nbsp;&nbsp;<\/p>\n<\/li>\n<li>\n<p>sdsfree(buf);&nbsp;&nbsp;<\/p>\n<\/li>\n<li>\n<p>matches++;&nbsp;&nbsp;<\/p>\n<\/li>\n<li>\n<p>}&nbsp;&nbsp;<\/p>\n<\/li>\n<li>\n<p>setDeferredMultiBulkLength(c,replylen,matches*2);&nbsp;&nbsp;<\/p>\n<\/li>\n<li>\n<p>}&nbsp;<\/p>\n<\/li>\n<\/ol>\n<p><strong>2\uff09\u5728 server.c \u6587\u4ef6\u7684 processCommand \u65b9\u6cd5\u4e2d\u589e\u52a0\u5bf9 issuperclient \u7684\u8ba4\u8bc1<\/strong>&nbsp;<\/p>\n<\/p>\n<ol>\n<li>\n<p>typedef&nbsp;struct&nbsp;trustedIPArray&nbsp;{&nbsp;&nbsp;<\/p>\n<\/li>\n<li>\n<p>int&nbsp;numips;&nbsp;&nbsp;<\/p>\n<\/li>\n<li>\n<p>sds*&nbsp;ips;&nbsp;&nbsp;<\/p>\n<\/li>\n<li>\n<p>}&nbsp;trustedIPArray;&nbsp;<\/p>\n<\/li>\n<\/ol>\n<p><strong>3\uff09\u5728 networking.c \u6587\u4ef6\u4e2d\u589e\u52a0 isTrustedIP \u65b9\u6cd5<\/strong>&nbsp;<\/p>\n<\/p>\n<ol>\n<li>\n<p>\/*&nbsp;\u5224\u65ad\u5ba2\u6237\u7aefIP\u662f\u5426\u5728IP\u767d\u540d\u5355\u4e2d&nbsp;*\/&nbsp;&nbsp;<\/p>\n<\/li>\n<li>\n<p>int&nbsp;isTrustedIP(int&nbsp;fd)&nbsp;{&nbsp;&nbsp;<\/p>\n<\/li>\n<li>\n<p>char&nbsp;ip[128];&nbsp;&nbsp;<\/p>\n<\/li>\n<li>\n<p>int&nbsp;i,&nbsp;port;&nbsp;&nbsp;<\/p>\n<\/li>\n<li>\n<p>anetPeerToString(fd,ip,128,&amp;port);&nbsp;<\/p>\n<\/li>\n<li>\n<p>if&nbsp;(strcmp(ip,&nbsp;&#8220;127.0.0.1&#8221;)&nbsp;==&nbsp;0)&nbsp;{&nbsp;&nbsp;<\/p>\n<\/li>\n<li>\n<p>return&nbsp;1;&nbsp;&nbsp;<\/p>\n<\/li>\n<li>\n<p>}&nbsp;&nbsp;<\/p>\n<\/li>\n<li>\n<p>for&nbsp;(<span>i<\/span>&nbsp;=&nbsp;<span>0<\/span>;&nbsp;i&nbsp;<span>&nbsp;<span>server.trusted_ips.numips<\/span>;&nbsp;i++)&nbsp;{&nbsp;&nbsp;<\/span><\/p>\n<\/li>\n<li>\n<p>if&nbsp;(strcmp(ip,&nbsp;server.trusted_ips.ips[i])&nbsp;==&nbsp;0)&nbsp;{&nbsp;&nbsp;<\/p>\n<\/li>\n<li>\n<p>return&nbsp;1;&nbsp;&nbsp;<\/p>\n<\/li>\n<li>\n<p>}&nbsp;&nbsp;<\/p>\n<\/li>\n<li>\n<p>}&nbsp;&nbsp;<\/p>\n<\/li>\n<li>\n<p>return&nbsp;0;&nbsp;&nbsp;<\/p>\n<\/li>\n<li>\n<p>}&nbsp;<\/p>\n<\/li>\n<\/ol>\n<p><strong>4\uff09\u5728 networking.c \u6587\u4ef6\u7684 createClient \u65b9\u6cd5\u4e2d\u589e\u52a0 issuperclient \u7684\u8bbe\u7f6e<\/strong>&nbsp;<\/p>\n<\/p>\n<ol>\n<li>\n<p>client&nbsp;*createClient(int&nbsp;fd)&nbsp;{&nbsp;&nbsp;<\/p>\n<\/li>\n<li>\n<p>client&nbsp;*<span>c<\/span>&nbsp;=&nbsp;<span>zmalloc<\/span>(sizeof(client));&nbsp;&nbsp;<\/p>\n<\/li>\n<li>\n<p>\/*&nbsp;passing&nbsp;-1&nbsp;as&nbsp;fd&nbsp;it&nbsp;is&nbsp;possible&nbsp;to&nbsp;create&nbsp;a&nbsp;non&nbsp;connected&nbsp;client.&nbsp;&nbsp;<\/p>\n<\/li>\n<li>\n<p>*&nbsp;This&nbsp;is&nbsp;useful&nbsp;since&nbsp;all&nbsp;the&nbsp;commands&nbsp;needs&nbsp;to&nbsp;be&nbsp;executed&nbsp;&nbsp;<\/p>\n<\/li>\n<li>\n<p>*&nbsp;in&nbsp;the&nbsp;context&nbsp;of&nbsp;a&nbsp;client.&nbsp;When&nbsp;commands&nbsp;are&nbsp;executed&nbsp;in&nbsp;other&nbsp;&nbsp;<\/p>\n<\/li>\n<li>\n<p>*&nbsp;contexts&nbsp;(for&nbsp;instance&nbsp;a&nbsp;Lua&nbsp;script)&nbsp;we&nbsp;need&nbsp;a&nbsp;non&nbsp;connected&nbsp;client.&nbsp;*\/&nbsp;&nbsp;<\/p>\n<\/li>\n<li>\n<p>if&nbsp;(fd&nbsp;!=&nbsp;-1)&nbsp;{&nbsp;&nbsp;<\/p>\n<\/li>\n<li>\n<p>anetNonBlock(NULL,fd);&nbsp;&nbsp;<\/p>\n<\/li>\n<li>\n<p>anetEnableTcpNoDelay(NULL,fd);&nbsp;&nbsp;<\/p>\n<\/li>\n<li>\n<p>if&nbsp;(server.tcpkeepalive)&nbsp;&nbsp;<\/p>\n<\/li>\n<li>\n<p>anetKeepAlive(NULL,fd,server.tcpkeepalive);&nbsp;&nbsp;<\/p>\n<\/li>\n<li>\n<p>if&nbsp;(aeCreateFileEvent(server.el,fd,AE_READABLE,&nbsp;&nbsp;<\/p>\n<\/li>\n<li>\n<p>readQueryFromClient,&nbsp;c)&nbsp;==&nbsp;AE_ERR)&nbsp;&nbsp;<\/p>\n<\/li>\n<li>\n<p>{&nbsp;&nbsp;<\/p>\n<\/li>\n<li>\n<p>close(fd);&nbsp;&nbsp;<\/p>\n<\/li>\n<li>\n<p>zfree(c);&nbsp;&nbsp;<\/p>\n<\/li>\n<li>\n<p>return&nbsp;NULL;&nbsp;&nbsp;<\/p>\n<\/li>\n<li>\n<p>}&nbsp;&nbsp;<\/p>\n<\/li>\n<li>\n<p>&#8230;&nbsp;&nbsp;<\/p>\n<\/li>\n<li>\n<p>\/*&nbsp;\u8bbe\u7f6eis_super_client&nbsp;*\/&nbsp;&nbsp;<\/p>\n<\/li>\n<li>\n<p>if&nbsp;(isTrustedIP(fd))&nbsp;{&nbsp;&nbsp;<\/p>\n<\/li>\n<li>\n<p>c-<span>&gt;<\/span><span>is_super_client<\/span>&nbsp;=&nbsp;<span>1<\/span>;&nbsp;&nbsp;<\/p>\n<\/li>\n<li>\n<p>}&nbsp;else&nbsp;{&nbsp;&nbsp;<\/p>\n<\/li>\n<li>\n<p>c-<span>&gt;<\/span><span>is_super_client<\/span>&nbsp;=&nbsp;<span>0<\/span>;&nbsp;&nbsp;<\/p>\n<\/li>\n<li>\n<p>}&nbsp;&nbsp;<\/p>\n<\/li>\n<li>\n<p>&#8230;&nbsp;&nbsp;<\/p>\n<\/li>\n<li>\n<p>return&nbsp;c;&nbsp;&nbsp;<\/p>\n<\/li>\n<li>\n<p>}&nbsp;<\/p>\n<\/li>\n<\/ol>\n<p><strong>5\uff09\u5728 server.c \u6587\u4ef6\u7684 processCommand \u65b9\u6cd5\u4e2d\u589e\u52a0\u5bf9 issuperclient \u7684\u8ba4\u8bc1<\/strong>&nbsp;<\/p>\n<\/p>\n<ol>\n<li>\n<p>int&nbsp;processCommand(client&nbsp;*c)&nbsp;{&nbsp;&nbsp;<\/p>\n<\/li>\n<li>\n<p>\/*&nbsp;The&nbsp;QUIT&nbsp;command&nbsp;is&nbsp;handled&nbsp;separately.&nbsp;Normal&nbsp;command&nbsp;procs&nbsp;will&nbsp;&nbsp;<\/p>\n<\/li>\n<li>\n<p>*&nbsp;go&nbsp;through&nbsp;checking&nbsp;for&nbsp;replication&nbsp;and&nbsp;QUIT&nbsp;will&nbsp;cause&nbsp;trouble&nbsp;&nbsp;<\/p>\n<\/li>\n<li>\n<p>*&nbsp;when&nbsp;FORCE_REPLICATION&nbsp;is&nbsp;enabled&nbsp;and&nbsp;would&nbsp;be&nbsp;implemented&nbsp;in&nbsp;&nbsp;<\/p>\n<\/li>\n<li>\n<p>*&nbsp;a&nbsp;regular&nbsp;command&nbsp;proc.&nbsp;*\/&nbsp;<\/p>\n<\/li>\n<li>\n<p>if&nbsp;(!strcasecmp(c-<span>&gt;<\/span>argv[0]-<span>&gt;<\/span>ptr,&#8221;quit&#8221;))&nbsp;{&nbsp;&nbsp;<\/p>\n<\/li>\n<li>\n<p>addReply(c,shared.ok);&nbsp;&nbsp;<\/p>\n<\/li>\n<li>\n<p>c-<span>&gt;<\/span>flags&nbsp;|=&nbsp;CLIENT_CLOSE_AFTER_REPLY;&nbsp;&nbsp;<\/p>\n<\/li>\n<li>\n<p>return&nbsp;C_ERR;&nbsp;&nbsp;<\/p>\n<\/li>\n<li>\n<p>}&nbsp;&nbsp;<\/p>\n<\/li>\n<li>\n<p>&#8230;&nbsp;&nbsp;<\/p>\n<\/li>\n<li>\n<p>\/*&nbsp;Check&nbsp;if&nbsp;the&nbsp;user&nbsp;is&nbsp;authenticated&nbsp;*\/&nbsp;&nbsp;<\/p>\n<\/li>\n<li>\n<p>\/*&nbsp;\u589e\u52a0is_super_client\u8ba4\u8bc1&nbsp;*\/&nbsp;&nbsp;<\/p>\n<\/li>\n<li>\n<p>if&nbsp;(!c-<span>&gt;<\/span>is_super_client&nbsp;&amp;&amp;&nbsp;server.requirepass&nbsp;&amp;&amp;&nbsp;!c-<span>&gt;<\/span>authenticated&nbsp;&amp;&amp;&nbsp;c-<span>&gt;<\/span>cmd-<span>&gt;<\/span>proc&nbsp;!=&nbsp;authCommand)&nbsp;&nbsp;<\/p>\n<\/li>\n<li>\n<p>&#8230;&nbsp;&nbsp;<\/p>\n<\/li>\n<li>\n<p>return&nbsp;C_OK;&nbsp;&nbsp;<\/p>\n<\/li>\n<li>\n<p>}&nbsp;<\/p>\n<\/li>\n<\/ol>\n<p><strong>6\uff09\u5728 db.c \u6587\u4ef6\u4e2d\u589e\u52a0 checkCommandBeforeExec \u65b9\u6cd5<\/strong>&nbsp;<\/p>\n<\/p>\n<ol>\n<li>\n<p>\/*&nbsp;\u5982\u679c\u662fsuper&nbsp;client\u6216\u8005\u662fmaster\uff0c\u8fd4\u56de1\uff0c\u5426\u5219\u8fd4\u56de0&nbsp;&nbsp;<\/p>\n<\/li>\n<li>\n<p>*&nbsp;\u56e0\u4e3a\u5728master-slave\u4e0b\uff0cmaster(client)\u9700\u8981\u5411slave\u6267\u884c\u5371\u9669\u547d\u4ee4*\/&nbsp;&nbsp;<\/p>\n<\/li>\n<li>\n<p>int&nbsp;checkCommandBeforeExec(client&nbsp;*c)&nbsp;{&nbsp;&nbsp;<\/p>\n<\/li>\n<li>\n<p>if&nbsp;(c-<span>&gt;<\/span>is_super_client&nbsp;||&nbsp;(server.masterhost&nbsp;&amp;&amp;&nbsp;(c-<span>&gt;<\/span>flags&nbsp;&amp;&nbsp;CLIENT_MASTER)))&nbsp;{&nbsp;&nbsp;<\/p>\n<\/li>\n<li>\n<p>return&nbsp;1;&nbsp;&nbsp;<\/p>\n<\/li>\n<li>\n<p>}&nbsp;&nbsp;<\/p>\n<\/li>\n<li>\n<p>addReplyError(c,&#8221;No&nbsp;permission&nbsp;to&nbsp;execute&nbsp;this&nbsp;command&#8221;);&nbsp;&nbsp;<\/p>\n<\/li>\n<li>\n<p>return&nbsp;0;&nbsp;&nbsp;<\/p>\n<\/li>\n<li>\n<p>}&nbsp;<\/p>\n<\/li>\n<\/ol>\n<p><strong>2\u3001\u5c4f\u853d\u9ad8\u5371\u6307\u4ee4<\/strong><\/p>\n<p>\u901a\u8fc7\u4fee\u6539 Redis \u6e90\u4ee3\u7801\uff0c\u5728 Server \u7aef\u5c4f\u853d\u90e8\u5206\u5371\u9669\u6307\u4ee4\uff0c\u89c4\u5b9a\u53ea\u6709\u901a\u8fc7\u767d\u540d\u5355\u68c0\u67e5\u7684\u5ba2\u6237\u7aef\u8fde\u63a5\u624d\u53ef\u4ee5\u6267\u884c\u8fd9\u4e9b\u6307\u4ee4\u3002\u5728\u6267\u884c\u9ad8\u5371\u6307\u4ee4\u524d\u8fdb\u884c\u68c0\u67e5\uff0c\u5982\u9700\u5bf9 save \u6307\u4ee4\u8fdb\u884c\u5c4f\u853d\uff0c\u53ef\u5bf9 rdb.c \u6587\u4ef6\u7684 saveCommand \u65b9\u6cd5\u7684\u7b2c\u4e00\u884c\u589e\u52a0 checkCommandBeforeExec \u68c0\u67e5\u3002&nbsp;<\/p>\n<\/p>\n<ol>\n<li>\n<p>void&nbsp;saveCommand(client&nbsp;*c)&nbsp;{&nbsp;&nbsp;<\/p>\n<\/li>\n<li>\n<p>if&nbsp;(!checkCommandBeforeExec(c))&nbsp;return;&nbsp;\/*&nbsp;\u6267\u884c\u6307\u4ee4\u4e4b\u524d\u8fdb\u884c\u68c0\u67e5\uff0c\u5982\u4e0d\u901a\u8fc7\u76f4\u63a5\u8fd4\u56de&nbsp;*\/&nbsp;&nbsp;&nbsp;<\/p>\n<\/li>\n<li>\n<p>if&nbsp;(server.rdb_child_pid&nbsp;!=&nbsp;-1)&nbsp;{&nbsp;&nbsp;<\/p>\n<\/li>\n<li>\n<p>addReplyError(c,&#8221;Background&nbsp;save&nbsp;already&nbsp;in&nbsp;progress&#8221;);&nbsp;&nbsp;<\/p>\n<\/li>\n<li>\n<p>return;&nbsp;&nbsp;<\/p>\n<\/li>\n<li>\n<p>}&nbsp;&nbsp;<\/p>\n<\/li>\n<li>\n<p>rdbSaveInfo&nbsp;rsi,&nbsp;*rsiptr;&nbsp;&nbsp;<\/p>\n<\/li>\n<li>\n<p><span>rsiptr<\/span>&nbsp;=&nbsp;<span>rdbPopulateSaveInfo<\/span>(&amp;rsi);&nbsp;&nbsp;<\/p>\n<\/li>\n<li>\n<p>if&nbsp;(rdbSave(server.rdb_filename,rsiptr)&nbsp;==&nbsp;C_OK)&nbsp;{&nbsp;<\/p>\n<\/li>\n<li>\n<p>addReply(c,shared.ok);&nbsp;&nbsp;<\/p>\n<\/li>\n<li>\n<p>}&nbsp;else&nbsp;{&nbsp;&nbsp;<\/p>\n<\/li>\n<li>\n<p>addReply(c,shared.err);&nbsp;&nbsp;<\/p>\n<\/li>\n<li>\n<p>}&nbsp;&nbsp;<\/p>\n<\/li>\n<li>\n<p>}&nbsp;<\/p>\n<\/li>\n<\/ol>\n<p>\u5c4f\u853d\u7684\u9ad8\u5371\u6307\u4ee4\u6709\uff1a<\/p>\n<ul>\n<li>\n<p>&nbsp;\u6bd4\u8f83\u8017\u65f6\u7c7b\u6307\u4ee4\uff1ainfo\u3001keys *\u3002<\/p>\n<\/li>\n<li>\n<p>&nbsp;\u6e05\u7a7a\u6570\u636e\u7c7b\u6307\u4ee4\uff1ashutdown\u3001flushdb\u3001 flushall\u3002<\/p>\n<\/li>\n<li>\n<p>&nbsp;\u6570\u636e\u6301\u4e45\u5316\u7c7b\u6307\u4ee4\uff1asave\u3001bgsave\u3001bgrewriteaof\u3002<\/p>\n<\/li>\n<li>\n<p>&nbsp;\u914d\u7f6e\u7c7b\u6307\u4ee4\uff1aconfig get\u3001config set\u3001config rewrite\u3002<\/p>\n<\/li>\n<li>\n<p>&nbsp;\u8fd0\u7ef4\u7ba1\u7406\u7c7b\u6307\u4ee4\uff1aslaveof\u3001monitor\u3001client list\u3001client kill\u3002<\/p>\n<\/li>\n<\/ul>\n<p>\u5728 Redis \u6e90\u4ee3\u7801\u6d89\u53ca\u8fd9\u4e9b\u6307\u4ee4\u7684\u5730\u65b9\uff0c\u90fd\u9700\u8981\u52a0\u4e0a checkCommandBeforeExec \u65b9\u6cd5\u8fdb\u884c\u68c0\u67e5\u3002<\/p>\n<p><strong>3\u3001\u914d\u7f6e\u4f18\u5316<\/strong><\/p>\n<p>\u9488\u5bf9\u96c6\u7fa4\u5404\u4e2a\u8282\u70b9\u7684\u4e3b\u4ece\u5b9e\u4f8b\u8fdb\u884c\u5dee\u5f02\u5316\u914d\u7f6e\uff0c\u7531\u4e8e\u6bcf\u4e2a\u8282\u70b9\u53ea\u6709\u4e3b\u5e93\u5bf9\u5916\u63d0\u4f9b\u670d\u52a1\uff0c\u4e3a\u4e86\u6700\u5927\u9650\u5ea6\u7684\u63d0\u9ad8\u4e3b\u5e93\u7684\u5e76\u53d1\u80fd\u529b\uff0c\u4e00\u4e9b\u6bd4\u8f83\u8017\u65f6\u7684\u64cd\u4f5c\u53ef\u4ee5\u653e\u5230\u4ece\u5e93\u53bb\u6267\u884c\u3002<\/p>\n<p>\u51e0\u9879\u4e3b\u8981\u7684\u914d\u7f6e\u5982\u4e0b\uff1a<\/p>\n<ul>\n<li>\n<p>&nbsp;\u4e3b\u5e93\u5173\u95ed bgsave\u3001bgrewriteaof \u529f\u80fd\u3002<\/p>\n<\/li>\n<li>\n<p>&nbsp;\u4ece\u5e93\u5f00\u542f aof \u529f\u80fd\uff0c\u5b9a\u65f6\u8c03\u5ea6\u91cd\u5199 aof \u6587\u4ef6\uff0c\u91ca\u653e\u670d\u52a1\u5668\u78c1\u76d8\u7a7a\u95f4\u3002<\/p>\n<\/li>\n<li>\n<p>&nbsp;\u4ece\u5e93\u5b9a\u65f6\u6267\u884c bgsave \u64cd\u4f5c\uff0c\u5907\u4efd rdb \u6587\u4ef6\u3002<\/p>\n<\/li>\n<li>\n<p>&nbsp;\u4ece\u5e93\u5f00\u542f slave-read-only \u53c2\u6570\uff0c\u53ea\u8bfb\u3002<\/p>\n<\/li>\n<\/ul>\n<p>\u5f53 Redis \u96c6\u7fa4\u90e8\u7f72\u5b8c\u4e4b\u540e\uff0c\u4f1a\u6709\u5b9a\u65f6\u4efb\u52a1\u53bb\u68c0\u67e5\u670d\u52a1\u5668\u4e0a\u5404\u4e2a Redis \u5b9e\u4f8b\u7684\u89d2\u8272\uff0c\u6839\u636e\u89d2\u8272\u7684\u4e0d\u540c\u4fee\u6539\u76f8\u5173\u7684\u914d\u7f6e\u53c2\u6570\uff0c\u540c\u65f6\u5c06\u4fee\u6539\u540e\u7684\u6301\u4e45\u5316\u5230\u914d\u7f6e\u6587\u4ef6\u3002<\/p>\n<p><strong>\u4e09\u3001\u81ea\u52a8\u5316\u8fd0\u7ef4<\/strong><\/p>\n<p>1\u3001\u521d\u59cb\u5316\u7cfb\u7edf\u73af\u5883<\/p>\n<p>\u5728 Redis \u670d\u52a1\u5668\u4e0a\u90e8\u7f72\u96c6\u7fa4\u4e4b\u524d\uff0c\u9996\u5148\u9700\u8981\u521d\u59cb\u5316\u7cfb\u7edf\u73af\u5883\uff0c\u5c06\u8fd9\u4e9b\u73af\u5883\u914d\u7f6e\u6dfb\u52a0\u5230 Redis \u7684 rpm \u6253\u5305\u7a0b\u5e8f\u7684 spec \u6587\u4ef6\u4e2d\uff0c\u5b89\u88c5 Redis \u8f6f\u4ef6\u5305\u65f6\u4f1a\u81ea\u52a8\u66f4\u6539\u76f8\u5173\u914d\u7f6e\uff0c\u4e3b\u8981\u7684\u7cfb\u7edf\u73af\u5883\u53c2\u6570\u6709\u4ee5\u4e0b\u51e0\u4e2a\uff1a&nbsp;<\/p>\n<\/p>\n<ol>\n<li>\n<p>sed&nbsp;-i&nbsp;-r&nbsp;&#8216;\/vm.overcommit_memory.*\/d&#8217;&nbsp;\/etc\/sysctl.conf&nbsp;&nbsp;<\/p>\n<\/li>\n<li>\n<p>sed&nbsp;-i&nbsp;-r&nbsp;&#8216;\/vm.swappiness.*\/d&#8217;&nbsp;\/etc\/sysctl.conf&nbsp;&nbsp;<\/p>\n<\/li>\n<li>\n<p>sed&nbsp;-i&nbsp;-r&nbsp;&#8216;\/vm.dirty_bytes.*\/d&#8217;&nbsp;\/etc\/sysctl.conf&nbsp;&nbsp;<\/p>\n<\/li>\n<li>\n<p>echo&nbsp;&#8220;<span>vm.overcommit_memory<\/span>&nbsp;=&nbsp;<span>1<\/span>&#8221;&nbsp;<span>&gt;<\/span><span>&gt;<\/span>&nbsp;\/etc\/sysctl.conf&nbsp;&nbsp;<\/p>\n<\/li>\n<li>\n<p>echo&nbsp;&#8220;<span>vm.swappiness<\/span>&nbsp;=&nbsp;<span>0<\/span>&#8221;&nbsp;<span>&gt;<\/span><span>&gt;<\/span>&nbsp;\/etc\/sysctl.conf&nbsp;&nbsp;<\/p>\n<\/li>\n<li>\n<p>echo&nbsp;&#8220;<span>vm.dirty_bytes<\/span>&nbsp;=&nbsp;<span>33554432<\/span>&#8221;&nbsp;<span>&gt;<\/span><span>&gt;<\/span>&nbsp;\/etc\/sysctl.conf&nbsp;&nbsp;<\/p>\n<\/li>\n<li>\n<p>\/sbin\/sysctl&nbsp;-q&nbsp;-p&nbsp;\/etc\/sysctl.conf&nbsp;&nbsp;<\/p>\n<\/li>\n<li>\n<p>groupadd&nbsp;redis&nbsp;<span>&gt;<\/span>\/dev\/null&nbsp;2<span>&gt;<\/span>&amp;1&nbsp;||&nbsp;true&nbsp;&nbsp;<\/p>\n<\/li>\n<li>\n<p>useradd&nbsp;-M&nbsp;-g&nbsp;redis&nbsp;redis&nbsp;-s&nbsp;\/sbin\/nologin&nbsp;<span>&gt;<\/span>\/dev\/null&nbsp;2<span>&gt;<\/span>&amp;1&nbsp;||&nbsp;true&nbsp;&nbsp;<\/p>\n<\/li>\n<li>\n<p>sed&nbsp;-i&nbsp;-r&nbsp;&#8216;\/redis&nbsp;soft&nbsp;nofile.*\/d&#8217;&nbsp;\/etc\/security\/limits.conf&nbsp;&nbsp;<\/p>\n<\/li>\n<li>\n<p>sed&nbsp;-i&nbsp;-r&nbsp;&#8216;\/redis&nbsp;hard&nbsp;nofile.*\/d&#8217;&nbsp;\/etc\/security\/limits.conf&nbsp;&nbsp;<\/p>\n<\/li>\n<li>\n<p>echo&nbsp;&#8220;redis&nbsp;soft&nbsp;nofile&nbsp;288000&#8221;&nbsp;<span>&gt;<\/span><span>&gt;<\/span>&nbsp;\/etc\/security\/limits.conf&nbsp;&nbsp;<\/p>\n<\/li>\n<li>\n<p>echo&nbsp;&#8220;redis&nbsp;hard&nbsp;nofile&nbsp;288000&#8221;&nbsp;<span>&gt;<\/span><span>&gt;<\/span>&nbsp;\/etc\/security\/limits.conf&nbsp;&nbsp;<\/p>\n<\/li>\n<li>\n<p>sed&nbsp;-i&nbsp;-r&nbsp;&#8216;\/redis&nbsp;soft&nbsp;nproc.*\/d&#8217;&nbsp;\/etc\/security\/limits.conf&nbsp;&nbsp;<\/p>\n<\/li>\n<li>\n<p>sed&nbsp;-i&nbsp;-r&nbsp;&#8216;\/redis&nbsp;hard&nbsp;nproc.*\/d&#8217;&nbsp;\/etc\/security\/limits.conf&nbsp;&nbsp;<\/p>\n<\/li>\n<li>\n<p>echo&nbsp;&#8220;redis&nbsp;soft&nbsp;nproc&nbsp;unlimited&#8221;&nbsp;<span>&gt;<\/span><span>&gt;<\/span>&nbsp;\/etc\/security\/limits.conf&nbsp;&nbsp;<\/p>\n<\/li>\n<li>\n<p>echo&nbsp;&#8220;redis&nbsp;hard&nbsp;nproc&nbsp;unlimited&#8221;&nbsp;<span>&gt;<\/span><span>&gt;<\/span>&nbsp;\/etc\/security\/limits.conf&nbsp;&nbsp;<\/p>\n<\/li>\n<li>\n<p>echo&nbsp;never&nbsp;<span>&gt;<\/span>&nbsp;\/sys\/kernel\/mm\/transparent_hugepage\/enabled&nbsp;<\/p>\n<\/li>\n<\/ol>\n<p><strong>2\u3001\u7edf\u4e00\u8fd0\u7ef4\u7ba1\u7406\u5de5\u5177<\/strong><\/p>\n<p>Qunar Redis \u96c6\u7fa4\u7684\u7edf\u4e00\u7ba1\u7406\u5957\u4ef6\uff0c\u5c01\u88c5\u4e86\u7cfb\u7edf\u73af\u5883\u521d\u59cb\u5316\u3001\u5b9e\u4f8b\u5b89\u88c5\u3001\u5b9e\u4f8b\u542f\u52a8\u3001\u5b9e\u4f8b\u5173\u95ed\u3001\u76d1\u63a7\u62a5\u8b66\u3001\u5b9a\u65f6\u4efb\u52a1\u7b49\u811a\u672c\uff0c\u5b9e\u73b0\u4e86\u76d1\u63a7\u3001\u7edf\u8ba1\u3001\u6ce8\u518c\u7b49\u81ea\u52a8\u5316\u64cd\u4f5c\u3002&nbsp;<\/p>\n<\/p>\n<ol>\n<li>\n<p>\/etc\/cron.d\/appendonly_switch&nbsp;&nbsp;<\/p>\n<\/li>\n<li>\n<p>\/etc\/cron.d\/auto_upgrade_toolkit&nbsp;&nbsp;<\/p>\n<\/li>\n<li>\n<p>\/etc\/cron.d\/bgrewriteaof&nbsp;&nbsp;<\/p>\n<\/li>\n<li>\n<p>\/etc\/cron.d\/check_maxmemory&nbsp;&nbsp;<\/p>\n<\/li>\n<li>\n<p>\/etc\/cron.d\/dump_rdb_keys&nbsp;&nbsp;<\/p>\n<\/li>\n<li>\n<p>\/etc\/cron.d\/rdb_backup&nbsp;&nbsp;<\/p>\n<\/li>\n<li>\n<p>\/etc\/profile.d\/q_redis_path.sh&nbsp;&nbsp;<\/p>\n<\/li>\n<li>\n<p>\/xxx\/collectd\/etc\/collectd.d\/collect_redis.conf&nbsp;&nbsp;<\/p>\n<\/li>\n<li>\n<p>\/xxx\/collectd\/lib\/collectd\/collect_redis.py&nbsp;&nbsp;<\/p>\n<\/li>\n<li>\n<p>\/xxx\/collectd\/share\/collectd\/types_redis.db&nbsp;&nbsp;<\/p>\n<\/li>\n<li>\n<p>\/xxx\/nrpe\/libexec\/q-check-redis-cpu-usage&nbsp;&nbsp;<\/p>\n<\/li>\n<li>\n<p>\/xxx\/nrpe\/libexec\/q-check-redis-latency&nbsp;&nbsp;<\/p>\n<\/li>\n<li>\n<p>\/xxx\/nrpe\/libexec\/q-check-redis-memory-usage&nbsp;&nbsp;<\/p>\n<\/li>\n<li>\n<p>\/xxx\/nrpe\/libexec\/q-check-zookeeper-ruok&nbsp;&nbsp;<\/p>\n<\/li>\n<li>\n<p>\/xxx\/redis\/tools\/cron_appendonly_switch.sh&nbsp;&nbsp;<\/p>\n<\/li>\n<li>\n<p>\/xxx\/redis\/tools\/cron_bgrewrite_aof.sh&nbsp;&nbsp;<\/p>\n<\/li>\n<li>\n<p>\/xxx\/redis\/tools\/cron_check_maxmemory.sh&nbsp;&nbsp;<\/p>\n<\/li>\n<li>\n<p>\/xxx\/redis\/tools\/cron_dump_rdb_keys.sh&nbsp;&nbsp;<\/p>\n<\/li>\n<li>\n<p>\/xxx\/redis\/tools\/cron_rdb_backup.sh&nbsp;&nbsp;<\/p>\n<\/li>\n<li>\n<p>\/xxx\/redis\/tools\/dump_rdb_keys.py&nbsp;&nbsp;<\/p>\n<\/li>\n<li>\n<p>\/xxx\/redis\/tools\/redis-cli5&nbsp;&nbsp;<\/p>\n<\/li>\n<li>\n<p>\/xxx\/redis\/tools\/redis-latency&nbsp;&nbsp;<\/p>\n<\/li>\n<li>\n<p>\/xxx\/redis\/tools\/redis_install.sh&nbsp;&nbsp;<\/p>\n<\/li>\n<li>\n<p>\/xxx\/redis\/tools\/redis_start.sh&nbsp;&nbsp;<\/p>\n<\/li>\n<li>\n<p>\/xxx\/redis\/tools\/redis_stop.sh&nbsp;<\/p>\n<\/li>\n<\/ol>\n<p><strong>3\u3001\u5355\u673a\u591a\u5b9e\u4f8b\u591a\u7248\u672c\u90e8\u7f72<\/strong><\/p>\n<p>Qunar Redis \u7684\u5b89\u88c5\u5de5\u5177\u5305\u652f\u6301\u5355\u673a\u591a\u5b9e\u4f8b\u5b89\u88c5\uff0c\u5b89\u88c5\u811a\u672c\u63d0\u4f9b\u9009\u9879\u548c\u914d\u7f6e\u6587\u4ef6\u6a21\u677f\uff0c\u53ef\u4ee5\u81ea\u5b9a\u4e49\u5b89\u88c5\u4e0d\u540c\u7248\u672c\u7684 Redis\uff0c\u76ee\u524d\u652f\u6301\u7684 Redis Server \u7248\u672c\u6709 2.8.6\u30013.0.7 \u4ee5\u53ca 4.0.14\u3002&nbsp;<\/p>\n<\/p>\n<ol>\n<li>\n<p>\/*&nbsp;\u5b89\u88c5\u5305\u53caRedis\u5b9e\u4f8b\u76ee\u5f55\u7ed3\u6784&nbsp;*\/&nbsp;&nbsp;<\/p>\n<\/li>\n<li>\n<p>.&nbsp;&nbsp;<\/p>\n<\/li>\n<li>\n<p>\u251c\u2500\u2500&nbsp;multi&nbsp;&nbsp;<\/p>\n<\/li>\n<li>\n<p>\u2502&nbsp;\u251c\u2500\u2500&nbsp;server_2800&nbsp;\/*&nbsp;Redis2.8.6\u8f6f\u4ef6\u5305&nbsp;*\/&nbsp;&nbsp;<\/p>\n<\/li>\n<li>\n<p>\u2502&nbsp;\u2502&nbsp;\u251c\u2500\u2500&nbsp;bin&nbsp;&nbsp;<\/p>\n<\/li>\n<li>\n<p>\u2502&nbsp;\u2502&nbsp;\u2514\u2500\u2500&nbsp;utils&nbsp;&nbsp;<\/p>\n<\/li>\n<li>\n<p>\u2502&nbsp;\u251c\u2500\u2500&nbsp;server_3000&nbsp;\/*&nbsp;Redis3.0.7\u8f6f\u4ef6\u5305&nbsp;*\/&nbsp;&nbsp;<\/p>\n<\/li>\n<li>\n<p>\u2502&nbsp;\u2502&nbsp;\u251c\u2500\u2500&nbsp;bin&nbsp;&nbsp;<\/p>\n<\/li>\n<li>\n<p>\u2502&nbsp;\u2502&nbsp;\u2514\u2500\u2500&nbsp;utils&nbsp;&nbsp;<\/p>\n<\/li>\n<li>\n<p>\u2502&nbsp;\u2514\u2500\u2500&nbsp;server_4000&nbsp;\/*&nbsp;Redis4.0.14\u8f6f\u4ef6\u5305&nbsp;*\/&nbsp;&nbsp;<\/p>\n<\/li>\n<li>\n<p>\u2502&nbsp;\u251c\u2500\u2500&nbsp;bin&nbsp;&nbsp;<\/p>\n<\/li>\n<li>\n<p>\u2502&nbsp;\u2514\u2500\u2500&nbsp;utils&nbsp;&nbsp;<\/p>\n<\/li>\n<li>\n<p>\u251c\u2500\u2500&nbsp;redis10088&nbsp;\/*&nbsp;\u7aef\u53e3\u4e3a10088\u7684Redis\u5b9e\u4f8b\u6570\u636e\u76ee\u5f55\uff0c\u7528\u4e8e\u5b58\u653e\u8be5\u5b9e\u4f8b\u7684\u914d\u7f6e\u6587\u4ef6\u3001\u65e5\u5fd7\u3001AOF\u6587\u4ef6\u53caRDB\u6587\u4ef6&nbsp;*\/&nbsp;&nbsp;<\/p>\n<\/li>\n<li>\n<p>\u2502&nbsp;\u251c\u2500\u2500&nbsp;bin&nbsp;&nbsp;<\/p>\n<\/li>\n<li>\n<p>\u2502&nbsp;\u2514\u2500\u2500&nbsp;utils&nbsp;&nbsp;<\/p>\n<\/li>\n<li>\n<p>\u251c\u2500\u2500&nbsp;redis10803&nbsp;\/*&nbsp;\u7aef\u53e3\u4e3a10803\u7684Redis\u5b9e\u4f8b\u6570\u636e\u76ee\u5f55\uff0c\u7528\u4e8e\u5b58\u653e\u8be5\u5b9e\u4f8b\u7684\u914d\u7f6e\u6587\u4ef6\u3001\u65e5\u5fd7\u3001AOF\u6587\u4ef6\u53caRDB\u6587\u4ef6&nbsp;*\/&nbsp;&nbsp;<\/p>\n<\/li>\n<li>\n<p>\u2502&nbsp;\u251c\u2500\u2500&nbsp;bin&nbsp;&nbsp;<\/p>\n<\/li>\n<li>\n<p>\u2502&nbsp;\u2514\u2500\u2500&nbsp;utils&nbsp;&nbsp;<\/p>\n<\/li>\n<li>\n<p>\u251c\u2500\u2500&nbsp;redis11459&nbsp;\/*&nbsp;\u7aef\u53e3\u4e3a11459\u7684Redis\u5b9e\u4f8b\u6570\u636e\u76ee\u5f55\uff0c\u7528\u4e8e\u5b58\u653e\u8be5\u5b9e\u4f8b\u7684\u914d\u7f6e\u6587\u4ef6\u3001\u65e5\u5fd7\u3001AOF\u6587\u4ef6\u53caRDB\u6587\u4ef6&nbsp;*\/&nbsp;&nbsp;<\/p>\n<\/li>\n<li>\n<p>\u2502&nbsp;\u251c\u2500\u2500&nbsp;bin&nbsp;&nbsp;<\/p>\n<\/li>\n<li>\n<p>\u2502&nbsp;\u2514\u2500\u2500&nbsp;utils&nbsp;&nbsp;<\/p>\n<\/li>\n<li>\n<p>\/*&nbsp;Redis\u5b9e\u4f8b\u5b89\u88c5\u7a0b\u5e8f\u7528\u6cd5&nbsp;*\/&nbsp;&nbsp;<\/p>\n<\/li>\n<li>\n<p>Usage:&nbsp;redis_install.sh&nbsp;-P&nbsp;<span><span>port<\/span><span>&gt;<\/span>&nbsp;-v&nbsp;[2.8|3.0|4.0]&nbsp;-p&nbsp;<span><span>password<\/span><span>&gt;<\/span>&nbsp;-m&nbsp;<span><span>size<\/span><span>&gt;<\/span>&nbsp;&nbsp;<\/span><\/span><\/span><\/p>\n<\/li>\n<li>\n<p>\u5fc5\u9009\u53c2\u6570:&nbsp;&nbsp;<\/p>\n<\/li>\n<li>\n<p>-P&nbsp;redis\u7aef\u53e3&nbsp;&nbsp;<\/p>\n<\/li>\n<li>\n<p>-p&nbsp;redis\u5bc6\u7801&nbsp;&nbsp;<\/p>\n<\/li>\n<li>\n<p>-v&nbsp;\u5c06\u8981\u5b89\u88c5\u7684redis\u7248\u672c,\u5f3a\u70c8\u63a8\u83504.0\u7248\u672c&nbsp;&nbsp;<\/p>\n<\/li>\n<li>\n<p>-m&nbsp;redis\u5b9e\u4f8b\u5141\u8bb8\u7684\u6700\u5927\u5185\u5b58\u5927\u5c0f,\u5355\u4f4d\u662fG&nbsp;&nbsp;<\/p>\n<\/li>\n<li>\n<p>\u53ef\u9009\u53c2\u6570:&nbsp;&nbsp;<\/p>\n<\/li>\n<li>\n<p>&#8211;cluster&nbsp;\u96c6\u7fa4\u6a21\u5f0f\uff0cversion<span>&gt;<\/span>=3.0&nbsp;&nbsp;<\/p>\n<\/li>\n<li>\n<p>&#8211;testenv&nbsp;\u6d4b\u8bd5\u73af\u5883&nbsp;&nbsp;<\/p>\n<\/li>\n<li>\n<p>example:&nbsp;&nbsp;<\/p>\n<\/li>\n<li>\n<p>sudo&nbsp;redis_install.sh&nbsp;-P&nbsp;6379&nbsp;-v&nbsp;4.0&nbsp;-m&nbsp;20&nbsp;-p&nbsp;1qaz2wsx&nbsp;<\/p>\n<\/li>\n<\/ol>\n<p><strong>4\u3001\u4f7f\u7528git\u7ba1\u7406Redis\u54e8\u5175<\/strong><\/p>\n<p>\u4f7f\u7528 git \u96c6\u4e2d\u7ba1\u7406\u6240\u6709\u7684\u54e8\u5175\u914d\u7f6e\uff0c\u4e00\u4e2a\u5730\u65b9\u53d1\u751f\u53d8\u66f4\uff0c\u54e8\u5175\u96c6\u7fa4\u7684\u6240\u6709\u670d\u52a1\u5668\u540c\u65f6\u62c9\u53d6\u8fdb\u884c\u540c\u6b65\u66f4\u65b0\u3002\u540c\u65f6\u8be6\u7ec6\u7684 commit log\uff0c\u65b9\u4fbf\u8ddf\u8e2a\u914d\u7f6e\u6587\u4ef6\u4fee\u6539\u5386\u53f2\u3002Qunar Redis \u54e8\u5175\u5177\u6709\u4ee5\u4e0b\u7279\u70b9\uff1a<\/p>\n<ul>\n<li>\n<p>&nbsp;\u4e00\u5957\u54e8\u5175\u53ea\u7ba1\u7406\u4e00\u4e2a\u8282\u70b9\uff0c\u5373\u53ea\u5bf9\u7aef\u53e3\u53f7\u76f8\u540c\u7684\u4e00\u7ec4 Redis\uff08\u4e00\u4e3b\u4e00\u4ece\u6216\u4e00\u4e3b\u591a\u4ece\uff09\u5b9e\u4f8b\u8fdb\u884c\u76d1\u63a7\u548c\u6545\u969c\u8f6c\u79fb\u3002<\/p>\n<\/li>\n<li>\n<p>&nbsp;\u54e8\u5175\u53ea\u8d1f\u8d23\u8282\u70b9\u7684\u9ad8\u53ef\u7528\uff0c\u5ba2\u6237\u7aef\u4e0d\u9700\u8981\u901a\u8fc7\u54e8\u5175\u6765\u8bbf\u95ee Redis \u5b9e\u4f8b\u3002<\/p>\n<\/li>\n<li>\n<p>&nbsp;\u54e8\u5175\u914d\u7f6e\u6587\u4ef6\u4f7f\u7528 git \u7edf\u4e00\u7ba1\u7406\uff0c\u914d\u7f6e\u6587\u4ef6\u4ee5[\u8282\u70b9\u7aef\u53e3\u53f7+20000]_\u96c6\u7fa4 namespace.conf \u65b9\u5f0f\u7edf\u4e00\u547d\u540d\uff0c\u4f8b\u5982 30708_redis_delay_test.conf\uff0c\u901a\u8fc7\u96c6\u7fa4\u4efb\u610f\u4e00\u4e2a\u8282\u70b9\u7684\u7aef\u53e3\u53f7\u6216\u8005 namespace \u53ef\u4ee5\u83b7\u53d6\u96c6\u7fa4\u5168\u90e8\u8282\u70b9\u7684\u4fe1\u606f\u3002<\/p>\n<\/li>\n<li>\n<p>&nbsp;\u5f53\u54e8\u5175\u76d1\u63a7\u7684\u8282\u70b9\u53d1\u751f\u5207\u6362\u65f6\uff0c\u4f1a\u66f4\u65b0\u914d\u7f6e\u4e2d\u5fc3\u5bf9\u5e94\u8282\u70b9\u7684\u4e3b\u5e93\u914d\u7f6e\u548c zookeeper \u4e2d\u5bf9\u5e94\u8282\u70b9\u7684 dataVersion\uff0c\u5ba2\u6237\u7aef\u68c0\u6d4b\u5230 zookeeper \u7684\u53d8\u5316\u4f1a\u53bb\u914d\u7f6e\u4e2d\u5fc3\u83b7\u53d6\u8282\u70b9\u6700\u65b0\u7684\u4fe1\u606f\u8fdb\u884c\u91cd\u8fde\uff0c\u540c\u65f6\u54e8\u5175\u4f1a\u5c06\u5207\u6362\u4fe1\u606f\u53d1\u9001\u81f3 DBA \u548c\u8fd0\u7ef4\u4e8b\u4ef6\u5e73\u53f0\u3002<\/p>\n<\/li>\n<li>\n<p>\u54e8\u5175\u670d\u52a1\u5668\u7684 IP \u9ed8\u8ba4\u90fd\u6dfb\u52a0\u5230 Redis \u5b9e\u4f8b\u7684\u767d\u540d\u5355\u4e2d\uff0c\u5373\u901a\u8fc7\u54e8\u5175\u670d\u52a1\u5668\u53ef\u4ee5\u8bbf\u95ee\u4efb\u4f55\u4e00\u4e2a Redis \u5b9e\u4f8b\u8fdb\u884c\u6240\u6709\u7684\u64cd\u4f5c\uff0c\u6240\u4ee5\u54e8\u5175\u670d\u52a1\u5668\u7684\u6743\u9650\u5fc5\u987b\u4e25\u683c\u63a7\u5236\uff0c\u53ea\u6709 DBA \u624d\u6709\u6743\u9650\u767b\u9646\u3002<\/p>\n<\/li>\n<\/ul>\n<p><strong>5\u3001\u8fd0\u7ef4\u64cd\u4f5c\u5e73\u53f0\u5316<\/strong><\/p>\n<p>\u4ee5\u4e0a\u51e0\u9879\u89c4\u8303\u7edf\u4e00\u7684\u6807\u51c6\u5316\u6d41\u7a0b\uff0c\u4e3a Qunar Redis \u7684\u6574\u4e2a\u8fd0\u7ef4\u5e73\u53f0\u5316\u63d0\u4f9b\u4e86\u6709\u529b\u7684\u652f\u6491\uff0c\u76ee\u524d Qunar Redis \u7684 90% \u4ee5\u4e0a\u7684\u8fd0\u7ef4\u64cd\u4f5c\u90fd\u5b9e\u73b0\u4e86\u5e73\u53f0\u81ea\u52a8\u5316\uff0c\u5305\u62ec\u5de5\u5355\u7533\u8bf7\u53ca\u5ba1\u6838\u3001\u96c6\u7fa4\u90e8\u7f72\u3001\u5b9e\u4f8b\u8fc1\u79fb\u3001\u96c6\u7fa4\u5782\u76f4\u4f38\u7f29\u3001\u4e0d\u540c\u7ef4\u5ea6\uff08\u670d\u52a1\u5668\u3001\u96c6\u7fa4\u3001\u5b9e\u4f8b\uff09\u7684\u4fe1\u606f\u67e5\u770b\u7b49\uff0c\u4e0b\u9762\u4e3b\u8981\u4ecb\u7ecd\u4e0b Qunar Redis \u96c6\u7fa4\u90e8\u7f72\u548c\u5b9e\u4f8b\u8fc1\u79fb\u7684\u5b9e\u73b0\u8fc7\u7a0b\u3002<\/p>\n<p><strong>\u96c6\u7fa4\u90e8\u7f72<\/strong><\/p>\n<p>Qunar Redis \u96c6\u7fa4\u90e8\u7f72\u65f6\u4e3b\u8981\u6709\u4ee5\u4e0b\u6b65\u9aa4\uff1a<\/p>\n<p>1\uff09\u5f00\u53d1\u4eba\u5458\u901a\u8fc7\u5e73\u53f0\u63d0\u4ea4\u96c6\u7fa4\u7533\u8bf7\u5de5\u5355\u53d1\u8d77\u6d41\u7a0b\uff0cTL \u5ba1\u6838\u5b8c\u6210\u540e\u6d41\u7a0b\u626d\u8f6c\u5230 DBA\u3002<\/p>\n<p>2\uff09DBA \u6839\u636e\u7533\u8bf7\u5de5\u5355\u7684\u4fe1\u606f\u89c4\u5212\u96c6\u7fa4\u89c4\u6a21\uff0c\u5982\u8282\u70b9\u4e2a\u6570\u3001\u5185\u5b58\u5927\u5c0f\u3001\u90e8\u7f72\u673a\u623f\u3001Redis \u7248\u672c\u7b49\u3002<\/p>\n<p>3\uff09\u6839\u636e\u96c6\u7fa4\u89c4\u5212\u5728 Redis \u96c6\u7fa4\u90e8\u7f72\u9875\u9762\u586b\u5199\u90e8\u7f72\u4fe1\u606f\u3002<\/p>\n<\/p>\n<p>4\uff09\u63d0\u4ea4\u90e8\u7f72\u4fe1\u606f\u540e\u5e73\u53f0\u4f1a\u81ea\u52a8\u7b5b\u9009\u8d44\u6e90\u7a7a\u95f2\u7684\u670d\u52a1\u5668\u8fdb\u884c\u96c6\u7fa4\u90e8\u7f72\u3002<\/p>\n<\/p>\n<p>5\uff09\u96c6\u7fa4\u90e8\u7f72\u5b8c\u6210\u540e\u4f1a\u5728\u5728 Qtalk \u4e0a\u901a\u77e5 DBA\uff0c\u96c6\u7fa4\u7684 clientcipher \u4f1a\u901a\u8fc7\u90ae\u4ef6\u65b9\u5f0f\u901a\u77e5\u5f00\u53d1\u4eba\u5458\uff0c\u540c\u65f6\u4f1a\u5c06\u96c6\u7fa4\u90e8\u7f72\u60c5\u51b5\u63a8\u9001\u5230\u516c\u53f8\u8fd0\u7ef4\u4e8b\u4ef6\u5e73\u53f0\uff0c\u4fdd\u7559\u64cd\u4f5c\u8bb0\u5f55\u3002<\/p>\n<p><strong>\u5b9e\u4f8b\u8fc1\u79fb<\/strong><\/p>\n<p>\u8fd0\u7ef4\u8fc7\u7a0b\u4e2d\u5b9e\u4f8b\u8fc1\u79fb\u4e3b\u8981\u5206\u4e3a\u4e24\u5927\u7c7b\uff1a<\/p>\n<p>1\uff09\u90e8\u5206\u5b9e\u4f8b\u8fc1\u79fb\u3002\u5f53\u67d0\u53f0\u670d\u52a1\u5668\u7684\u53ef\u7528\u8d44\u6e90\u4e0d\u8db3\u65f6\uff0c\u5c06\u8fd9\u53f0\u673a\u5668\u4e0a\u7684\u90e8\u5206\u5b9e\u4f8b\u8fc1\u79fb\u5230\u5176\u4ed6\u8d44\u6e90\u6bd4\u8f83\u7a7a\u95f2\u7684\u670d\u52a1\u5668\u4e0a\u3002\u5728\u9875\u9762\u8f93\u5165\u5b9e\u4f8b\u7684\u6e90\u4e3b\u673a\u548c\u76ee\u524d\u4e3b\u673a\uff0c\u63d0\u4ea4\u540e\u4f1a\u81ea\u52a8\u751f\u6210\u8fc1\u79fb\u4efb\u52a1\u3002<\/p>\n<\/p>\n<p>2\uff09\u6574\u673a\u5b9e\u4f8b\u8fc1\u79fb\u3002\u4e3b\u8981\u662f\u66ff\u6362\u8fc7\u4fdd\u670d\u52a1\u5668\u6216\u8005\u670d\u52a1\u5668\u9700\u8981\u505c\u673a\u7ef4\u62a4\u65f6\uff0c\u5c06\u8be5\u673a\u5668\u4e0a\u7684\u6240\u6709\u5b9e\u4f8b\u81ea\u52a8\u8fc1\u79fb\u5230\u5176\u4ed6\u8d44\u6e90\u6bd4\u8f83\u7a7a\u95f4\u7684\u670d\u52a1\u5668\u4e0a\u3002\u5728\u9875\u9762\u8f93\u5165\u9700\u8981\u8fc1\u79fb\u7684\u4e3b\u673a\u540d\uff0c\u63d0\u4ea4\u540e\u4f1a\u81ea\u52a8\u751f\u6210\u8fc1\u79fb\u4efb\u52a1\u3002<\/p>\n<\/p>\n<p>\u8fc1\u79fb\u4efb\u52a1\u5f00\u59cb\u540e\uff0c\u6574\u4e2a\u8fc1\u79fb\u8fc7\u7a0b\u65e0\u987b\u4eba\u5de5\u4ecb\u5165\uff0c\u4f1a\u81ea\u52a8\u66f4\u65b0\u6267\u884c\u8fdb\u5ea6\u5e76\u8f93\u51fa\u65e5\u5fd7\u3002<\/p>\n<\/p>\n<p>&nbsp;<\/p>\n<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5206\u4eabRedis\u9ad8\u53ef\u7528\u67b6\u6784\u8bbe\u8ba1\u5b9e\u8df5&#46;&#46;&#46;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[101],"tags":[],"class_list":["post-201460","post","type-post","status-publish","format-standard","hentry","category-database"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/201460","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/comments?post=201460"}],"version-history":[{"count":0,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/201460\/revisions"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=201460"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=201460"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=201460"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}