{"id":13410,"date":"2023-05-15T11:08:08","date_gmt":"2023-05-15T03:08:08","guid":{"rendered":"https:\/\/blog.ywdevops.cn\/?p=13410"},"modified":"2026-05-28T16:08:42","modified_gmt":"2026-05-28T08:08:42","slug":"redis-3","status":"publish","type":"post","link":"https:\/\/blog.ywdevops.cn\/index.php\/2023\/05\/15\/redis-3\/","title":{"rendered":"redis\u96c6\u7fa4\u65b9\u5f0f\u90e8\u7f72"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Redis Cluster\u662f\u4e00\u79cd\u670d\u52a1\u5668 Sharding \u6280\u672f\uff0c3.0\u7248\u672c\u5f00\u59cb\u6b63\u5f0f\u63d0\u4f9b<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Redis \u7684\u54e8\u5175\u6a21\u5f0f\u57fa\u672c\u5df2\u7ecf\u53ef\u4ee5\u5b9e\u73b0\u9ad8\u53ef\u7528\uff0c\u8bfb\u5199\u5206\u79bb \uff0c\u4f46\u662f\u5728\u8fd9\u79cd\u6a21\u5f0f\u4e0b\u6bcf\u53f0 Redis \u670d\u52a1\u5668\u90fd\u5b58\u50a8\u76f8\u540c\u7684\u6570\u636e\uff0c\u5f88\u6d6a\u8d39\u5185\u5b58\uff0c\u6240\u4ee5\u5728 redis3.0\u4e0a\u52a0\u5165\u4e86 Cluster \u96c6\u7fa4\u6a21\u5f0f\uff0c\u5b9e\u73b0\u4e86 Redis \u7684\u5206\u5e03\u5f0f\u5b58\u50a8\uff0c<strong>\u4e5f\u5c31\u662f\u8bf4\u6bcf\u53f0 Redis \u8282\u70b9\u4e0a\u5b58\u50a8\u4e0d\u540c\u7684\u5185\u5bb9<\/strong>\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u96c6\u7fa4\u6570\u636e\u5206\u7247\uff1a<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Redis \u96c6\u7fa4\u6ca1\u6709\u4f7f\u7528\u4e00\u81f4\u6027 hash\uff0c\u800c\u662f\u5f15\u5165\u4e86\u54c8\u5e0c\u69fd\u3010hash slot\u3011\u7684\u6982\u5ff5<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Redis \u96c6\u7fa4\u670916384 \u4e2a\u54c8\u5e0c\u69fd\uff0c\u6bcf\u4e2a key \u901a\u8fc7 CRC16 \u6821\u9a8c\u540e\u5bf9 16384 \u53d6\u6a21\u6765\u51b3\u5b9a\u653e\u7f6e\u54ea\u4e2a\u69fd\u3002\u96c6\u7fa4\u7684\u6bcf\u4e2a\u8282\u70b9\u8d1f\u8d23\u4e00\u90e8\u5206hash\u69fd\uff0c\u4e3e\u4e2a\u4f8b\u5b50\uff0c\u6bd4\u5982\u5f53\u524d\u96c6\u7fa4\u67093\u4e2a\u8282\u70b9\uff0c\u90a3\u4e48\u6bcf\u4e2a\u8282\u70b9\u5c31\u5305\u542b5461\u4e2a\u69fd\uff0c\u5982\u4e0b\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u8282\u70b9 A \u5305\u542b 0 \u5230 5460 \u53f7\u54c8\u5e0c\u69fd<\/li>\n\n\n\n<li>\u8282\u70b9 B \u5305\u542b 5461 \u5230 10922 \u53f7\u54c8\u5e0c\u69fd<\/li>\n\n\n\n<li>\u8282\u70b9 C \u5305\u542b 10923 \u5230 16383 \u53f7\u54c8\u5e0c\u69fd<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">\u8fd9\u79cd\u7ed3\u6784\u5f88\u5bb9\u6613\u6dfb\u52a0\u6216\u8005\u5220\u9664\u8282\u70b9\u3002\u6bd4\u5982\u5982\u679c\u6211\u9700\u8981\u5411\u96c6\u7fa4\u4e2d\u65b0\u6dfb\u52a0\u4e2a\u8282\u70b9 D \uff0c \u5c31\u9700\u8981\u4ece\u8282\u70b9 A\uff0c B\uff0c C \u4e2d\u5206\u51fa\u4e00\u90e8\u5206\u69fd\u5230 D \u4e0a\u3002\u5982\u679c\u8981\u79fb\u9664\u8282\u70b9 A \uff0c\u9700\u8981\u5c06 A \u4e2d\u7684\u69fd\u79fb\u5230 B \u548c C \u8282\u70b9\u4e0a\uff0c\u7136\u540e\u5c06\u6ca1\u6709\u4efb\u4f55\u69fd\u7684 A \u8282\u70b9\u4ece\u96c6\u7fa4\u4e2d\u79fb\u9664\u5373\u53ef\u3002\u7531\u4e8e\u4ece\u4e00\u4e2a\u8282\u70b9\u5c06\u54c8\u5e0c\u69fd\u79fb\u52a8\u5230\u53e6\u4e00\u4e2a\u8282\u70b9\u5e76\u4e0d\u4f1a\u505c\u6b62\u670d\u52a1\uff0c\u6240\u4ee5\u65e0\u8bba\u6dfb\u52a0\u5220\u9664\u6216\u8005\u6539\u53d8\u67d0\u4e2a\u8282\u70b9\u7684\u54c8\u5e0c\u69fd\u7684\u6570\u91cf\u90fd\u4e0d\u4f1a\u9020\u6210\u96c6\u7fa4\u4e0d\u53ef\u7528\u7684\u72b6\u6001\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u5728 Redis \u7684\u6bcf\u4e00\u4e2a\u8282\u70b9\u4e0a\uff0c\u90fd\u6709\u8fd9\u4e48\u4e24\u4e2a\u4e1c\u897f\uff0c\u4e00\u4e2a\u662f\u63d2\u69fd\uff08slot\uff09\uff0c\u5b83\u7684\u7684\u53d6\u503c\u8303\u56f4\u662f\uff1a0-16383\u3002\u8fd8\u6709\u4e00\u4e2a\u5c31\u662f cluster\uff0c\u53ef\u4ee5\u7406\u89e3\u4e3a\u662f\u4e00\u4e2a\u96c6\u7fa4\u7ba1\u7406\u7684\u63d2\u4ef6\u3002\u5f53\u6211\u4eec\u7684\u5b58\u53d6\u7684 Key\u5230\u8fbe\u7684\u65f6\u5019\uff0cRedis \u4f1a\u6839\u636e CRC16 \u7684\u7b97\u6cd5\u5f97\u51fa\u4e00\u4e2a\u7ed3\u679c\uff0c\u7136\u540e\u628a\u7ed3\u679c\u5bf9 16384 \u6c42\u4f59\u6570\uff0c\u8fd9\u6837\u6bcf\u4e2a key \u90fd\u4f1a\u5bf9\u5e94\u4e00\u4e2a\u7f16\u53f7\u5728 0-16383 \u4e4b\u95f4\u7684\u54c8\u5e0c\u69fd\uff0c\u901a\u8fc7\u8fd9\u4e2a\u503c\uff0c\u53bb\u627e\u5230\u5bf9\u5e94\u7684\u63d2\u69fd\u6240\u5bf9\u5e94\u7684\u8282\u70b9\uff0c\u7136\u540e\u76f4\u63a5\u81ea\u52a8\u8df3\u8f6c\u5230\u8fd9\u4e2a\u5bf9\u5e94\u7684\u8282\u70b9\u4e0a\u8fdb\u884c\u5b58\u53d6\u64cd\u4f5c<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-purple-color\">slot\u53ea\u5b58\u5728\u96c6\u7fa4\u7684master\u8282\u70b9\uff0c\u800c\u4e14\u65e0\u8bba\u96c6\u7fa4\u6709\u591a\u5c11\u4e2amaster\uff0c\u603b\u6570\u90fd\u662f16384\u4e2aslot\uff0c\u5e76\u4e14\u4e00\u4e2aslot\u4e2d\u53ef\u4ee5\u5b58\u50a8\u6210\u5343\u4e0a\u4e07\u4e2akey<\/mark><\/strong><\/p>\n\n\n\n<p class=\"has-luminous-vivid-amber-background-color has-background wp-block-paragraph\">\u6ce8\uff1a\u53ea\u6709\u96c6\u7fa4\u624d\u6709slot\u7684\u6982\u5ff5\uff0c\u5355\u5b9e\u4f8b\u6ca1\u6709<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-red-color\">Redis Cluster \u4e00\u6b21\u5199\u8bf7\u6c42\u7684\u5b8c\u6574\u8def\u7531\u8fc7\u7a0b\u5927\u81f4\u5982\u4e0b\uff1a<\/mark><\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">1\u3001\u5ba2\u6237\u7aef\u901a\u8fc7TCP\u8fde seed \u8282\u70b9\uff08\u79cd\u5b50\u8282\u70b9\uff09<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u5ba2\u6237\u7aef\u968f\u673a\u6311\u4e00\u4e2a seed\uff08\u5982 <code>redis-cluster-3<\/code>\uff0c\u53ef\u80fd\u662f Replica\uff09\uff0c\u5efa\u7acb TCP \u8fde\u63a5<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">2\u3001\u53d1\u9001 <code>CLUSTER NODES<\/code>\uff0cReplica \/ Master \u90fd\u8fd4\u56de\u5b8c\u6574\u4fe1\u606f\uff0c\u6bd4\u5982\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Master-0 \u2192 slot 0\u20135460\r\nMaster-1 \u2192 slot 5461\u201310922\r\nMaster-2 \u2192 slot 10923\u201316383<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">3\u3001\u5ba2\u6237\u7aef\u672c\u5730\u7f13\u5b58 slot \u2192 Master IP \u6620\u5c04\uff0c\u5ba2\u6237\u7aef\u5728\u5185\u5b58\u4e2d\u5f62\u6210\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>slot 0\u20135460   \u2192 redis-cluster-0 IP\r\nslot 5461\u201310922 \u2192 redis-cluster-1 IP\r\nslot 10923\u201316383 \u2192 redis-cluster-2 IP<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u5230\u6b64\uff0c<strong>\u8def\u7531\u8868\u5efa\u7acb\u5b8c\u6210<\/strong>\uff0cseed \u8282\u70b9\u4f7f\u547d\u7ed3\u675f<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">4\u3001\u4e1a\u52a1\u8bf7\u6c42\u8def\u7531\u8fc7\u7a0b(\u91cd\u70b9)\uff0c\u5047\u5982\u5199\u5165\u5185\u5bb9\u5982\u4e0b\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>set(\"user:1001\", \"Tom\");<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">(1)\u3001\u8ba1\u7b97 key \u2192 slot<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>slot = CRC16(\"user:1001\") % 16384  ==> \u5047\u5982 slot = 5247<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">(2)\u3001\u5ba2\u6237\u7aef\u67e5\u8be2\u7f13\u5b58\u7684\u8def\u7531\u8868\uff0c\u6bd4\u5982\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>slot 5247 \u2192 redis-cluster-1 (Master)<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">(3)\u3001\u5ba2\u6237\u7aef <strong>\u76f4\u8fde redis-cluster-1:6379<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>SET user:1001 Tom<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">(4)\u3001Master \u5904\u7406\u5199\u8bf7\u6c42<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u6821\u9a8c ACL \/ \u5bc6\u7801<\/li>\n\n\n\n<li>\u5199\u5165 DB<\/li>\n\n\n\n<li>\u5f02\u6b65\u590d\u5236\u7ed9 Replica\uff08<code>redis-cluster-4<\/code>\uff09<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">\u2705 \u5199\u6210\u529f\u8fd4\u56de <code>OK<\/code>\uff01\uff01\uff01\uff01<\/p>\n\n\n\n<p class=\"has-luminous-vivid-amber-background-color has-background wp-block-paragraph\">\u6ce8\uff1aReplica \u5347\u4e3b\u540e\uff0c\u76f4\u63a5\u63a5\u7ba1\u539f Master \u7684 slot\uff0cslot \u4e0d\u91cd\u65b0\u8ba1\u7b97\u3001\u4e0d\u8fc1\u79fb\u3001\u4e0d\u91cd\u65b0\u5206\u914d\uff0cslot \u7f16\u53f7\u548c\u5f52\u5c5e\u5173\u7cfb\u5b8c\u5168\u4e0d\u53d8\uff0c\u53ea\u662f Master \u6362\u4e86 IP\/Node-ID<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">redis-cluster\u96c6\u7fa4\u5f15\u5165\u4e86\u4e3b\u4ece\u590d\u5236\u6a21\u578b\uff0c\u4e00\u4e2a\u4e3b\u8282\u70b9\u5bf9\u5e94\u4e00\u4e2a\u6216\u8005\u591a\u4e2a\u4ece\u8282\u70b9\uff0c\u5f53\u4e3b\u8282\u70b9\u5b95\u673a\u7684\u65f6\u5019\uff0c\u5c31\u4f1a\u542f\u7528\u4ece\u8282\u70b9\u3002\u5f53\u5176\u5b83\u4e3b\u8282\u70b9 ping \u4e00\u4e2a\u4e3b\u8282\u70b9 A \u65f6\uff0c\u5982\u679c\u534a\u6570\u4ee5\u4e0a\u7684\u4e3b\u8282\u70b9\u4e0e A \u901a\u4fe1\u8d85\u65f6\uff0c\u90a3\u4e48\u8ba4\u4e3a\u4e3b\u8282\u70b9 A \u5b95\u673a\u4e86\u3002\u5982\u679c\u4e3b\u8282\u70b9 A \u548c\u5b83\u7684\u4ece\u8282\u70b9 A1 \u90fd\u5b95\u673a\u4e86\uff0c\u90a3\u4e48\u8be5\u96c6\u7fa4\u5c31\u65e0\u6cd5\u518d\u63d0\u4f9b\u670d\u52a1\u4e86\uff0c\u4f1a\u62a5\u69fd\u65e0\u6cd5\u83b7\u53d6<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u96c6\u7fa4\u4f18\u70b9\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u5b9e\u73b0\u4e86\u5206\u5e03\u5f0f\u5b58\u50a8\uff0c\u8282\u7701\u4e86\u5185\u5b58<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">\u96c6\u7fa4\u6b63\u5e38\u5de5\u4f5c\u81f3\u5c11\u9700\u89813\u4e2a\u4e3b\u8282\u70b9\uff0c\u672c\u4f8b\u5b50\u521b\u5efa6\u4e2a\u8282\u70b9\uff0c\u4e09\u4e2a\u4e3b\u8282\u70b9\u4e09\u4e2a\u4ece\u8282\u70b9\uff0c\u5bf9\u5e94IP\u548c\u7aef\u53e3\u5982\u4e0b\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td class=\"has-text-align-center\" data-align=\"center\">IP<\/td><td class=\"has-text-align-center\" data-align=\"center\">\u7aef\u53e3<\/td><td class=\"has-text-align-center\" data-align=\"center\">redis\u7248\u672c<\/td><\/tr><tr><td class=\"has-text-align-center\" data-align=\"center\">10.9.2.29<\/td><td class=\"has-text-align-center\" data-align=\"center\">7000<\/td><td class=\"has-text-align-center\" data-align=\"center\">7.0.11<\/td><\/tr><tr><td class=\"has-text-align-center\" data-align=\"center\">10.9.2.29<\/td><td class=\"has-text-align-center\" data-align=\"center\">7001<\/td><td class=\"has-text-align-center\" data-align=\"center\"><\/td><\/tr><tr><td class=\"has-text-align-center\" data-align=\"center\">10.9.2.29<\/td><td class=\"has-text-align-center\" data-align=\"center\">7002<\/td><td class=\"has-text-align-center\" data-align=\"center\"><\/td><\/tr><tr><td class=\"has-text-align-center\" data-align=\"center\">10.9.2.247<\/td><td class=\"has-text-align-center\" data-align=\"center\">7003<\/td><td class=\"has-text-align-center\" data-align=\"center\"><\/td><\/tr><tr><td class=\"has-text-align-center\" data-align=\"center\">10.9.2.247<\/td><td class=\"has-text-align-center\" data-align=\"center\">7004<\/td><td class=\"has-text-align-center\" data-align=\"center\"><\/td><\/tr><tr><td class=\"has-text-align-center\" data-align=\"center\">10.9.2.247<\/td><td class=\"has-text-align-center\" data-align=\"center\">7005<\/td><td class=\"has-text-align-center\" data-align=\"center\"><\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"has-text-align-center wp-block-paragraph\"><strong><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-purple-color\">\u90e8\u7f72<\/mark><\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">1\u3001\u9996\u5148\u4e24\u53f0\u673a\u5668\u901a\u8fc7\u7f16\u8bd1\u65b9\u5f0f\u5b89\u88c5redis<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u53c2\u8003\u7f16\u8bd1\u5b89\u88c5\u65b9\u5f0f\u7ae0\u8282\uff1a<a href=\"https:\/\/blog.ywdevops.cn\/index.php\/2021\/10\/20\/redis-2\/\" target=\"_blank\" rel=\"noreferrer noopener\">https:\/\/blog.ywdevops.cn\/index.php\/2021\/10\/20\/redis-2\/<\/a><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">2\u3001\u767b\u5f5510.9.2.29\u673a\u5668\uff0c\u8fdb\u5165redis\u8def\u5f84\uff0c\u521b\u5efa\u96c6\u7fa4\u76ee\u5f55\u548c\u7aef\u53e3\u76ee\u5f55\uff0c\u5982\u4e0b\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>cd \/usr\/local\/redis-7.0.11\nmkdir -p redis_cluster\/{7000,7001,7002}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">10.9.2.247\u673a\u5668\u540c\u6837\u64cd\u4f5c\uff0c\u7aef\u53e3\u6587\u4ef6\u5939\u53d8\u4e3a7003\u30017004\u30017005<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>cd \/usr\/local\/redis-7.0.11\nmkdir -p redis_cluster\/{7003,7004,7005}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">3\u3001\u5c06\u914d\u7f6e\u6587\u4ef6\u590d\u5236\u5230\u5bf9\u5e94\u7684\u7aef\u53e3\u6587\u4ef6\u5939\u4e2d\uff0c\u5e76\u4fee\u6539\u540d\u5b57\uff0c\u5982\u4e0b\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>cp redis.conf redis_cluster\/7000\/redis_7000.conf     #10.9.2.29\u673a\u5668\ncp redis.conf redis_cluster\/7001\/redis_7001.conf     #10.9.2.29\u673a\u5668\ncp redis.conf redis_cluster\/7002\/redis_7002.conf     #10.9.2.29\u673a\u5668\ncp redis.conf redis_cluster\/7003\/redis_7003.conf     #10.9.2.247\u673a\u5668\ncp redis.conf redis_cluster\/7004\/redis_7004.conf     #10.9.2.247\u673a\u5668\ncp redis.conf redis_cluster\/7005\/redis_7005.conf     #10.9.2.247\u673a\u5668<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">4\u3001\u4fee\u6539\u4e0a\u9762\u6587\u4ef6\u5939\u4e2d\u7684\u914d\u7f6e\u6587\u4ef6\uff0c6\u4e2a\u914d\u7f6e\u6587\u4ef6\u90fd\u8981\u4fee\u6539\uff0c\u5982\u4e0b\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>bind 0.0.0.0 \n# \u6539\u4e3a\u5bf9\u5e94\u7684\u7aef\u53e3\u53f7\nport 7000\n# \u540e\u53f0\u542f\u52a8\ndaemonize yes\n#\u4fdd\u62a4\u6a21\u5f0f\nprotected-mode no\n# \u5f00\u542f\u96c6\u7fa4\ncluster-enabled yes\n#\u96c6\u7fa4\u8282\u70b9\u914d\u7f6e\u6587\u4ef6\ncluster-config-file nodes-7000.conf\n# \u96c6\u7fa4\u8fde\u63a5\u8d85\u65f6\u65f6\u95f4\ncluster-node-timeout 5000\n# \u8fdb\u7a0bpid\u7684\u6587\u4ef6\u4f4d\u7f6e\npidfile \/var\/run\/redis-7000.pid\n# \u5f00\u542faof\nappendonly yes\n# aof\u6587\u4ef6\u8def\u5f84\nappendfilename \"appendonly-7000.aof\"\n# rdb\u6587\u4ef6\u8def\u5f84\ndbfilename dump-7000.rdb\n#\u65e5\u5fd7\u4f4d\u7f6e\nlogfile \"redis_cluster\/7000\/redis_7000.log\"\n#\u5c06\u6570\u636e\u4ece\u5355\u8282\u70b9\u5207\u6362\u4e3a\u96c6\u7fa4\u6a21\u5f0f\uff0c\u4e0d\u914d\u7f6e\u4f1a\u6709\u544a\u8b66\u63d0\u793a\ndatabase 1\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">5\u3001\u542f\u52a8\u4e24\u53f0\u673a\u5668\u76846\u4e2aredis\uff0c\u5982\u4e0b\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/usr\/bin\/redis-server redis_cluster\/7000\/redis_7000.conf\n\/usr\/bin\/redis-server redis_cluster\/7001\/redis_7001.conf\n\/usr\/bin\/redis-server redis_cluster\/7002\/redis_7002.conf\n\/usr\/bin\/redis-server redis_cluster\/7003\/redis_7003.conf\n\/usr\/bin\/redis-server redis_cluster\/7004\/redis_7004.conf\n\/usr\/bin\/redis-server redis_cluster\/7005\/redis_7005.conf\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">6\u3001\u4e0a\u9762\u547d\u4ee4\u53ea\u662f\u542f\u52a86\u4e2aredis\uff0c\u8fd8\u672a\u5c06\u5176\u5173\u8054\u4e00\u8d77\uff0c\u6267\u884c\u547d\u4ee4\u521b\u5efa\u96c6\u7fa4\uff0c\u5173\u8054redis\uff0c\u5982\u4e0b\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>redis-cli --cluster create --cluster-replicas 1 10.9.2.29:7000 10.9.2.29:7001 10.9.2.29:7002 10.9.2.247:7003 10.9.2.247:7004 10.9.2.247:7005\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u63d0\u793aCan I set the above configuration? (type &#8216;yes&#8217; to accept): \u7684\u65f6\u5019\u9009\u62e9yew\uff0c\u521b\u5efa\u5b8c\u5982\u56fe\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"707\" height=\"474\" src=\"https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2023\/05\/9-2.png\" alt=\"\" class=\"wp-image-13429\" srcset=\"https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2023\/05\/9-2.png 707w, https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2023\/05\/9-2-300x201.png 300w, https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2023\/05\/9-2-600x402.png 600w\" sizes=\"auto, (max-width: 707px) 100vw, 707px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">\u67e5\u770b\u96c6\u7fa4\u72b6\u6001\u4fe1\u606f\uff0c\u5982\u56fe\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"707\" height=\"169\" src=\"https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2023\/05\/10-1.png\" alt=\"\" class=\"wp-image-13431\" srcset=\"https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2023\/05\/10-1.png 707w, https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2023\/05\/10-1-300x72.png 300w, https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2023\/05\/10-1-600x143.png 600w\" sizes=\"auto, (max-width: 707px) 100vw, 707px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">7\u3001\u6d4b\u8bd5<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u9996\u5148\u572810.9.2.29\u673a\u5668\u901a\u8fc7\u5982\u4e0b\u547d\u4ee4\u8fde\u63a5\u5230\u96c6\u7fa4\uff0c\u7136\u540e\u8bbe\u7f6ekey\u548c\u83b7\u53d6key\uff0c\u5982\u4e0b\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>redis-cli -c -p 7000    #\u5fc5\u987b\u52a0-c\u53c2\u6570\uff0c\u5426\u5219\u6267\u884cset\u547d\u4ee4\u62a5\u9519(error) MOVED 15495 10.9.2.29:7001\nset hello world<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"708\" height=\"143\" src=\"https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2023\/05\/11-2.png\" alt=\"\" class=\"wp-image-13435\" srcset=\"https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2023\/05\/11-2.png 708w, https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2023\/05\/11-2-300x61.png 300w, https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2023\/05\/11-2-600x121.png 600w\" sizes=\"auto, (max-width: 708px) 100vw, 708px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">\u767b\u5f5510.9.2.247\u7684\u4efb\u610f\u4e00\u4e2aredis\uff0c\u67e5\u8be2key\u5bf9\u5e94\u7684\u503c\uff0c\u5982\u56fe\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"707\" height=\"201\" src=\"https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2023\/05\/12-1.png\" alt=\"\" class=\"wp-image-13436\" srcset=\"https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2023\/05\/12-1.png 707w, https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2023\/05\/12-1-300x85.png 300w, https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2023\/05\/12-1-600x171.png 600w\" sizes=\"auto, (max-width: 707px) 100vw, 707px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">\u901a\u8fc7info\u547d\u4ee4\u4e5f\u53ef\u4ee5\u5f53\u524dredis\u8282\u70b9\u7684\u4fe1\u606f\uff0c\u5305\u62ec\u4e3b\u4ece\u4fe1\u606f\uff0c\u5982\u56fe\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"707\" height=\"211\" src=\"https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2023\/05\/13.png\" alt=\"\" class=\"wp-image-13438\" srcset=\"https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2023\/05\/13.png 707w, https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2023\/05\/13-300x90.png 300w, https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2023\/05\/13-600x179.png 600w\" sizes=\"auto, (max-width: 707px) 100vw, 707px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">8\u3001\u7ed9\u96c6\u7fa4\u8bbe\u7f6e\u5bc6\u7801\u8ba4\u8bc1<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u4e0a\u9762\u96c6\u7fa4\u9ed8\u8ba4\u662f\u6ca1\u6709\u8bbe\u7f6e\u5bc6\u7801\u7684\uff0c\u4e00\u822c\u4f7f\u7528\u7684\u65f6\u5019\u90fd\u662f\u9700\u8981\u8bbe\u7f6e\u5bc6\u7801\u7684\uff0c\u65b9\u6cd5\u5982\u4e0b\uff1a<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">(1)\u3001\u4fee\u6539\u6bcf\u4e2aRedis\u7684\u914d\u7f6e\u6587\u4ef6\uff0c\u8bbe\u7f6e\u4e24\u4e2a\u5bc6\u7801\u4f4d\u7f6e\uff0c\u5982\u4e0b\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>masterauth  \"password\"\nrequirepass \"password\"<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">(2)\u3001\u91cd\u542f\u6bcf\u4e2aredis\u8282\u70b9\uff0c\u7136\u540e\u901a\u8fc7\u5bc6\u7801\u767b\u5f55\u96c6\u7fa4\uff0c\u5982\u4e0b\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>redis-cli -p 7000 -c -a Abcd1234<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">(3)\u3001\u7136\u540e\u6267\u884cset\u548cget\u5373\u53ef<\/p>\n\n\n\n<p class=\"has-luminous-vivid-amber-background-color has-background wp-block-paragraph\">\u6ce8\u610f\uff1a\u5982\u679c\u767b\u5f55\u7684\u65f6\u5019\u4e0d\u6307\u5b9a-a \uff0c\u90a3\u4e48\u767b\u5f55\u540e\u4f7f\u7528auth\u8ba4\u8bc1\u540e\u518d\u4f7f\u7528set\u547d\u4ee4\u8fd8\u662f\u63d0\u793a\u8981\u8ba4\u8bc1<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Redis Cluster\u662f\u4e00\u79cd\u670d\u52a1\u5668 Sharding \u6280\u672f\uff0c3.0\u7248\u672c\u5f00\u59cb\u6b63\u5f0f\u63d0\u4f9b Redis \u7684\u54e8\u5175\u6a21\u5f0f [&hellip;]<\/p>\n","protected":false},"author":3,"featured_media":13411,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1,25],"tags":[],"class_list":["post-13410","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-redis","category-database"],"blocksy_meta":{"styles_descriptor":{"styles":{"desktop":"","tablet":"","mobile":""},"google_fonts":[],"version":8}},"_links":{"self":[{"href":"https:\/\/blog.ywdevops.cn\/index.php\/wp-json\/wp\/v2\/posts\/13410","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.ywdevops.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.ywdevops.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.ywdevops.cn\/index.php\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.ywdevops.cn\/index.php\/wp-json\/wp\/v2\/comments?post=13410"}],"version-history":[{"count":34,"href":"https:\/\/blog.ywdevops.cn\/index.php\/wp-json\/wp\/v2\/posts\/13410\/revisions"}],"predecessor-version":[{"id":20448,"href":"https:\/\/blog.ywdevops.cn\/index.php\/wp-json\/wp\/v2\/posts\/13410\/revisions\/20448"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blog.ywdevops.cn\/index.php\/wp-json\/wp\/v2\/media\/13411"}],"wp:attachment":[{"href":"https:\/\/blog.ywdevops.cn\/index.php\/wp-json\/wp\/v2\/media?parent=13410"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.ywdevops.cn\/index.php\/wp-json\/wp\/v2\/categories?post=13410"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.ywdevops.cn\/index.php\/wp-json\/wp\/v2\/tags?post=13410"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}