{"id":149546,"date":"2020-08-28T09:18:49","date_gmt":"2020-08-28T01:18:49","guid":{"rendered":"http:\/\/4563.org\/?p=149546"},"modified":"2020-08-28T09:18:49","modified_gmt":"2020-08-28T01:18:49","slug":"%e7%94%b1-docker-redis-%e7%bb%84%e6%88%90%e7%9a%84-redis-cluster-%e5%9c%a8-macos-%e4%b8%8a%e6%97%a0%e6%b3%95%e6%88%90%e5%8a%9f%e5%88%9b%e5%bb%ba","status":"publish","type":"post","link":"http:\/\/4563.org\/?p=149546","title":{"rendered":"\u7531 Docker Redis \u7ec4\u6210\u7684 Redis cluster \u5728 macOS \u4e0a\u65e0\u6cd5\u6210\u529f\u521b\u5efa"},"content":{"rendered":"<div>\n<div>\n<div>\n<h1>                  \u7531 Docker Redis \u7ec4\u6210\u7684 Redis cluster \u5728 macOS \u4e0a\u65e0\u6cd5\u6210\u529f\u521b\u5efa               <\/h1>\n<p> <\/p>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : JasonLaw <\/span>  <span><i><\/i> 7<\/span> <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<div isfirst=\"1\"> <\/p>\n<p>\u542f\u52a8\u591a\u4e2a\u5b9e\u4f8b<\/p>\n<pre><code>for i in {7000..7002} do    docker run -d --name Redis-cache-cluster-node-${i}        --network=host        -v Redis-cache-cluster-node-${i}_data:\/data        redis:6.0.6        redis-server --port ${i} --cluster-enabled yes --cluster-config-file nodes.conf -- cluster-node-timeout 5000 --appendonly yes done <\/code><\/pre>\n<p>\u521b\u5efa cluster<\/p>\n<pre><code>docker run -it --rm --network=host redis  redis-cli --cluster create 127.0.0.1:7000 127.0.0.1:7001 127.0.0.1:7002 <\/code><\/pre>\n<p>\u5728 Ubuntu \u4e0a\u9762\uff0c\u662f\u53ef\u4ee5\u6210\u529f\u521b\u5efa cluster \u7684\uff0c\u4f46\u662f\u5728 macOS \u4e0a\u9762\u5374\u4e0d\u884c\uff0c\u4e00\u76f4\u5361\u5728\u201cWaiting for the cluster to join\u201d\uff0c\u5230\u5e95\u662f\u4e3a\u4ec0\u4e48\u5462\uff1f<\/p>\n<p>\u5173\u4e8e\u7f51\u7edc\u95ee\u9898\uff0c\u6211\u5df2\u7ecf\u67e5\u9605\u4e86ip &#8211; Docker container doesn&#8217;t expose ports when &#8211;net=host is mentioned in the docker run command &#8211; Stack Overflow\u3001Block\/disallow &#8211;net=host (host networking) on Mac OS \u00b7 Issue #2716 \u00b7 docker\/for-mac\uff0c\u5e76\u4e14\u5c1d\u8bd5\u8fc7\u4f7f\u7528<code>-p ${i}:${i} -p $((${i} + 10000)):$((${i} + 10000))<\/code>\u66ff\u6362<code>--network=host<\/code>\uff0c\u7ed3\u679c\u8fd8\u662f\u4e0d\u884c\u3002<\/p>\n<\/p><\/div>\n<div> <b>\u5927\u4f6c\u6709\u8a71\u8aaa<\/b> (<span>6<\/span>)        <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<ul>\n<li data-pid=\"3139196\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : windghoul <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u521b\u5efa\u4e00\u4e2a\u865a\u62df\u7f51\u7edc\uff0c\u7136\u540e\u8fdb\u5230 docker \u91cc\u9762\u6267\u884c cli \u547d\u4ee4                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3139197\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : windghoul <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u53c2\u8003 https:\/\/jasonkayzk.github.io\/2020\/01\/17\/%E4%BD%BF%E7%94%A8Docker%E9%83%A8%E7%BD%B2Redis%E9%9B%86%E7%BE%A4-%E4%B8%89%E4%B8%BB%E4%B8%89%E4%BB%8E\/<\/p>\n<p>https:\/\/www.g5niusx.com\/2019\/04\/redis-4.html                                                            <\/p><\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3139198\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : whileFalse <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u5148\u770b\u770b\u4f60\u7684 Docker for Mac \u6709\u6ca1\u6709\u5f00\u4ee3\u7406\u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3139199\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : JasonLaw <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @windghoul #2 <br \/>@whileFalse #3 <\/p>\n<p>\u6211\u60f3\u786e\u8ba4\u4e00\u4e0b\u6211\u7406\u89e3\u7684\u662f\u4e0d\u662f\u6b63\u786e\u7684\u3002&#8211;network=host \u4e0d\u884c\u662f\u56e0\u4e3a macOS \u4e0d\u652f\u6301\uff0c\u5355\u7eaf\u4f7f\u7528-p ${i}:${i} -p $((${i} + 10000)):$((${i} + 10000))\u66ff\u6362&#8211;network=host \u4e0d\u884c\u662f\u56e0\u4e3a redis-cli &#8211;cluster create 127.0.0.1:7000 127.0.0.1:7001 127.0.0.1:7002 \u4e2d\u7684 127.0.0.1 \uff08\u56e0\u4e3a\u5b83\u4eec\u8fd9\u4e09\u4e2a\u5bb9\u5668\u90fd\u6709\u81ea\u5df1\u7684\u201c\u52a8\u6001\u201dIP \u5730\u5740\uff09\u3002\u5bf9\u5417\uff1f                                                            <\/p><\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3139200\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : windghoul <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @JasonLaw #4 \u6211\u4e4b\u524d\u521b\u5efa\u7684\uff0c\u5728 linux \u4e0a\uff0c\u4e5f\u4e0d\u80fd\u7528\u5bbf\u4e3b\u673a\u7684 ip \u8fdb\u884c\u96c6\u7fa4\u6dfb\u52a0\uff0c\u53ea\u80fd\u7528\u5b83\u7684\u865a\u62df ip \u8fdb\u884c\u6dfb\u52a0\uff0c\u5177\u4f53\u7684\u539f\u56e0\u6211\u8fd8\u6ca1\u6765\u5f97\u53ca\u7814\u7a76                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3139201\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : qfdk <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u4f60\u8981\u7528 host \u4ee3\u66ff\u4f60\u7684 127.0.0.1 \u4f60\u8fd9\u4e2a\u5c5e\u4e8e\u5bb9\u5668\u5185\u90e8\u7684\u901a\u4fe1 link \u4f30\u8ba1\u4e5f\u53ef\u4ee5                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li>\n","protected":false},"excerpt":{"rendered":"<p>\u7531 Docker Redis \u7ec4\u6210&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[],"tags":[],"_links":{"self":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/149546"}],"collection":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=149546"}],"version-history":[{"count":0,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/149546\/revisions"}],"wp:attachment":[{"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=149546"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=149546"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=149546"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}