{"id":404,"date":"2018-04-28T11:01:07","date_gmt":"2018-04-28T03:01:07","guid":{"rendered":"https:\/\/www.zhuyanbin.com\/?p=404"},"modified":"2018-04-28T11:11:10","modified_gmt":"2018-04-28T03:11:10","slug":"redis%e9%9b%86%e7%be%a4%e5%bf%ab%e9%80%9f%e6%90%ad%e5%bb%ba%e8%84%9a%e6%9c%ac","status":"publish","type":"post","link":"https:\/\/www.yanbin888.com\/?p=404","title":{"rendered":"Redis\u96c6\u7fa4\u5feb\u901f\u642d\u5efa\u811a\u672c"},"content":{"rendered":"<p>\u642d\u5efa\u4e00\u5957redis\u96c6\u7fa4\u7528\u4e8e\u6d4b\u8bd5\uff0c\u642d\u5efa\u8fc7\u7a0b\u5982\u4e0b<\/p>\n<p>\u5b89\u88c5redis\u7684ruby\u63d2\u4ef6\uff0c\u7528\u4e8e\u6784\u5efaredis\u96c6\u7fa4\u3002<\/p>\n<p><code>gem install redis<\/code><\/p>\n<div>\u4e0b\u8f7d\u6700\u65b0\u7684redis\u5b89\u88c5\u5305\uff1a<\/div>\n<div><code>wget http:\/\/download.redis.io\/releases\/redis-4.0.9.tar.gz<\/code><\/div>\n<div><\/div>\n<div>\u7f16\u8bd1\u5b89\u88c5(\u672c\u6b21\u5b89\u88c5\u76ee\u5f55\u5728\/opt\/redis\u76ee\u5f55\u4e0b)\uff1a<\/div>\n<div><code>tar xzf redis-4.0.9.tar.gz<br \/>\ncd redis-4.0.9<br \/>\nmake<br \/>\nmake PREFIX=\/opt\/redis install<br \/>\n<\/code><\/div>\n<div><\/div>\n<div>\u5c06\u6784\u5efa\u96c6\u7fa4\u7684\u811a\u672c\u62f7\u8d1d\u81f3\u5b89\u88c5\u76ee\u5f55<\/div>\n<div><code>cp src\/redis-trib.rb \/opt\/redis\/bin\/<\/code><\/div>\n<div><\/div>\n<div><\/div>\n<div>\u5236\u4f5c\u96c6\u7fa4\u914d\u7f6e\u6587\u4ef6(\u81f3\u5c116\u4e2a\u8282\u70b9)\uff1a<\/div>\n<div><code>mkdir -p \/opt\/redis\/cluster\/{10001,10002,10003,10004,10005,10006}<br \/>\necho \"port {port}\" &gt; .\/redis-cluster.conf<br \/>\necho \"dir \/opt\/redis\/cluster\/{port}\" &gt;&gt; .\/redis-cluster.conf<br \/>\necho \"cluster-enabled yes\" &gt;&gt; .\/redis-cluster.conf<br \/>\necho \"daemonize yes\" &gt;&gt; .\/redis-cluster.conf<br \/>\necho \"bind 127.0.0.1\" &gt;&gt; .\/redis-cluster.conf<br \/>\nsed 's\/{port}\/10001\/' .\/redis-cluster.conf &gt; \/opt\/redis\/redis-cluster-10001.conf<br \/>\nsed 's\/{port}\/10002\/' .\/redis-cluster.conf &gt; \/opt\/redis\/redis-cluster-10002.conf<br \/>\nsed 's\/{port}\/10003\/' .\/redis-cluster.conf &gt; \/opt\/redis\/redis-cluster-10003.conf<br \/>\nsed 's\/{port}\/10004\/' .\/redis-cluster.conf &gt; \/opt\/redis\/redis-cluster-10004.conf<br \/>\nsed 's\/{port}\/10005\/' .\/redis-cluster.conf &gt; \/opt\/redis\/redis-cluster-10005.conf<br \/>\nsed 's\/{port}\/10006\/' .\/redis-cluster.conf &gt; \/opt\/redis\/redis-cluster-10006.conf<br \/>\n<\/code><\/div>\n<div><\/div>\n<div>\u542f\u52a8\u8282\u70b9\uff1a<\/div>\n<div><code>\/opt\/redis\/bin\/redis-server \/opt\/redis\/redis-cluster-10001.conf<br \/>\n\/opt\/redis\/bin\/redis-server \/opt\/redis\/redis-cluster-10002.conf<br \/>\n\/opt\/redis\/bin\/redis-server \/opt\/redis\/redis-cluster-10003.conf<br \/>\n\/opt\/redis\/bin\/redis-server \/opt\/redis\/redis-cluster-10004.conf<br \/>\n\/opt\/redis\/bin\/redis-server \/opt\/redis\/redis-cluster-10005.conf<br \/>\n\/opt\/redis\/bin\/redis-server \/opt\/redis\/redis-cluster-10006.conf<br \/>\n<\/code><\/div>\n<div><\/div>\n<div>\u5173\u8054\u6210\u96c6\u7fa4\u6a21\u5f0f\uff1a<\/div>\n<div><code>echo \"yes\" | \/opt\/redis\/bin\/redis-trib.rb create --replicas 1 127.0.0.1:10001 127.0.0.1:10002 127.0.0.1:10003 127.0.0.1:10004 127.0.0.1:10005 127.0.0.1:10006<\/code><\/div>\n<div><\/div>\n<div><\/div>\n<div>\u96c6\u7fa4\u91cd\u542f\u811a\u672c:<\/div>\n<div><code>PIDS=`ps -ef | grep '\/opt\/redis\/bin\/redis-server' | grep '127.0.0.1:1000' | awk '{print $2}'`<br \/>\nfor i in $PIDS; do<br \/>\necho \"kill pid $i\"<br \/>\nkill $i<br \/>\ndone<br \/>\nsleep 3<br \/>\nrm -rf \/opt\/redis\/cluster<br \/>\nmkdir -p \/opt\/redis\/cluster\/{10001,10002,10003,10004,10005,10006}<br \/>\n\/opt\/redis\/bin\/redis-server \/opt\/redis\/redis-cluster-10001.conf<br \/>\n\/opt\/redis\/bin\/redis-server \/opt\/redis\/redis-cluster-10002.conf<br \/>\n\/opt\/redis\/bin\/redis-server \/opt\/redis\/redis-cluster-10003.conf<br \/>\n\/opt\/redis\/bin\/redis-server \/opt\/redis\/redis-cluster-10004.conf<br \/>\n\/opt\/redis\/bin\/redis-server \/opt\/redis\/redis-cluster-10005.conf<br \/>\n\/opt\/redis\/bin\/redis-server \/opt\/redis\/redis-cluster-10006.conf<br \/>\necho \"yes\" | \/opt\/redis\/bin\/redis-trib.rb create --replicas 1 127.0.0.1:10001 127.0.0.1:10002 127.0.0.1:10003 127.0.0.1:10004 127.0.0.1:10005 127.0.0.1:10006<br \/>\n<\/code><\/div>\n<div><\/div>\n<div>PS: redis\u96c6\u7fa4\u5e76\u6ca1\u6709\u8003\u8651\u6240\u6709\u8282\u70b9\u540c\u65f6\u5b95\u6389\u7684\u60c5\u51b5\uff0c\u56e0\u6b64\u6ca1\u6709\u91cd\u542f\u6240\u6709\u96c6\u7fa4\u7684\u547d\u4ee4\uff0c\u6b64\u91cd\u542f\u811a\u672c\u5c06\u6240\u6709\u6570\u636e\u60c5\u51b5\uff0c\u91cd\u5efa\u96c6\u7fa4\uff0c\u8bf7\u52ff\u76f4\u63a5\u4f7f\u7528\u751f\u4ea7\u73af\u5883\uff0c\u4ec5\u9650\u6d4b\u8bd5\u5f00\u53d1\u73af\u5883\u3002<\/div>\n<p><audio style=\"display: none;\" controls=\"controls\"><\/audio><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u642d\u5efa\u4e00\u5957redis\u96c6\u7fa4\u7528\u4e8e\u6d4b\u8bd5\uff0c\u642d\u5efa\u8fc7\u7a0b\u5982\u4e0b \u5b89\u88c5redis\u7684ruby\u63d2\u4ef6\uff0c\u7528\u4e8e\u6784\u5efaredis\u96c6\u7fa4\u3002 gem  <span class=\"ellipsis\">&hellip;<\/span> <span class=\"more-link-wrap\"><a href=\"https:\/\/www.yanbin888.com\/?p=404\" class=\"more-link\"><span>Read More &rarr;<\/span><\/a><\/span><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[42],"class_list":["post-404","post","type-post","status-publish","format-standard","hentry","category-linux","tag-redis-cluster"],"_links":{"self":[{"href":"https:\/\/www.yanbin888.com\/index.php?rest_route=\/wp\/v2\/posts\/404","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.yanbin888.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.yanbin888.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.yanbin888.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.yanbin888.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=404"}],"version-history":[{"count":4,"href":"https:\/\/www.yanbin888.com\/index.php?rest_route=\/wp\/v2\/posts\/404\/revisions"}],"predecessor-version":[{"id":410,"href":"https:\/\/www.yanbin888.com\/index.php?rest_route=\/wp\/v2\/posts\/404\/revisions\/410"}],"wp:attachment":[{"href":"https:\/\/www.yanbin888.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=404"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.yanbin888.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=404"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.yanbin888.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=404"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}