{"id":5831,"date":"2024-11-14T11:28:50","date_gmt":"2024-11-14T03:28:50","guid":{"rendered":"https:\/\/fwq.ai\/blog\/5831\/"},"modified":"2024-11-14T11:28:50","modified_gmt":"2024-11-14T03:28:50","slug":"redis%e6%80%8e%e4%b9%88%e8%bf%9c%e7%a8%8b%e7%99%bb%e5%bd%95","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/5831\/","title":{"rendered":"redis\u600e\u4e48\u8fdc\u7a0b\u767b\u5f55"},"content":{"rendered":"<blockquote><p>\n  \u8fdc\u7a0b\u767b\u5f55 redis \u7684\u65b9\u6cd5\u6709\u4e24\u79cd\uff1a\u901a\u8fc7 ssh \u7aef\u53e3\u8f6c\u53d1\uff1a\u5728\u672c\u5730\u521b\u5efa ssh \u901a\u9053\u540e\uff0c\u8fde\u63a5\u672c\u5730\u7aef\u53e3\u5373\u53ef\u767b\u5f55\u3002\u4f7f\u7528 redis sentinel\uff1a\u5b89\u88c5 redis sentinel\uff0c\u914d\u7f6e\u914d\u7f6e\u6587\u4ef6\uff0c\u542f\u52a8 sentinel\uff0c\u8bbf\u95ee\u7ba1\u7406\u754c\u9762\u540e\u53ef\u8fde\u63a5\u5230 redis \u4e3b\u8282\u70b9\u3002\n<\/p><\/blockquote>\n<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/202406\/03\/2024060320215878507.jpg\" class=\"aligncenter\" title=\"redis\u600e\u4e48\u8fdc\u7a0b\u767b\u5f55\u63d2\u56fe\" alt=\"redis\u600e\u4e48\u8fdc\u7a0b\u767b\u5f55\u63d2\u56fe\" \/><\/p>\n<p><strong>Redis \u8fdc\u7a0b\u767b\u5f55<\/strong><\/p>\n<p><strong>\u5982\u4f55\u8fdc\u7a0b\u767b\u5f55 Redis\uff1f<\/strong><\/p>\n<p>\u8fdc\u7a0b\u767b\u5f55 Redis \u7684\u65b9\u6cd5\u4e3b\u8981\u6709\u4e24\u79cd\uff1a<\/p>\n<ol>\n<li>\u901a\u8fc7 SSH \u7aef\u53e3\u8f6c\u53d1<\/li>\n<li>\u4f7f\u7528 Redis Sentinel<\/li>\n<\/ol>\n<p><strong>\u65b9\u6cd5 1\uff1aSSH \u7aef\u53e3\u8f6c\u53d1<\/strong><\/p>\n<p><strong>\u6b65\u9aa4\uff1a<\/strong><\/p>\n<ol>\n<li>\n<p>\u5728\u672c\u5730\u8ba1\u7b97\u673a\u4e0a\u521b\u5efa\u4e00\u4e2a SSH \u901a\u9053\uff1a<\/p>\n<pre>ssh -L [local_port]:127.0.0.1:[remote_port] [username]@[remote_host]<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u4f8b\u5982\uff1assh -L 6379:127.0.0.1:6379 user@remote-server<\/p>\n<\/li>\n<li>\n<p>\u8fde\u63a5\u672c\u5730\u7aef\u53e3\uff1a<br \/>\u4f7f\u7528 Redis \u5ba2\u6237\u7aef\u8fde\u63a5\u672c\u5730\u7aef\u53e3\uff086379 \u5728\u6b64\u793a\u4f8b\u4e2d\uff09\uff1a<\/p>\n<pre>redis-cli -h localhost -p 6379<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/li>\n<\/ol>\n<p><strong>\u65b9\u6cd5 2\uff1aRedis Sentinel<\/strong><\/p>\n<p>Redis Sentinel \u662f\u4e00\u6b3e\u76d1\u63a7\u548c\u7ba1\u7406 Redis \u5b9e\u4f8b\u7684\u5de5\u5177\u3002\u5b83\u53ef\u4ee5\u63d0\u4f9b Redis \u7684\u6545\u969c\u8f6c\u79fb\u548c\u81ea\u52a8\u6545\u969c\u6062\u590d\u529f\u80fd\u3002<\/p>\n<p><strong>\u6b65\u9aa4\uff1a<\/strong><\/p>\n<ol>\n<li>\n<p>\u5b89\u88c5 Redis Sentinel\uff1a<\/p>\n<pre>yum install redis-sentinel<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/li>\n<li>\u914d\u7f6e Sentinel\uff1a<br \/>\u521b\u5efa\u914d\u7f6e\u6587\u4ef6 \/etc\/\/sentinel.conf \u5e76\u6307\u5b9a Redis \u4e3b\u8282\u70b9\u548c\u4ece\u8282\u70b9\u7684\u4fe1\u606f\u3002<\/li>\n<li>\n<p>\u542f\u52a8 Sentinel\uff1a<\/p>\n<pre>redis-sentinel \/etc\/redis\/sentinel.conf<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/li>\n<li>\n<p>\u8fde\u63a5\u5230 Sentinel \u7ba1\u7406\u754c\u9762\uff1a<br \/>\u4f7f\u7528\u6d4f\u89c8\u5668\u8bbf\u95ee Sentinel \u7ba1\u7406\u754c\u9762\uff1a<\/p>\n<pre>http:\/\/[sentinel_host]:26379<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/li>\n<li>\u5728\u7ba1\u7406\u754c\u9762\u4e2d\uff0c\u9009\u62e9\u8981\u8fde\u63a5\u7684 Redis \u4e3b\u8282\u70b9\u3002<\/li>\n<\/ol>\n<p><strong>\u6e29\u99a8\u63d0\u793a\uff1a<\/strong><\/p>\n<ul>\n<li>\u8fdc\u7a0b\u7aef\u53e3\uff08remote_port\uff09\u5e94\u8be5\u662f Redis \u670d\u52a1\u6b63\u5728\u4fa6\u542c\u7684\u7aef\u53e3\u3002<\/li>\n<li>\u8bf7\u786e\u4fdd\u5728\u8fdc\u7a0b\u670d\u52a1\u5668\u4e0a\u542f\u7528\u4e86 Redis \u670d\u52a1\uff0c\u5e76\u4e14\u6ca1\u6709\u9632\u706b\u5899\u963b\u6b62\u8fde\u63a5\u3002<\/li>\n<li>Sentinel \u4ec5\u9002\u7528\u4e8e Redis 2.8.12 \u6216\u66f4\u9ad8\u7248\u672c\u3002<\/li>\n<\/ul>\n<p>\u4ee5\u4e0a\u5c31\u662f\u600e\u4e48\u8fdc\u7a0b\u767b\u5f55\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u7f51\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u8fdc\u7a0b\u767b\u5f55 redis \u7684\u65b9\u6cd5\u6709\u4e24\u79cd\uff1a\u901a\u8fc7 ssh \u7aef\u53e3\u8f6c\u53d1\uff1a\u5728\u672c\u5730\u521b\u5efa ssh \u901a\u9053\u540e\uff0c\u8fde\u63a5\u672c\u5730\u7aef\u53e3\u5373\u53ef\u767b\u5f55\u3002\u4f7f\u7528 redis sentinel\uff1a\u5b89\u88c5 redis sentinel\uff0c\u914d\u7f6e\u914d\u7f6e\u6587\u4ef6\uff0c\u542f\u52a8 sentinel\uff0c\u8bbf\u95ee\u7ba1\u7406\u754c\u9762\u540e\u53ef\u8fde\u63a5\u5230 redis \u4e3b\u8282\u70b9\u3002 Redis \u8fdc\u7a0b\u767b\u5f55 \u5982\u4f55\u8fdc\u7a0b\u767b\u5f55 Redis\uff1f \u8fdc\u7a0b\u767b\u5f55 Redis \u7684\u65b9\u6cd5\u4e3b\u8981\u6709\u4e24\u79cd\uff1a \u901a\u8fc7 SSH \u7aef\u53e3\u8f6c\u53d1 \u4f7f\u7528 Redis Sentinel \u65b9\u6cd5 1\uff1aSSH \u7aef\u53e3\u8f6c\u53d1 \u6b65\u9aa4\uff1a \u5728\u672c\u5730\u8ba1\u7b97\u673a\u4e0a\u521b\u5efa\u4e00\u4e2a SSH \u901a\u9053\uff1a ssh -L [local_port]:127.0.0.1:[remote_port] [username]@[remote_host] \u767b\u5f55\u540e\u590d\u5236 \u4f8b\u5982\uff1assh -L 6379:127.0.0.1:6379 user@remote-server \u8fde\u63a5\u672c\u5730\u7aef\u53e3\uff1a\u4f7f\u7528 Redis \u5ba2\u6237\u7aef\u8fde\u63a5\u672c\u5730\u7aef\u53e3\uff086379 \u5728\u6b64\u793a\u4f8b\u4e2d\uff09\uff1a redis-cli -h localhost -p 6379 \u767b\u5f55\u540e\u590d\u5236 \u65b9\u6cd5 2\uff1aRedis [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"class_list":["post-5831","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/5831","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=5831"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/5831\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=5831"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=5831"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=5831"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}