{"id":174941,"date":"2024-11-08T01:02:49","date_gmt":"2024-11-07T17:02:49","guid":{"rendered":"https:\/\/server.hk\/cnblog\/174941\/"},"modified":"2024-11-08T01:02:49","modified_gmt":"2024-11-07T17:02:49","slug":"%e5%a6%82%e4%bd%95%e8%bc%95%e9%ac%86%e8%87%aa%e5%8b%95%e5%95%9f%e5%8b%95redis%e6%95%b8%e6%93%9a%e5%ba%ab%ef%bc%88%e6%80%8e%e9%ba%bc%e8%87%aa%e5%8b%95%e5%95%9f%e5%8b%95redis%e5%ba%ab%ef%bc%89","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/174941\/","title":{"rendered":"\u5982\u4f55\u8f15\u9b06\u81ea\u52d5\u555f\u52d5Redis\u6578\u64da\u5eab\uff08\u600e\u9ebc\u81ea\u52d5\u555f\u52d5redis\u5eab\uff09"},"content":{"rendered":"<h1 id=\"%e5%a6%82%e4%bd%95%e8%bc%95%e9%ac%86%e8%87%aa%e5%8b%95%e5%95%9f%e5%8b%95redis%e6%95%b8%e6%93%9a%e5%ba%ab-KbWFObeSnh\">\u5982\u4f55\u8f15\u9b06\u81ea\u52d5\u555f\u52d5Redis\u6578\u64da\u5eab<\/h1>\n<p>Redis\u662f\u4e00\u500b\u9ad8\u6548\u80fd\u7684\u9375\u503c\u6578\u64da\u5eab\uff0c\u5ee3\u6cdb\u61c9\u7528\u65bc\u7de9\u5b58\u3001\u6d88\u606f\u968a\u5217\u548c\u6578\u64da\u5b58\u5132\u7b49\u5834\u666f\u3002\u5c0d\u65bc\u9700\u8981\u9ad8\u53ef\u7528\u6027\u548c\u7a69\u5b9a\u6027\u7684\u61c9\u7528\u4f86\u8aaa\uff0c\u81ea\u52d5\u555f\u52d5Redis\u6578\u64da\u5eab\u662f\u4e00\u500b\u91cd\u8981\u7684\u914d\u7f6e\u3002\u672c\u6587\u5c07\u4ecb\u7d39\u5982\u4f55\u5728Linux\u7cfb\u7d71\u4e0a\u8f15\u9b06\u8a2d\u7f6eRedis\u7684\u81ea\u52d5\u555f\u52d5\u3002<\/p>\n<h2 id=\"%e5%ae%89%e8%a3%9dredis-KbWFObeSnh\">\u5b89\u88ddRedis<\/h2>\n<p>\u5728\u958b\u59cb\u4e4b\u524d\uff0c\u9996\u5148\u9700\u8981\u78ba\u4fddRedis\u5df2\u7d93\u5b89\u88dd\u5728\u4f60\u7684\u4f3a\u670d\u5668\u4e0a\u3002\u53ef\u4ee5\u901a\u904e\u4ee5\u4e0b\u547d\u4ee4\u4f86\u5b89\u88ddRedis\uff1a<\/p>\n<pre><code>sudo apt update\nsudo apt install redis-server<\/code><\/pre>\n<p>\u5b89\u88dd\u5b8c\u6210\u5f8c\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u4f86\u555f\u52d5Redis\u670d\u52d9\uff1a<\/p>\n<pre><code>sudo systemctl start redis-server<\/code><\/pre>\n<h2 id=\"%e9%85%8d%e7%bd%aeredis%e8%87%aa%e5%8b%95%e5%95%9f%e5%8b%95-KbWFObeSnh\">\u914d\u7f6eRedis\u81ea\u52d5\u555f\u52d5<\/h2>\n<p>\u8981\u4f7fRedis\u5728\u7cfb\u7d71\u555f\u52d5\u6642\u81ea\u52d5\u555f\u52d5\uff0c\u53ef\u4ee5\u4f7f\u7528systemd\u4f86\u7ba1\u7406\u670d\u52d9\u3002\u4ee5\u4e0b\u662f\u914d\u7f6e\u6b65\u9a5f\uff1a<\/p>\n<h3 id=\"1-%e5%89%b5%e5%bb%baredis%e6%9c%8d%e5%8b%99%e6%96%87%e4%bb%b6-KbWFObeSnh\">1. \u5275\u5efaRedis\u670d\u52d9\u6587\u4ef6<\/h3>\n<p>\u9996\u5148\uff0c\u5275\u5efa\u4e00\u500b\u540d\u70baredis.service\u7684\u670d\u52d9\u6587\u4ef6\uff0c\u4e26\u5c07\u5176\u653e\u7f6e\u5728\/etc\/systemd\/system\/\u76ee\u9304\u4e0b\uff1a<\/p>\n<pre><code>sudo nano \/etc\/systemd\/system\/redis.service<\/code><\/pre>\n<p>\u5728\u6587\u4ef6\u4e2d\u6dfb\u52a0\u4ee5\u4e0b\u5167\u5bb9\uff1a<\/p>\n<pre><code>[Unit]\nDescription=Redis In-Memory Data Store\nAfter=network.target\n\n[Service]\nExecStart=\/usr\/bin\/redis-server \/etc\/redis\/redis.conf\nExecStop=\/usr\/bin\/redis-cli shutdown\nRestart=always\nUser=redis\nGroup=redis\n\n[Install]\nWantedBy=multi-user.target<\/code><\/pre>\n<h3 id=\"2-%e9%87%8d%e6%96%b0%e5%8a%a0%e8%bc%89systemd%e9%85%8d%e7%bd%ae-KbWFObeSnh\">2. \u91cd\u65b0\u52a0\u8f09systemd\u914d\u7f6e<\/h3>\n<p>\u5b8c\u6210\u670d\u52d9\u6587\u4ef6\u7684\u5275\u5efa\u5f8c\uff0c\u9700\u8981\u91cd\u65b0\u52a0\u8f09systemd\u914d\u7f6e\uff0c\u4ee5\u4fbf\u7cfb\u7d71\u8b58\u5225\u65b0\u7684\u670d\u52d9\uff1a<\/p>\n<pre><code>sudo systemctl daemon-reload<\/code><\/pre>\n<h3 id=\"3-%e5%95%9f%e7%94%a8redis%e8%87%aa%e5%8b%95%e5%95%9f%e5%8b%95-KbWFObeSnh\">3. \u555f\u7528Redis\u81ea\u52d5\u555f\u52d5<\/h3>\n<p>\u63a5\u4e0b\u4f86\uff0c\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u4f86\u555f\u7528Redis\u670d\u52d9\u7684\u81ea\u52d5\u555f\u52d5\uff1a<\/p>\n<pre><code>sudo systemctl enable redis.service<\/code><\/pre>\n<h3 id=\"4-%e9%a9%97%e8%ad%89redis%e6%9c%8d%e5%8b%99%e7%8b%80%e6%85%8b-KbWFObeSnh\">4. \u9a57\u8b49Redis\u670d\u52d9\u72c0\u614b<\/h3>\n<p>\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u4f86\u6aa2\u67e5Redis\u670d\u52d9\u7684\u72c0\u614b\uff0c\u78ba\u4fdd\u5176\u6b63\u5728\u904b\u884c\uff1a<\/p>\n<pre><code>sudo systemctl status redis.service<\/code><\/pre>\n<p>\u5982\u679c\u4e00\u5207\u6b63\u5e38\uff0c\u60a8\u61c9\u8a72\u6703\u770b\u5230Redis\u670d\u52d9\u7684\u72c0\u614b\u986f\u793a\u70ba\u201cactive (running)\u201d\u3002<\/p>\n<h2 id=\"%e6%b8%ac%e8%a9%a6%e8%87%aa%e5%8b%95%e5%95%9f%e5%8b%95%e5%8a%9f%e8%83%bd-KbWFObeSnh\">\u6e2c\u8a66\u81ea\u52d5\u555f\u52d5\u529f\u80fd<\/h2>\n<p>\u70ba\u4e86\u78ba\u4fddRedis\u80fd\u5920\u5728\u7cfb\u7d71\u91cd\u555f\u5f8c\u81ea\u52d5\u555f\u52d5\uff0c\u53ef\u4ee5\u91cd\u555f\u4f3a\u670d\u5668\u4e26\u518d\u6b21\u6aa2\u67e5Redis\u670d\u52d9\u7684\u72c0\u614b\uff1a<\/p>\n<pre><code>sudo reboot<\/code><\/pre>\n<p>\u91cd\u555f\u5f8c\uff0c\u4f7f\u7528\u76f8\u540c\u7684\u72c0\u614b\u6aa2\u67e5\u547d\u4ee4\u4f86\u78ba\u8a8dRedis\u670d\u52d9\u662f\u5426\u5df2\u7d93\u81ea\u52d5\u555f\u52d5\u3002<\/p>\n<h2 id=\"%e7%b8%bd%e7%b5%90-KbWFObeSnh\">\u7e3d\u7d50<\/h2>\n<p>\u901a\u904e\u4ee5\u4e0a\u6b65\u9a5f\uff0c\u60a8\u53ef\u4ee5\u8f15\u9b06\u5730\u914d\u7f6eRedis\u6578\u64da\u5eab\u5728Linux\u7cfb\u7d71\u4e0a\u81ea\u52d5\u555f\u52d5\u3002\u9019\u4e0d\u50c5\u63d0\u9ad8\u4e86\u7cfb\u7d71\u7684\u7a69\u5b9a\u6027\uff0c\u9084\u80fd\u78ba\u4fdd\u60a8\u7684\u61c9\u7528\u7a0b\u5e8f\u5728\u4f3a\u670d\u5668\u91cd\u555f\u5f8c\u80fd\u5920\u6301\u7e8c\u904b\u884c\u3002\u5982\u679c\u60a8\u9700\u8981\u66f4\u9ad8\u6548\u7684\u89e3\u6c7a\u65b9\u6848\uff0c\u8003\u616e\u4f7f\u7528<a href=\"https:\/\/server.hk\">\u9999\u6e2fVPS<\/a>\u4f86\u90e8\u7f72\u60a8\u7684Redis\u670d\u52d9\uff0c\u9019\u6a23\u53ef\u4ee5\u7372\u5f97\u66f4\u597d\u7684\u6027\u80fd\u548c\u53ef\u9760\u6027\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5b78\u7fd2\u5982\u4f55\u8f15\u9b06\u81ea\u52d5\u555f\u52d5Redis\u6578\u64da\u5eab\uff0c\u78ba\u4fdd\u6578\u64da\u5eab\u5728\u7cfb\u7d71\u555f\u52d5\u6642\u81ea\u52d5\u904b\u884c\uff0c\u63d0\u5347\u5de5\u4f5c\u6548\u7387\u3002<\/p>\n","protected":false},"author":0,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[101],"tags":[],"class_list":["post-174941","post","type-post","status-publish","format-standard","hentry","category-database"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/174941","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/types\/post"}],"replies":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/comments?post=174941"}],"version-history":[{"count":1,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/174941\/revisions"}],"predecessor-version":[{"id":174942,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/174941\/revisions\/174942"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=174941"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=174941"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=174941"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}