{"id":97635,"date":"2026-08-29T22:17:08","date_gmt":"2026-08-29T14:17:08","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/97635.html"},"modified":"2026-08-29T22:17:08","modified_gmt":"2026-08-29T14:17:08","slug":"redis%e7%9f%a5%e8%af%86%e7%82%b9%ef%bc%88%e4%ba%8c%ef%bc%89","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/97635.html","title":{"rendered":"Redis\u77e5\u8bc6\u70b9\uff08\u4e8c\uff09"},"content":{"rendered":"<p>redis\u77e5\u8bc6\u70b9&#xff08;\u4e8c&#xff09;<\/p>\n<h3>1.\u4e3b\u4ece\u590d\u5236\u4f18\u5316<\/h3>\n<ul>\n<li>redis\u4e3b\u4ece\u540c\u6b65\u5206\u4e3a\u5168\u91cf\u540c\u6b65\u548c\u589e\u91cf\u540c\u6b65\u3002\u4e14\u4e3b\u4ece\u540c\u6b65\u662f\u975e\u963b\u585e\u7684&#xff0c;\u5373\u540c\u6b65\u8fc7\u7a0b\u4e0d\u4f1a\u5f71\u54cd\u4e3b\u670d\u52a1\u5668\u7684\u6b63\u5e38\u8bbf\u95ee\u3002<\/li>\n<li>\u4e3b\u8282\u70b9\u91cd\u542f\u4f1a\u5bfc\u81f4\u5168\u91cf\u540c\u6b65&#xff0c;\u4ece\u8282\u70b9\u91cd\u542f\u53ea\u4f1a\u5bfc\u81f4\u589e\u91cf\u540c\u6b65\u3002<\/li>\n<\/ul>\n<h4>1.1\u5168\u91cf\u590d\u5236\u8fc7\u7a0b<\/h4>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/08\/20260829141658-6a92e9dac406e.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<ul>\n<li>\u4e3b\u4ece\u8282\u70b9\u5efa\u7acb\u8fde\u63a5&#xff0c;\u9a8c\u8bc1\u8eab\u4efd\u540e&#xff0c;\u4ece\u8282\u70b9\u60f3\u4e3b\u8282\u70b9\u53d1\u9001PSYNC\u547d\u4ee4\u3002<\/li>\n<li>\u4e3b\u8282\u70b9\u5411\u4ece\u8282\u70b9\u53d1\u9001FULLRESYNC\u547d\u4ee4,\u5305\u62ecmaster_replid(runID)\u548coffset<\/li>\n<li>\u4ece\u8282\u70b9\u4fdd\u5b58\u4e3b\u8282\u70b9\u4fe1\u606f<\/li>\n<li>\u4e3b\u8282\u70b9\u6267\u884cBGSAVE\u4fdd\u5b58RDB\u6587\u4ef6,\u540c\u65f6\u8bb0\u5f55\u65b0\u7684\u8bb0\u5f55\u5230buffer\u4e2d<\/li>\n<li>\u4e3b\u8282\u70b9\u53d1\u9001RDB\u6587\u4ef6\u7ed9\u4ece\u8282\u70b9<\/li>\n<li>\u4e3b\u8282\u70b9\u5c06\u65b0\u6536\u5230buffer\u4e2d\u7684\u8bb0\u5f55\u53d1\u9001\u81f3\u4ece\u8282\u70b9<\/li>\n<li>\u4ece\u8282\u70b9\u5220\u9664\u672c\u673a\u7684\u65e7\u6570\u636e<\/li>\n<li>\u4ece\u8282\u70b9\u52a0\u8f7dRDB<\/li>\n<li>\u4ece\u8282\u70b9\u540c\u6b65\u4e3b\u8282\u70b9\u7684buffer\u4fe1\u606f<\/li>\n<\/ul>\n<p>\u200b\u5168\u91cf\u590d\u5236\u53d1\u751f\u5728\u4e0b\u9762\u60c5\u51b5<\/p>\n<ul>\n<li>\u4ece\u8282\u70b9\u9996\u6b21\u8fde\u63a5\u4e3b\u8282\u70b9(\u65e0master_replid\/run_id)<\/li>\n<li>\u4ece\u8282\u70b9\u7684\u590d\u5236\u504f\u79fb\u91cf\u4e0d\u5728\u590d\u5236\u79ef\u538b\u7f13\u51b2\u533a\u5185<\/li>\n<li>\u4ece\u8282\u70b9\u65e0\u6cd5\u8fde\u63a5\u4e3b\u8282\u70b9\u8d85\u8fc7\u4e00\u5b9a\u7684\u65f6\u95f4<\/li>\n<\/ul>\n<h4>1.2\u589e\u91cf\u590d\u5236\u8fc7\u7a0b<\/h4>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/08\/20260829141702-6a92e9de829c3.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<ul>\n<li>\u5728\u4e3b\u4ece\u590d\u5236\u9996\u6b21\u5b8c\u6210\u5168\u91cf\u540c\u6b65\u4e4b\u540e\u518d\u6b21\u9700\u8981\u540c\u6b65\u65f6,\u4ece\u670d\u52a1\u5668\u53ea\u8981\u53d1\u9001\u5f53\u524d\u7684offset\u4f4d\u7f6e(\u7c7b\u4f3c\u4e8eMySQL\u7684binlog\u7684\u4f4d\u7f6e)\u7ed9\u4e3b\u670d\u52a1\u5668&#xff0c;\u7136\u540e\u4e3b\u670d\u52a1\u5668\u6839\u636e\u76f8\u5e94\u7684\u4f4d\u7f6e\u5c06\u4e4b\u540e\u7684\u6570\u636e(\u5305\u62ec\u5199\u5728\u7f13\u51b2\u533a\u7684\u79ef\u538b\u6570\u636e)\u53d1\u9001\u7ed9\u4ece\u670d\u52a1\u5668,\u518d\u6b21\u5c06\u5176\u4fdd\u5b58\u5230\u4ece\u8282\u70b9\u5185\u5b58\u5373\u53ef<\/li>\n<\/ul>\n<h4>1.3\u4e3b\u4ece\u540c\u6b65\u5b8c\u6574\u8fc7\u7a0b<\/h4>\n<p>\u4e3b\u4ece\u540c\u6b65\u5b8c\u6574\u8fc7\u7a0b\u5982\u4e0b&#xff1a;<\/p>\n<ul>\n<li>slave\u53d1\u8d77\u8fde\u63a5master&#xff0c;\u9a8c\u8bc1\u901a\u8fc7\u540e,\u53d1\u9001PSYNC\u547d\u4ee4<\/li>\n<li>master\u63a5\u6536\u5230PSYNC\u547d\u4ee4\u540e&#xff0c;\u6267\u884cBGSAVE\u547d\u4ee4\u5c06\u5168\u90e8\u6570\u636e\u4fdd\u5b58\u81f3RDB\u6587\u4ef6\u4e2d,\u5e76\u5c06\u540e\u7eed\u53d1\u751f\u7684\u5199\u64cd\u4f5c\u8bb0\u5f55\u81f3buffer\u4e2d<\/li>\n<li>master\u5411\u6240\u6709slave\u53d1\u9001RDB\u6587\u4ef6<\/li>\n<li>master\u5411\u6240\u6709slave\u53d1\u9001\u540e\u7eed\u8bb0\u5f55\u5728buffer\u4e2d\u5199\u64cd\u4f5c<\/li>\n<li>slave\u6536\u5230\u5feb\u7167\u6587\u4ef6\u540e\u4e22\u5f03\u6240\u6709\u65e7\u6570\u636e<\/li>\n<li>slave\u52a0\u8f7d\u6536\u5230\u7684RDB\u5230\u5185\u5b58<\/li>\n<li>slave \u6267\u884c\u6765\u81eamaster\u63a5\u6536\u5230\u7684buffer\u5199\u64cd\u4f5c<\/li>\n<li>\u5f53slave\u5b8c\u6210\u5168\u91cf\u590d\u5236\u540e,\u540e\u7eedmaster\u53ea\u4f1a\u5148\u53d1\u9001slave_repl_offset\u4fe1\u606f<\/li>\n<li>\u4ee5\u540eslave\u6bd4\u8f83\u81ea\u8eab\u548cmaster\u7684\u5dee\u5f02,\u53ea\u4f1a\u8fdb\u884c\u589e\u91cf\u590d\u5236\u7684\u6570\u636e\u5373\u53ef<\/li>\n<\/ul>\n<h4>1.4\u907f\u514d\u5168\u91cf\u590d\u5236<\/h4>\n<ul>\n<li>\u7b2c\u4e00\u6b21\u5168\u91cf\u590d\u5236\u4e0d\u53ef\u907f\u514d,\u540e\u7eed\u7684\u5168\u91cf\u590d\u5236\u53ef\u4ee5\u5229\u7528\u5c0f\u4e3b\u8282\u70b9(\u5185\u5b58\u5c0f),\u4e1a\u52a1\u4f4e\u5cf0\u65f6\u8fdb\u884c\u5168\u91cf<\/li>\n<li>\u8282\u70b9master_replid\u6216RUN_ID\u4e0d\u5339\u914d:\u4e3b\u8282\u70b9\u91cd\u542f\u4f1a\u5bfc\u81f4master_replid\u6216RUN_ID\u53d8\u5316,\u53ef\u80fd\u4f1a\u89e6\u53d1\u5168\u91cf\u590d\u5236,\u53ef\u4ee5\u5229\u7528config\u547d\u4ee4\u52a8\u6001\u4fee\u6539\u914d\u7f6e&#xff0c;\u6545\u969c\u8f6c\u79fb\u4f8b\u5982\u54e8\u5175\u6216\u96c6\u7fa4\u9009\u4e3e\u65b0\u7684\u4e3b\u8282\u70b9\u4e5f\u4e0d\u4f1a\u5168\u91cf\u590d\u5236,\u800c\u4ece\u8282\u70b9\u91cd\u542f\u52a8,\u4e0d\u4f1a\u5bfc\u81f4\u5168\u91cf\u590d\u5236,\u53ea\u4f1a\u589e\u91cf\u590d\u5236<\/li>\n<li>\u590d\u5236\u6324\u538b\u7f13\u51b2\u533a\u4e0d\u8db3&#xff1a;\u5f53\u4e3b\u8282\u70b9\u751f\u6210\u7684\u65b0\u6570\u636e\u5927\u4e8e\u7f13\u51b2\u533a\u5927\u5c0f&#xff0c;\u4ece\u8282\u70b9\u6062\u590d\u548c\u4e3b\u673a\u8282\u70b9\u8fde\u63a5\u540e&#xff0c;\u4f1a\u5bfc\u81f4\u5168\u91cf\u590d\u5236\u3002\u89e3\u51b3\u65b9\u6cd5&#xff1a;\u5c06repl-backlog-size\u8c03\u5927<\/li>\n<\/ul>\n<h4>1.5\u907f\u514d\u590d\u5236\u98ce\u66b4<\/h4>\n<ul>\n<li>\n<p>\u5355\u4e3b\u8282\u70b9\u590d\u5236\u98ce\u66b4&#xff1a;\u5f53\u4e3b\u8282\u70b9\u91cd\u542f&#xff0c;\u591a\u4ece\u8282\u70b9\u590d\u5236&#xff1b;\u89e3\u51b3\u65b9\u6cd5&#xff1a;\u8ddf\u6362\u590d\u5236\u62d3\u6251\u3002\u7ea7\u8054\u590d\u5236\u3002<\/p>\n<\/li>\n<li>\n<p>\u5355\u673a\u5668\u591a\u5b9e\u4f8b\u590d\u5236\u98ce\u66b4\u3002\u673a\u5668\u5b95\u673a\u540e&#xff0c;\u5927\u91cf\u5168\u91cf\u590d\u5236\u3002\u89e3\u51b3\u65b9\u6cd5&#xff1a;\u4e3b\u8282\u70b9\u5206\u6563\u591a\u673a\u5668<br \/>\n<img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/08\/20260829141706-6a92e9e2890c8.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<\/li>\n<\/ul>\n<h4>1.6\u5e38\u89c1\u4e3b\u4ece\u590d\u5236\u6545\u969c<\/h4>\n<ul>\n<li>\n<p>\u4e3b\u4ece\u786c\u4ef6\u548c\u8f6f\u4ef6\u914d\u7f6e\u4e0d\u4e00\u81f4<\/p>\n<ul>\n<li>\n<p>\u4e3b\u4ece\u8282\u70b9\u7684maxmemory\u4e0d\u4e00\u81f4,\u4e3b\u8282\u70b9\u5185\u5b58\u5927\u4e8e\u4ece\u8282\u70b9\u5185\u5b58,\u4e3b\u4ece\u590d\u5236\u53ef\u80fd\u4e22\u5931\u6570\u636e<\/p>\n<\/li>\n<li>\n<p>rename-command \u547d\u4ee4\u4e0d\u4e00\u81f4,\u5982\u5728\u4e3b\u8282\u70b9\u542f\u7528flushdb,\u4ece\u8282\u70b9\u7981\u7528\u6b64\u547d\u4ee4,\u7ed3\u679c\u5728master\u8282\u70b9\u6267\u884cflushdb\u540e,\u5bfc\u81f4slave\u8282\u70b9\u4e0d\u540c\u6b65<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<li>\n<p>slave\u8282\u70b9\u914d\u7f6e\u7684master\u5bc6\u7801\u9519\u8bef<\/p>\n<\/li>\n<li>\n<p>redis\u7684\u7248\u672c\u4e0d\u4e00\u81f4&#xff0c;\u4e3b\u4ece\u590d\u5236\u7684\u6240\u6709\u8282\u70b9\u5e94\u8be5\u4f7f\u7528\u76f8\u540c\u7684\u7248\u672c\u3002<\/p>\n<\/li>\n<li>\n<p>\u5982\u679c\u5f00\u542f\u4e86\u5b89\u5168\u6a21\u5f0f&#xff0c;\u5e76\u4e14\u6ca1\u6709\u8bbe\u7f6ebind\u5730\u5740\u548c\u5bc6\u7801,\u4f1a\u5bfc\u81f4\u65e0\u6cd5\u8fdc\u7a0b\u8fde\u63a5<\/p>\n<\/li>\n<\/ul>\n<h3>2.redis\u54e8\u5175sentinel<\/h3>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/08\/20260829141706-6a92e9e2aa05f.jpg\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<ul>\n<li>\u5ba2\u6237\u4ecesentinel\u83b7\u53d6Redis\u4fe1\u606f\u3002<\/li>\n<li>Sentinel\u662f\u4e00\u4e2a\u5206\u5e03\u5f0f\u7cfb\u7edf,\u5373\u9700\u8981\u5728\u591a\u4e2a\u8282\u70b9\u4e0a\u5404\u81ea\u540c\u65f6\u8fd0\u884c\u4e00\u4e2asentinel\u8fdb\u7a0b&#xff0c;Sentienl \u8fdb\u7a0b\u901a\u8fc7\u6d41\u8a00\u534f\u8bae(gossip protocols)\u6765\u63a5\u6536\u5173\u4e8eMaster\u662f\u5426\u4e0b\u7ebf\u72b6\u6001&#xff0c;\u5e76\u4f7f\u7528\u6295\u7968\u534f\u8bae(Agreement Protocols)\u6765\u51b3\u5b9a\u662f\u5426\u6267\u884c\u81ea\u52a8\u6545\u969c\u8f6c\u79fb,\u5e76\u9009\u62e9\u5408\u9002\u7684Slave\u4f5c\u4e3a\u65b0\u7684Master<\/li>\n<\/ul>\n<h4>2.1sentinel\u4e2d\u7684\u4e09\u4e2a\u5b9a\u65f6\u4efb\u52a1<\/h4>\n<ul>\n<li>\n<p>\u6bcf10\u79d2\u6bcf\u4e2asentinel\u5bf9master\u548cslave\u6267\u884cinfo\u2014\u2014\u53d1\u73b0slave\u8282\u70b9&#xff0c;\u786e\u8ba4\u4e3b\u4ece\u5173\u7cfb<\/p>\n<\/li>\n<li>\n<p>\u6bcf2\u79d2\u6bcf\u4e2asentinel\u901a\u8fc7master\u8282\u70b9\u7684channel\u4ea4\u6362\u4fe1\u606f&#xff08;pub\/sub&#xff09;<\/p>\n<p>\u2014\u2014\u901a\u8fc7sentinel__:hello\u9891\u9053\u4ea4\u4e92&#xff1b;\u4ea4\u4e92\u5bf9\u8282\u70b9\u7684\u201c\u770b\u6cd5\u201d\u548c\u81ea\u8eab\u4fe1\u606f<\/p>\n<\/li>\n<li>\n<p>\u6bcf1\u79d2\u6bcf\u4e2asentinel\u5bf9\u5176\u4ed6sentinel\u548credis\u6267\u884cping<\/p>\n<\/li>\n<\/ul>\n<h4>2.2\u642d\u5efa\u54e8\u5175\u7cfb\u7edf<\/h4>\n<ul>\n<li>\u54e8\u5175\u7684\u524d\u63d0\u662f\u5b9e\u73b0\u4e86\u4e3b\u4ece\u590d\u5236&#xff0c;\u5305\u62ecmaster\u548cslave\u5728\u5185\u7684\u6240\u6709\u8282\u70b9\u7684 masterauth \u548crequirepassslave \u5bc6\u7801\u90fd\u5fc5\u987b\u76f8\u540c<\/li>\n<li>\u6240\u6709\u4e3b\u8282\u70b9\u7684 redis.conf \u4e2d\u5173\u5065\u914d\u7f6e<\/li>\n<\/ul>\n<p><span class=\"token comment\">#\u5728\u6240\u6709\u4e3b\u4ece\u8282\u70b9\u6267\u884c<\/span><br \/>\n<span class=\"token comment\">#\u57fa\u4e8e\u5305\u5b89\u88c5<\/span><br \/>\nyum <span class=\"token parameter variable\">-y<\/span> <span class=\"token function\">install<\/span> redis<br \/>\n<span class=\"token function\">apt<\/span> <span class=\"token parameter variable\">-y<\/span> <span class=\"token function\">install<\/span> redis redis-sentinel<\/p>\n<p><span class=\"token comment\">#\u6240\u6709\u8282\u70b9\u7684masterauth\u548crequirepass\u5fc5\u987b\u76f8\u540c<\/span><br \/>\n<span class=\"token punctuation\">[<\/span>root&#064;centos8 ~<span class=\"token punctuation\">]<\/span><span class=\"token comment\">#vim \/etc\/redis.conf<\/span><br \/>\n<span class=\"token builtin class-name\">bind<\/span> <span class=\"token number\">0.0<\/span>.0.0<br \/>\nmasterauth <span class=\"token string\">&#034;123456&#034;<\/span><br \/>\nrequirepass <span class=\"token string\">&#034;123456&#034;<\/span><\/p>\n<p><span class=\"token comment\">#\u5728\u6240\u6709\u4ece\u8282\u70b9\u6267\u884c<\/span><br \/>\n<span class=\"token punctuation\">[<\/span>root&#064;centos8 ~<span class=\"token punctuation\">]<\/span><span class=\"token comment\">#echo &#034;replicaof 10.0.0.8 6379&#034; &gt;&gt; \/etc\/redis.conf<\/span><\/p>\n<p><span class=\"token comment\">#\u5728\u6240\u6709\u4e3b\u4ece\u8282\u70b9\u6267\u884c<\/span><br \/>\n<span class=\"token punctuation\">[<\/span>root&#064;centos8 ~<span class=\"token punctuation\">]<\/span><span class=\"token comment\">#systemctl enable &#8211;now redis<\/span><\/p>\n<ul>\n<li>\u67e5\u770b\u4e3b\u8282\u70b9\u72b6\u6001<\/li>\n<\/ul>\n<p><span class=\"token comment\">#redis-cli -a 123456<\/span><br \/>\nWarning: Using a password with <span class=\"token string\">&#039;-a&#039;<\/span> or <span class=\"token string\">&#039;-u&#039;<\/span> option on the <span class=\"token builtin class-name\">command<\/span> line interface<br \/>\nmay not<br \/>\n<span class=\"token number\">127.0<\/span>.0.1:637<span class=\"token operator\"><span class=\"token file-descriptor important\">9<\/span>&gt;<\/span> INFO replication<\/p>\n<p><span class=\"token comment\"># Replication<\/span><br \/>\nrole:master<br \/>\nconnected_slaves:2<br \/>\nslave0:ip<span class=\"token operator\">&#061;<\/span><span class=\"token number\">10.0<\/span>.0.28,port<span class=\"token operator\">&#061;<\/span><span class=\"token number\">6379<\/span>,state<span class=\"token operator\">&#061;<\/span>online,offset<span class=\"token operator\">&#061;<\/span><span class=\"token number\">112<\/span>,lag<span class=\"token operator\">&#061;<\/span><span class=\"token number\">1<\/span><br \/>\nslave1:ip<span class=\"token operator\">&#061;<\/span><span class=\"token number\">10.0<\/span>.0.18,port<span class=\"token operator\">&#061;<\/span><span class=\"token number\">6379<\/span>,state<span class=\"token operator\">&#061;<\/span>online,offset<span class=\"token operator\">&#061;<\/span><span class=\"token number\">112<\/span>,lag<span class=\"token operator\">&#061;<\/span><span class=\"token number\">0<\/span><\/p>\n<ul>\n<li>\u914d\u7f6eslave1<\/li>\n<\/ul>\n<p><span class=\"token operator\">&gt;<\/span>REPLICAOF <span class=\"token number\">10.0<\/span>.0.8 <span class=\"token number\">6379<\/span><br \/>\nok<br \/>\n<span class=\"token operator\">&gt;<\/span>CONFIG SET masterauth <span class=\"token string\">&#034;123456&#034;<\/span><br \/>\nok<br \/>\n<span class=\"token operator\">&gt;<\/span>INFO replication<br \/>\nrole:slave<br \/>\nmaster_host:10.0.0.8<br \/>\nmaster_port:6379<br \/>\nmaster_link_status:up<br \/>\nmaster_last_io_seconds_ago:4<br \/>\nmaster_sync_in_progress:0<br \/>\nslave_repl_offset:140<br \/>\nslave_priority:100<br \/>\nslave_read_only:1<br \/>\nconnected_slaves:0<br \/>\nmaster_replid:8fdca730a2ae48fb9c8b7e739dcd2efcc76794f3<br \/>\nmaster_replid2:0000000000000000000000000000000000000000<\/p>\n<ul>\n<li>\u914d\u7f6eslave2<\/li>\n<\/ul>\n<p><span class=\"token operator\">&gt;<\/span>REPLICAOF <span class=\"token number\">10.0<\/span>.0.8 <span class=\"token number\">6379<\/span><br \/>\nOK<br \/>\n<span class=\"token operator\">&gt;<\/span>CONFIG SET masterauth <span class=\"token string\">&#034;123456&#034;<\/span><br \/>\nok<br \/>\n<span class=\"token operator\">&gt;<\/span>INFO replication<br \/>\nrole:slave<br \/>\nmaster_host:10.0.0.8<br \/>\nmaster_port:6379<br \/>\nmaster_link_status:up<br \/>\nmaster_last_io_seconds_ago:3<br \/>\nmaster_sync_in_progress:0<br \/>\nslave_repl_offset:182<br \/>\nslave_priority:100<br \/>\nslave_read_only:1<br \/>\nconnected_slaves:0<br \/>\nmaster_replid:8fdca730a2ae48fb9c8b7e739dcd2efcc76794f3<br \/>\nmaster_replid2:0000000000000000000000000000000000000000<br \/>\nmaster_repl_offset:182<br \/>\nsecond_repl_offset:-1<br \/>\nrepl_backlog_active:1<br \/>\nrepl_backlog_size:1048576<br \/>\nrepl_backlog_first_byte_offset:15<br \/>\nrepl_backlog_histlen:168<\/p>\n<ul>\n<li>\n<p>\u7f16\u8f91\u54e8\u5175\u914d\u7f6e<\/p>\n<ul>\n<li>Sentinel\u5b9e\u9645\u4e0a\u662f\u4e00\u4e2a\u7279\u6b8a\u7684redis\u670d\u52a1\u5668,\u6709\u4e9bredis\u6307\u4ee4\u652f\u6301,\u4f46\u5f88\u591a\u6307\u4ee4\u5e76\u4e0d\u652f\u6301.\u9ed8\u8ba4\u76d1\u542c\u572826379\/tcp\u7aef\u53e3.<\/li>\n<li>\u54e8\u5175\u670d\u52a1\u53ef\u4ee5\u548cRedis\u670d\u52a1\u5668\u5206\u5f00\u90e8\u7f72\u5728\u4e0d\u540c\u4e3b\u673a&#xff0c;\u4f46\u4e3a\u4e86\u8282\u7ea6\u6210\u672c\u4e00\u822c\u4f1a\u90e8\u7f72\u5728\u4e00\u8d77<\/li>\n<li>\u6240\u6709redis\u8282\u70b9\u4f7f\u7528\u76f8\u540c\u7684\u4ee5\u4e0b\u793a\u4f8b\u7684\u914d\u7f6e\u6587\u4ef6<\/li>\n<\/ul>\n<p><span class=\"token function\">cp<\/span> redis-7.0.5\/sentinel.conf \/apps\/redis\/etc\/sentinel.conf<br \/>\n<span class=\"token function\">chown<\/span> redis.redis \/apps\/redis\/etc\/sentinel.conf<\/p>\n<p><span class=\"token comment\">#\u7f16\u8bd1\u5b89\u88c5\u4fee\u6539\u914d\u7f6e\u6587\u4ef6<\/span><br \/>\nprotected-mode no               <span class=\"token comment\">#\u5305\u5b89\u88c5\u65f6\u9ed8\u8ba4\u4e3ayes,\u6b64\u5904\u8981\u4fee\u6539\u4e3ano<\/span><br \/>\nport <span class=\"token number\">26379<\/span><br \/>\ndaemonize no<br \/>\npidfile <span class=\"token string\">&#034;\/apps\/redis\/run\/redis-sentinel.pid&#034;<\/span><br \/>\nlogfile <span class=\"token string\">&#034;\/apps\/redis\/log\/redis-sentinel.log&#034;<\/span><br \/>\n<span class=\"token function\">dir<\/span> <span class=\"token string\">&#034;\/tmp&#034;<\/span><br \/>\nsentinel monitor mymaster <span class=\"token number\">10.0<\/span>.0.102 <span class=\"token number\">6379<\/span> <span class=\"token number\">2<\/span><br \/>\n<span class=\"token comment\">#mymaster\u662f\u96c6\u7fa4\u7684\u540d\u79f0&#xff0c;\u6b64\u884c\u6307\u5b9a\u5f53\u524dmymaster\u96c6\u7fa4\u4e2dmaster\u670d\u52a1\u5668\u7684\u5730\u5740\u548c\u7aef\u53e3<\/span><br \/>\n<span class=\"token comment\">#2\u4e3a\u6cd5\u5b9a\u4eba\u6570\u9650\u5236(quorum)&#xff0c;\u5373\u6709\u51e0\u4e2asentinel\u8ba4\u4e3amaster down\u4e86\u5c31\u8fdb\u884c\u6545\u969c\u8f6c\u79fb&#xff0c;\u4e00\u822c\u6b64\u503c\u662f\u6240\u6709sentinel\u8282\u70b9(\u4e00\u822c\u603b\u6570\u662f&gt;&#061;3\u7684 \u5947\u6570,\u5982:3,5,7\u7b49)\u7684\u4e00\u534a\u4ee5\u4e0a\u7684\u6574\u6570\u503c&#xff0c;\u6bd4\u5982&#xff0c;\u603b\u6570\u662f3&#xff0c;\u53733\/2&#061;1.5&#xff0c;\u53d6\u6574\u4e3a2,\u662fmaster\u7684ODOWN\u5ba2\u89c2\u4e0b\u7ebf\u7684\u4f9d\u636e<\/span><\/p>\n<p><span class=\"token comment\">#mymaster\u96c6\u7fa4\u4e2dmaster\u7684\u5bc6\u7801&#xff0c;\u6ce8\u610f\u6b64\u884c\u8981\u5728\u4e0a\u9762\u884c\u7684\u4e0b\u9762,\u6ce8\u610f&#xff1a;\u8981\u6c42\u8fd9\u7ec4redis\u4e3b\u4ece\u590d\u5236\u6240\u6709\u8282\u70b9\u7684\u5bc6<\/span><br \/>\n\u7801\u662f\u4e00\u6837\u7684<br \/>\nsentinel down-after-milliseconds mymaster <span class=\"token number\">3000<\/span><br \/>\n<span class=\"token comment\">#\u5224\u65admymaster\u96c6\u7fa4\u4e2d\u6240\u6709\u8282\u70b9\u7684\u4e3b\u89c2\u4e0b\u7ebf(SDOWN)\u7684\u65f6\u95f4&#xff0c;\u5355\u4f4d&#xff1a;\u6beb\u79d2&#xff0c;\u5efa\u8bae3000<\/span><br \/>\nacllog-max-len <span class=\"token number\">128<\/span><br \/>\nsentinel deny-scripts-reconfig <span class=\"token function\">yes<\/span><br \/>\nsentinel resolve-hostnames no<br \/>\nsentinel announce-hostnames no<\/p>\n<p><span class=\"token comment\">#\u5305\u5b89\u88c5\u4fee\u6539\u914d\u7f6e\u6587\u4ef6<\/span><br \/>\n<span class=\"token function\">vim<\/span> \/etc\/redis-sentinel.conf<br \/>\n<span class=\"token builtin class-name\">bind<\/span> <span class=\"token number\">0.0<\/span>.0.0<br \/>\nport <span class=\"token number\">26379<\/span><br \/>\ndaemonize <span class=\"token function\">yes<\/span><br \/>\npidfile <span class=\"token string\">&#034;redis-sentinel.pid&#034;<\/span><br \/>\nlogfile <span class=\"token string\">&#034;sentinel_26379.log&#034;<\/span><br \/>\n<span class=\"token function\">dir<\/span> <span class=\"token string\">&#034;\/tmp&#034;<\/span>  <span class=\"token comment\">#\u5de5\u4f5c\u76ee\u5f55<\/span><br \/>\nsentinel monitor mymaster <span class=\"token number\">10.0<\/span>.0.8 <span class=\"token number\">6379<\/span> <span class=\"token number\">2<\/span><br \/>\nsentinel auth-pass mymaster <span class=\"token number\">123456<\/span><br \/>\nsentinel down-after-milliseconds mymaster <span class=\"token number\">30000<\/span><br \/>\nsentinel parallel-syncs mymaster <span class=\"token number\">1<\/span><br \/>\n<span class=\"token comment\">#\u53d1\u751f\u6545\u969c\u8f6c\u79fb\u540e&#xff0c;\u53ef\u4ee5\u540c\u65f6\u5411\u65b0master\u540c\u6b65\u6570\u636e\u7684slave\u7684\u6570\u91cf&#xff0c;\u6570\u5b57\u8d8a\u5c0f\u603b\u540c\u6b65\u65f6\u95f4\u8d8a\u957f&#xff0c;\u4f46\u53ef\u4ee5\u51cf\u8f7b\u65b0master\u7684\u8d1f\u8f7d\u538b\u529b<\/span><br \/>\nsentinel failover-timeout mymaster <span class=\"token number\">180000<\/span><br \/>\n<span class=\"token comment\">#\u6240\u6709slaves\u6307\u5411\u65b0\u7684master\u6240\u9700\u7684\u8d85\u65f6\u65f6\u95f4&#xff0c;\u5355\u4f4d&#xff1a;\u6beb\u79d2<\/span><br \/>\nsentinel deny-scripts-reconfig <span class=\"token function\">yes<\/span> <span class=\"token comment\">#\u7981\u6b62\u4fee\u6539\u811a\u672c<\/span><br \/>\nlogfile \/var\/log\/redis\/sentinel.log<\/p>\n<\/li>\n<li>\n<p>\u4e09\u4e2a\u54e8\u5175\u670d\u52a1\u5668\u914d\u7f6e<\/p>\n<\/li>\n<\/ul>\n<p>sentinel monitor mymaster <span class=\"token number\">10.0<\/span>.0.8 <span class=\"token number\">6379<\/span> <span class=\"token number\">2<\/span>        <span class=\"token comment\">#\u4fee\u6539\u6b64\u884c<\/span><br \/>\nsentinel auth-pass mymaster <span class=\"token number\">123456<\/span>               <span class=\"token comment\">#\u589e\u52a0\u6b64\u884c<\/span><br \/>\nsentinel down-after-milliseconds mymaster <span class=\"token number\">3000<\/span>   <span class=\"token comment\">#\u4fee\u6539\u6b64\u884c<\/span><br \/>\n<span class=\"token comment\">#\u6ce8\u610f\u6b64\u884c\u81ea\u52a8\u751f\u6210\u5fc5\u987b\u552f\u4e00,\u4e00\u822c\u4e0d\u9700\u8981\u4fee\u6539&#xff0c;\u5982\u679c\u76f8\u540c\u5219\u4fee\u6539\u6b64\u503c\u9700\u91cd\u542fredis\u548csentinel\u670d\u52a1<\/span><br \/>\nsentinel myid 50547f34ed71fd48c197924969937e738a39975b<\/p>\n<ul>\n<li>\u542f\u52a8\u54e8\u5175\u670d\u52a1<\/li>\n<\/ul>\n<p><span class=\"token punctuation\">[<\/span>root&#064;redis-master ~<span class=\"token punctuation\">]<\/span>systemctl <span class=\"token builtin class-name\">enable<\/span> <span class=\"token parameter variable\">&#8211;now<\/span> redis-sentinel.service<br \/>\n<span class=\"token punctuation\">[<\/span>root&#064;redis-slave1 ~<span class=\"token punctuation\">]<\/span>systemctl <span class=\"token builtin class-name\">enable<\/span> <span class=\"token parameter variable\">&#8211;now<\/span> redis-sentinel.service<br \/>\n<span class=\"token punctuation\">[<\/span>root&#064;redis-slave2 ~<span class=\"token punctuation\">]<\/span>systemctl <span class=\"token builtin class-name\">enable<\/span> <span class=\"token parameter variable\">&#8211;now<\/span> redis-sentinel.service<\/p>\n<ul>\n<li>\n<p>\u67e5\u770b\u5f53\u524dsentinel\u72b6\u6001<\/p>\n<p>\u5728sentinel\u72b6\u6001\u4e2d\u5c24\u5176\u662f\u6700\u540e\u4e00\u884c&#xff0c;\u6d89\u53ca\u5230masterIP\u662f\u591a\u5c11&#xff0c;\u6709\u51e0\u4e2aslave&#xff0c;\u6709\u51e0\u4e2asentinels&#xff0c;\u5fc5\u987b\u662f\u7b26\u5408\u5168\u90e8\u670d\u52a1\u5668\u6570\u91cf<\/p>\n<\/li>\n<\/ul>\n<p><span class=\"token comment\">#redis-cli -p 26379<\/span><br \/>\n<span class=\"token number\">127.0<\/span>.0.1:2637<span class=\"token operator\"><span class=\"token file-descriptor important\">9<\/span>&gt;<\/span> INFO sentinel<br \/>\n<span class=\"token comment\"># Sentinel<\/span><br \/>\nsentinel_masters:1<br \/>\nsentinel_tilt:0<br \/>\nsentinel_running_scripts:0<br \/>\nsentinel_scripts_queue_length:0<br \/>\nsentinel_simulate_failure_flags:0<br \/>\nmaster0:name<span class=\"token operator\">&#061;<\/span>mymaster,status<span class=\"token operator\">&#061;<\/span>ok,address<span class=\"token operator\">&#061;<\/span><span class=\"token number\">10.0<\/span>.0.8:6379,slaves<span class=\"token operator\">&#061;<\/span><span class=\"token number\">2<\/span>,sentinels<span class=\"token operator\">&#061;<\/span><span class=\"token number\">3<\/span> <span class=\"token comment\">#\u4e24\u4e2aslave,\u4e09\u4e2asentinel\u670d\u52a1\u5668,\u5982\u679csentinels\u503c\u4e0d\u7b26\u5408,\u68c0\u67e5myid\u53ef\u80fd\u51b2\u7a81<\/span><\/p>\n<h4>2.3sentinel\u8fd0\u7ef4<\/h4>\n<p><span class=\"token function\">vim<\/span> \/etc\/redis.conf<br \/>\nreplica-priority <span class=\"token number\">10<\/span> <span class=\"token comment\">#\u6307\u5b9a\u4f18\u5148\u7ea7&#xff0c;\u503c\u8d8a\u5c0fsentinel\u4f1a\u4f18\u5148\u5c06\u4e4b\u9009\u4e3a\u65b0\u7684master&#xff0c;\u9ed8\u8ba4\u503c\u4e3a100&#xff0c;\u5982\u679c\u4e3a0&#xff0c;\u8868\u793a\u53ea\u5f53\u4ece\u8282\u70b9<\/span><\/p>\n<p><span class=\"token comment\">#\u6216\u8005\u52a8\u6001\u4fee\u6539<\/span><br \/>\n<span class=\"token number\">127.0<\/span>.0.1:637<span class=\"token operator\"><span class=\"token file-descriptor important\">9<\/span>&gt;<\/span> CONFIG GET replica-priority<br \/>\n<span class=\"token number\">1<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token string\">&#034;replica-priority&#034;<\/span><br \/>\n<span class=\"token number\">2<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token string\">&#034;100&#034;<\/span><br \/>\n<span class=\"token number\">127.0<\/span>.0.1:637<span class=\"token operator\"><span class=\"token file-descriptor important\">9<\/span>&gt;<\/span> CONFIG SET replica-priority <span class=\"token number\">99<\/span><br \/>\nOK<br \/>\n<span class=\"token number\">127.0<\/span>.0.1:637<span class=\"token operator\"><span class=\"token file-descriptor important\">9<\/span>&gt;<\/span> CONFIG GET replica-priority<br \/>\n<span class=\"token number\">1<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token string\">&#034;replica-priority&#034;<\/span><br \/>\n<span class=\"token number\">2<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token string\">&#034;99&#034;<\/span><\/p>\n<h4>2.4\u5e94\u7528\u7a0b\u5e8f\u8fde\u63a5sentinel<\/h4>\n<ul>\n<li>Java\u8fde\u63a5<\/li>\n<\/ul>\n<p>#jedis<span class=\"token operator\">\/<\/span>pom<span class=\"token punctuation\">.<\/span>xml \u914d\u7f6e\u8fde\u63a5redis<br \/>\n<span class=\"token generics\"><span class=\"token punctuation\">&lt;<\/span>properties<span class=\"token punctuation\">&gt;<\/span><\/span><br \/>\n <span class=\"token operator\">&lt;<\/span>redis<span class=\"token operator\">&#8211;<\/span><br \/>\nhosts<span class=\"token operator\">&gt;<\/span>localhost<span class=\"token operator\">:<\/span><span class=\"token number\">6379<\/span><span class=\"token punctuation\">,<\/span>localhost<span class=\"token operator\">:<\/span><span class=\"token number\">6380<\/span><span class=\"token punctuation\">,<\/span>localhost<span class=\"token operator\">:<\/span><span class=\"token number\">6381<\/span><span class=\"token punctuation\">,<\/span>localhost<span class=\"token operator\">:<\/span><span class=\"token number\">6382<\/span><span class=\"token punctuation\">,<\/span>localhost<span class=\"token operator\">:<\/span><span class=\"token number\">6383<\/span><br \/>\n<span class=\"token punctuation\">,<\/span>localhost<span class=\"token operator\">:<\/span><span class=\"token number\">6384<\/span><span class=\"token punctuation\">,<\/span>localhost<span class=\"token operator\">:<\/span><span class=\"token number\">6385<\/span><span class=\"token operator\">&lt;<\/span><span class=\"token operator\">\/<\/span>redis<span class=\"token operator\">&#8211;<\/span>hosts<span class=\"token operator\">&gt;<\/span><br \/>\n <span class=\"token operator\">&lt;<\/span>sentinel<span class=\"token operator\">&#8211;<\/span>hosts<span class=\"token operator\">&gt;<\/span>localhost<span class=\"token operator\">:<\/span><span class=\"token number\">26379<\/span><span class=\"token punctuation\">,<\/span>localhost<span class=\"token operator\">:<\/span><span class=\"token number\">26380<\/span><span class=\"token punctuation\">,<\/span>localhost<span class=\"token operator\">:<\/span><span class=\"token number\">26381<\/span><span class=\"token operator\">&lt;<\/span><span class=\"token operator\">\/<\/span>sentinel<span class=\"token operator\">&#8211;<\/span>hosts<span class=\"token operator\">&gt;<\/span><br \/>\n <span class=\"token operator\">&lt;<\/span>cluster<span class=\"token operator\">&#8211;<\/span>hosts<span class=\"token operator\">&gt;<\/span>localhost<span class=\"token operator\">:<\/span><span class=\"token number\">7379<\/span><span class=\"token punctuation\">,<\/span>localhost<span class=\"token operator\">:<\/span><span class=\"token number\">7380<\/span><span class=\"token punctuation\">,<\/span>localhost<span class=\"token operator\">:<\/span><span class=\"token number\">7381<\/span><span class=\"token punctuation\">,<\/span>localhost<span class=\"token operator\">:<\/span><span class=\"token number\">7382<\/span><span class=\"token punctuation\">,<\/span>localhost<span class=\"token operator\">:<\/span><span class=\"token number\">7383<\/span><br \/>\n<span class=\"token punctuation\">,<\/span>localhost<span class=\"token operator\">:<\/span><span class=\"token number\">7384<\/span><span class=\"token punctuation\">,<\/span>localhost<span class=\"token operator\">:<\/span><span class=\"token number\">7385<\/span><span class=\"token operator\">&lt;<\/span><span class=\"token operator\">\/<\/span>cluster<span class=\"token operator\">&#8211;<\/span>hosts<span class=\"token operator\">&gt;<\/span><br \/>\n   <span class=\"token generics\"><span class=\"token punctuation\">&lt;<\/span>github<span class=\"token punctuation\">.<\/span>global<span class=\"token punctuation\">.<\/span>server<span class=\"token punctuation\">&gt;<\/span><\/span>github<span class=\"token operator\">&lt;<\/span><span class=\"token operator\">\/<\/span>github<span class=\"token punctuation\">.<\/span>global<span class=\"token punctuation\">.<\/span>server<span class=\"token operator\">&gt;<\/span><br \/>\n <span class=\"token operator\">&lt;<\/span><span class=\"token operator\">\/<\/span>properties<span class=\"token operator\">&gt;<\/span><\/p>\n<ul>\n<li>python\u8fde\u63a5<\/li>\n<\/ul>\n<p><span class=\"token function\">apt<\/span> <span class=\"token parameter variable\">-y<\/span> <span class=\"token function\">install<\/span> python3-redis<br \/>\n<span class=\"token function\">cat<\/span> sentinel_test.py<br \/>\n<span class=\"token comment\">#!\/usr\/bin\/python3<\/span><br \/>\n<span class=\"token function\">import<\/span> redis<br \/>\nfrom redis.sentinel <span class=\"token function\">import<\/span> Sentinel<\/p>\n<p><span class=\"token comment\">#\u8fde\u63a5\u5230\u54e8\u5175\u670d\u52a1&#xff08;\u4e3b\u673a\u4e5f\u53ef\u4ee5\u4f7f\u7528\u57df\u540d&#xff09;<\/span><br \/>\nsentinel <span class=\"token operator\">&#061;<\/span> sentinel<span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">[<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">&#039;10.0.0.8&#039;<\/span>,26379<span class=\"token punctuation\">)<\/span>,<br \/>\n                     <span class=\"token punctuation\">(<\/span><span class=\"token string\">&#039;10.0.0.18&#039;<\/span>,26379<span class=\"token punctuation\">)<\/span>,<br \/>\n                     <span class=\"token punctuation\">(<\/span><span class=\"token string\">&#039;10.0.0.28&#039;<\/span>,26379<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">]<\/span>,<br \/>\n                     <span class=\"token assign-left variable\">socket_timeout<\/span><span class=\"token operator\">&#061;<\/span><span class=\"token number\">0.5<\/span><span class=\"token punctuation\">)<\/span><\/p>\n<p>redis_auth_pass <span class=\"token operator\">&#061;<\/span> <span class=\"token string\">&#039;123456&#039;<\/span><\/p>\n<p><span class=\"token comment\">#mymaster\u662f\u914d\u7f6e\u54e8\u5175\u6a21\u5f0f\u7684redis\u96c6\u7fa4\u540d\u79f0&#xff0c;\u6b64\u4e3a\u9ed8\u8ba4\u503c<\/span><br \/>\n<span class=\"token comment\">#\u83b7\u53d6\u4e3b\u670d\u52a1\u5668\u5730\u5740<\/span><br \/>\nmaster <span class=\"token operator\">&#061;<\/span> sentinel.discover_master<span class=\"token punctuation\">(<\/span><span class=\"token string\">&#039;mymaster&#039;<\/span><span class=\"token punctuation\">)<\/span><br \/>\nprint<span class=\"token punctuation\">(<\/span>master<span class=\"token punctuation\">)<\/span><\/p>\n<p><span class=\"token comment\">#\u83b7\u53d6\u4ece\u670d\u52a1\u5668\u5730\u5740<\/span><br \/>\nslave <span class=\"token operator\">&#061;<\/span> sentinel.discover_slaves<span class=\"token punctuation\">(<\/span><span class=\"token string\">&#039;mymaster&#039;<\/span><span class=\"token punctuation\">)<\/span><br \/>\nprint<span class=\"token punctuation\">(<\/span>master<span class=\"token punctuation\">)<\/span><\/p>\n<p><span class=\"token comment\">#\u83b7\u53d6\u4e3b\u670d\u52a1\u5668\u8fdb\u884c\u5199\u5165<\/span><br \/>\nmaster <span class=\"token operator\">&#061;<\/span> sentinel.master_for<span class=\"token punctuation\">(<\/span><span class=\"token string\">&#039;mymaster&#039;<\/span>, <span class=\"token assign-left variable\">socket_timeout<\/span><span class=\"token operator\">&#061;<\/span><span class=\"token number\">0.5<\/span>,<br \/>\n<span class=\"token assign-left variable\">password<\/span><span class=\"token operator\">&#061;<\/span>redis_auth_pass, <span class=\"token assign-left variable\">db<\/span><span class=\"token operator\">&#061;<\/span><span class=\"token number\">0<\/span><span class=\"token punctuation\">)<\/span><br \/>\nw_ret <span class=\"token operator\">&#061;<\/span> master.set<span class=\"token punctuation\">(<\/span><span class=\"token string\">&#039;name&#039;<\/span>, <span class=\"token string\">&#039;wang&#039;<\/span><span class=\"token punctuation\">)<\/span><br \/>\n<span class=\"token comment\">#\u8f93\u51fa&#xff1a;True<\/span><\/p>\n<p><span class=\"token comment\">#\u83b7\u53d6\u4ece\u670d\u52a1\u5668\u8fdb\u884c\u8bfb\u53d6&#xff08;\u9ed8\u8ba4\u662fround-roubin&#xff09;<\/span><br \/>\nslave <span class=\"token operator\">&#061;<\/span> sentinel.slave_for<span class=\"token punctuation\">(<\/span><span class=\"token string\">&#039;mymaster&#039;<\/span>, <span class=\"token assign-left variable\">socket_timeout<\/span><span class=\"token operator\">&#061;<\/span><span class=\"token number\">0.5<\/span>,<br \/>\n<span class=\"token assign-left variable\">password<\/span><span class=\"token operator\">&#061;<\/span>redis_auth_pass, <span class=\"token assign-left variable\">db<\/span><span class=\"token operator\">&#061;<\/span><span class=\"token number\">0<\/span><span class=\"token punctuation\">)<\/span><br \/>\nr_ret <span class=\"token operator\">&#061;<\/span> slave.get<span class=\"token punctuation\">(<\/span><span class=\"token string\">&#039;name&#039;<\/span><span class=\"token punctuation\">)<\/span><br \/>\nprint<span class=\"token punctuation\">(<\/span>r_ret<span class=\"token punctuation\">)<\/span><br \/>\n<span class=\"token comment\">#\u8f93\u51fa&#xff1a;wang<\/span><\/p>\n<p><span class=\"token comment\">#\u7ed9\u6743\u9650<\/span><br \/>\n<span class=\"token function\">chmod<\/span> &#043;x sentinel_test.py<\/p>\n<p><span class=\"token comment\">#\u8fd0\u884c\u811a\u672c<\/span><br \/>\n.\/sentinel_test.py<\/p>\n","protected":false},"excerpt":{"rendered":"<p>redis\u77e5\u8bc6\u70b9&#xff08;\u4e8c&#xff09;<br \/>\n1.\u4e3b\u4ece\u590d\u5236\u4f18\u5316<br \/>\nredis\u4e3b\u4ece\u540c\u6b65\u5206\u4e3a\u5168\u91cf\u540c\u6b65\u548c\u589e\u91cf\u540c\u6b65\u3002\u4e14\u4e3b\u4ece\u540c\u6b65\u662f\u975e\u963b\u585e\u7684&#xff0c;\u5373\u540c\u6b65\u8fc7\u7a0b\u4e0d\u4f1a\u5f71\u54cd\u4e3b\u670d\u52a1\u5668\u7684\u6b63\u5e38\u8bbf\u95ee\u3002\u4e3b\u8282\u70b9\u91cd\u542f\u4f1a\u5bfc\u81f4\u5168\u91cf\u540c\u6b65&#xff0c;\u4ece\u8282\u70b9\u91cd\u542f\u53ea\u4f1a\u5bfc\u81f4\u589e\u91cf\u540c\u6b65\u3002<br \/>\n1.1\u5168\u91cf\u590d\u5236\u8fc7\u7a0b\u4e3b\u4ece\u8282\u70b9\u5efa\u7acb\u8fde\u63a5&#xff0c;\u9a8c\u8bc1\u8eab\u4efd\u540e&#xff0c;\u4ece\u8282\u70b9\u60f3\u4e3b\u8282\u70b9\u53d1\u9001PSYNC\u547d\u4ee4\u3002\u4e3b\u8282\u70b9\u5411\u4ece\u8282\u70b9\u53d1\u9001FULLRESYNC\u547d\u4ee4,\u5305\u62ecmaster_replid(runID)\u548coffset\u4ece\u8282\u70b9\u4fdd\u5b58\u4e3b<\/p>\n","protected":false},"author":2,"featured_media":97631,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[10187,105,763,100,44],"topic":[],"class_list":["post-97635","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-server","tag-codingplan","tag-redis","tag-763","tag-100","tag-44"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Redis\u77e5\u8bc6\u70b9\uff08\u4e8c\uff09 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wsisp.com\/helps\/97635.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Redis\u77e5\u8bc6\u70b9\uff08\u4e8c\uff09 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"redis\u77e5\u8bc6\u70b9&#xff08;\u4e8c&#xff09; 1.\u4e3b\u4ece\u590d\u5236\u4f18\u5316 redis\u4e3b\u4ece\u540c\u6b65\u5206\u4e3a\u5168\u91cf\u540c\u6b65\u548c\u589e\u91cf\u540c\u6b65\u3002\u4e14\u4e3b\u4ece\u540c\u6b65\u662f\u975e\u963b\u585e\u7684&#xff0c;\u5373\u540c\u6b65\u8fc7\u7a0b\u4e0d\u4f1a\u5f71\u54cd\u4e3b\u670d\u52a1\u5668\u7684\u6b63\u5e38\u8bbf\u95ee\u3002\u4e3b\u8282\u70b9\u91cd\u542f\u4f1a\u5bfc\u81f4\u5168\u91cf\u540c\u6b65&#xff0c;\u4ece\u8282\u70b9\u91cd\u542f\u53ea\u4f1a\u5bfc\u81f4\u589e\u91cf\u540c\u6b65\u3002 1.1\u5168\u91cf\u590d\u5236\u8fc7\u7a0b\u4e3b\u4ece\u8282\u70b9\u5efa\u7acb\u8fde\u63a5&#xff0c;\u9a8c\u8bc1\u8eab\u4efd\u540e&#xff0c;\u4ece\u8282\u70b9\u60f3\u4e3b\u8282\u70b9\u53d1\u9001PSYNC\u547d\u4ee4\u3002\u4e3b\u8282\u70b9\u5411\u4ece\u8282\u70b9\u53d1\u9001FULLRESYNC\u547d\u4ee4,\u5305\u62ecmaster_replid(runID)\u548coffset\u4ece\u8282\u70b9\u4fdd\u5b58\u4e3b\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/97635.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2026-08-29T14:17:08+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/08\/20260829141658-6a92e9dac406e.png\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/97635.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/97635.html\",\"name\":\"Redis\u77e5\u8bc6\u70b9\uff08\u4e8c\uff09 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2026-08-29T14:17:08+00:00\",\"dateModified\":\"2026-08-29T14:17:08+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/97635.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/97635.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/97635.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Redis\u77e5\u8bc6\u70b9\uff08\u4e8c\uff09\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Redis\u77e5\u8bc6\u70b9\uff08\u4e8c\uff09 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wsisp.com\/helps\/97635.html","og_locale":"zh_CN","og_type":"article","og_title":"Redis\u77e5\u8bc6\u70b9\uff08\u4e8c\uff09 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"redis\u77e5\u8bc6\u70b9&#xff08;\u4e8c&#xff09; 1.\u4e3b\u4ece\u590d\u5236\u4f18\u5316 redis\u4e3b\u4ece\u540c\u6b65\u5206\u4e3a\u5168\u91cf\u540c\u6b65\u548c\u589e\u91cf\u540c\u6b65\u3002\u4e14\u4e3b\u4ece\u540c\u6b65\u662f\u975e\u963b\u585e\u7684&#xff0c;\u5373\u540c\u6b65\u8fc7\u7a0b\u4e0d\u4f1a\u5f71\u54cd\u4e3b\u670d\u52a1\u5668\u7684\u6b63\u5e38\u8bbf\u95ee\u3002\u4e3b\u8282\u70b9\u91cd\u542f\u4f1a\u5bfc\u81f4\u5168\u91cf\u540c\u6b65&#xff0c;\u4ece\u8282\u70b9\u91cd\u542f\u53ea\u4f1a\u5bfc\u81f4\u589e\u91cf\u540c\u6b65\u3002 1.1\u5168\u91cf\u590d\u5236\u8fc7\u7a0b\u4e3b\u4ece\u8282\u70b9\u5efa\u7acb\u8fde\u63a5&#xff0c;\u9a8c\u8bc1\u8eab\u4efd\u540e&#xff0c;\u4ece\u8282\u70b9\u60f3\u4e3b\u8282\u70b9\u53d1\u9001PSYNC\u547d\u4ee4\u3002\u4e3b\u8282\u70b9\u5411\u4ece\u8282\u70b9\u53d1\u9001FULLRESYNC\u547d\u4ee4,\u5305\u62ecmaster_replid(runID)\u548coffset\u4ece\u8282\u70b9\u4fdd\u5b58\u4e3b","og_url":"https:\/\/www.wsisp.com\/helps\/97635.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2026-08-29T14:17:08+00:00","og_image":[{"url":"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/08\/20260829141658-6a92e9dac406e.png"}],"author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"4 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/97635.html","url":"https:\/\/www.wsisp.com\/helps\/97635.html","name":"Redis\u77e5\u8bc6\u70b9\uff08\u4e8c\uff09 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2026-08-29T14:17:08+00:00","dateModified":"2026-08-29T14:17:08+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/97635.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/97635.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/97635.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"Redis\u77e5\u8bc6\u70b9\uff08\u4e8c\uff09"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/97635","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=97635"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/97635\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media\/97631"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=97635"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=97635"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=97635"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=97635"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}