{"id":163199,"date":"2024-11-04T21:30:22","date_gmt":"2024-11-04T13:30:22","guid":{"rendered":"https:\/\/server.hk\/cnblog\/163199\/"},"modified":"2024-11-04T21:30:23","modified_gmt":"2024-11-04T13:30:23","slug":"%e8%a7%a3%e6%94%be%e9%9b%99%e6%89%8b%e4%bd%bf%e7%94%a8redis%e8%87%aa%e5%8b%95%e9%83%a8%e7%bd%b2%e8%85%b3%e6%9c%ac%ef%bc%88redis%e8%87%aa%e5%8b%95%e9%83%a8%e7%bd%b2%e8%85%b3%e6%9c%ac%ef%bc%89","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/163199\/","title":{"rendered":"\u89e3\u653e\u96d9\u624b\u4f7f\u7528Redis\u81ea\u52d5\u90e8\u7f72\u8173\u672c\uff08Redis\u81ea\u52d5\u90e8\u7f72\u8173\u672c\uff09"},"content":{"rendered":"<h1 id=\"%e8%a7%a3%e6%94%be%e9%9b%99%e6%89%8b%e4%bd%bf%e7%94%a8redis%e8%87%aa%e5%8b%95%e9%83%a8%e7%bd%b2%e8%85%b3%e6%9c%ac%ef%bc%88redis%e8%87%aa%e5%8b%95%e9%83%a8%e7%bd%b2%e8%85%b3%e6%9c%ac%ef%bc%89-EfQVWaHKmT\">\u89e3\u653e\u96d9\u624b\u4f7f\u7528Redis\u81ea\u52d5\u90e8\u7f72\u8173\u672c\uff08Redis\u81ea\u52d5\u90e8\u7f72\u8173\u672c\uff09<\/h1>\n<p>\u5728\u7576\u4eca\u7684\u6578\u64da\u9a45\u52d5\u6642\u4ee3\uff0cRedis\u4f5c\u70ba\u4e00\u7a2e\u9ad8\u6548\u7684\u9375\u503c\u6578\u64da\u5eab\uff0c\u5ee3\u6cdb\u61c9\u7528\u65bc\u7de9\u5b58\u3001\u6d88\u606f\u968a\u5217\u548c\u5be6\u6642\u6578\u64da\u8655\u7406\u7b49\u5834\u666f\u3002\u96a8\u8457\u696d\u52d9\u9700\u6c42\u7684\u589e\u9577\uff0c\u624b\u52d5\u90e8\u7f72Redis\u7684\u904e\u7a0b\u53ef\u80fd\u6703\u8b8a\u5f97\u7e41\u7463\u4e14\u5bb9\u6613\u51fa\u932f\u3002\u56e0\u6b64\uff0c\u4f7f\u7528\u81ea\u52d5\u90e8\u7f72\u8173\u672c\u4f86\u7c21\u5316\u9019\u4e00\u904e\u7a0b\uff0c\u7121\u7591\u662f\u63d0\u9ad8\u5de5\u4f5c\u6548\u7387\u7684\u6709\u6548\u65b9\u6cd5\u3002<\/p>\n<h2 id=\"%e4%bb%80%e9%ba%bc%e6%98%afredis%e8%87%aa%e5%8b%95%e9%83%a8%e7%bd%b2%e8%85%b3%e6%9c%ac%ef%bc%9f-EfQVWaHKmT\">\u4ec0\u9ebc\u662fRedis\u81ea\u52d5\u90e8\u7f72\u8173\u672c\uff1f<\/h2>\n<p>Redis\u81ea\u52d5\u90e8\u7f72\u8173\u672c\u662f\u4e00\u7a2e\u7528\u65bc\u81ea\u52d5\u5316\u5b89\u88dd\u548c\u914d\u7f6eRedis\u7684\u8173\u672c\u3002\u9019\u4e9b\u8173\u672c\u53ef\u4ee5\u5e6b\u52a9\u7528\u6236\u5feb\u901f\u8a2d\u7f6eRedis\u74b0\u5883\uff0c\u6e1b\u5c11\u624b\u52d5\u64cd\u4f5c\u7684\u6642\u9593\u548c\u932f\u8aa4\u3002\u901a\u5e38\uff0c\u9019\u4e9b\u8173\u672c\u6703\u5305\u62ec\u5b89\u88ddRedis\u6240\u9700\u7684\u6240\u6709\u6b65\u9a5f\uff0c\u5982\u4e0b\u8f09\u3001\u89e3\u58d3\u3001\u914d\u7f6e\u548c\u555f\u52d5\u670d\u52d9\u7b49\u3002<\/p>\n<h2 id=\"%e7%82%ba%e4%bb%80%e9%ba%bc%e4%bd%bf%e7%94%a8%e8%87%aa%e5%8b%95%e9%83%a8%e7%bd%b2%e8%85%b3%e6%9c%ac%ef%bc%9f-EfQVWaHKmT\">\u70ba\u4ec0\u9ebc\u4f7f\u7528\u81ea\u52d5\u90e8\u7f72\u8173\u672c\uff1f<\/h2>\n<ul>\n<li><strong>\u63d0\u9ad8\u6548\u7387\uff1a<\/strong>\u81ea\u52d5\u5316\u90e8\u7f72\u53ef\u4ee5\u5927\u5e45\u5ea6\u6e1b\u5c11\u5b89\u88dd\u6642\u9593\uff0c\u7279\u5225\u662f\u5728\u9700\u8981\u90e8\u7f72\u591a\u500b\u5be6\u4f8b\u7684\u60c5\u6cc1\u4e0b\u3002<\/li>\n<li><strong>\u6e1b\u5c11\u932f\u8aa4\uff1a<\/strong>\u624b\u52d5\u64cd\u4f5c\u5bb9\u6613\u51fa\u932f\uff0c\u800c\u81ea\u52d5\u5316\u8173\u672c\u80fd\u5920\u78ba\u4fdd\u6bcf\u4e00\u6b65\u90fd\u6309\u7167\u9810\u5b9a\u7684\u6d41\u7a0b\u57f7\u884c\u3002<\/li>\n<li><strong>\u6613\u65bc\u91cd\u8907\u4f7f\u7528\uff1a<\/strong>\u4e00\u65e6\u7de8\u5beb\u597d\u81ea\u52d5\u90e8\u7f72\u8173\u672c\uff0c\u672a\u4f86\u7684\u90e8\u7f72\u904e\u7a0b\u4e2d\u53ef\u4ee5\u8f15\u9b06\u91cd\u8907\u4f7f\u7528\uff0c\u7bc0\u7701\u6642\u9593\u548c\u7cbe\u529b\u3002<\/li>\n<\/ul>\n<h2 id=\"redis%e8%87%aa%e5%8b%95%e9%83%a8%e7%bd%b2%e8%85%b3%e6%9c%ac%e7%a4%ba%e4%be%8b-EfQVWaHKmT\">Redis\u81ea\u52d5\u90e8\u7f72\u8173\u672c\u793a\u4f8b<\/h2>\n<p>\u4ee5\u4e0b\u662f\u4e00\u500b\u7c21\u55ae\u7684Redis\u81ea\u52d5\u90e8\u7f72\u8173\u672c\u793a\u4f8b\uff0c\u9069\u7528\u65bc\u57fa\u65bcUbuntu\u7684\u7cfb\u7d71\uff1a<\/p>\n<pre><code>#!\/bin\/bash\n\n# \u66f4\u65b0\u7cfb\u7d71\nsudo apt-get update\n\n# \u5b89\u88ddRedis\nsudo apt-get install -y redis-server\n\n# \u914d\u7f6eRedis\nsudo sed -i 's\/^supervised no\/supervised systemd\/' \/etc\/redis\/redis.conf\n\n# \u555f\u52d5Redis\u670d\u52d9\nsudo systemctl restart redis.service\n\n# \u8a2d\u7f6eRedis\u958b\u6a5f\u555f\u52d5\nsudo systemctl enable redis.service\n\necho \"Redis\u5df2\u6210\u529f\u5b89\u88dd\u4e26\u555f\u52d5\uff01\"\n<\/code><\/pre>\n<p>\u9019\u6bb5\u8173\u672c\u9996\u5148\u66f4\u65b0\u7cfb\u7d71\uff0c\u7136\u5f8c\u5b89\u88ddRedis\uff0c\u63a5\u8457\u4fee\u6539\u914d\u7f6e\u6587\u4ef6\u4ee5\u652f\u6301systemd\uff0c\u6700\u5f8c\u555f\u52d5Redis\u670d\u52d9\u4e26\u8a2d\u7f6e\u70ba\u958b\u6a5f\u555f\u52d5\u3002\u7528\u6236\u53ea\u9700\u904b\u884c\u9019\u500b\u8173\u672c\uff0c\u5373\u53ef\u5b8c\u6210Redis\u7684\u5b89\u88dd\u548c\u914d\u7f6e\u3002<\/p>\n<h2 id=\"%e9%80%b2%e9%9a%8e%e9%85%8d%e7%bd%ae-EfQVWaHKmT\">\u9032\u968e\u914d\u7f6e<\/h2>\n<p>\u9664\u4e86\u57fa\u672c\u7684\u5b89\u88dd\uff0c\u4f7f\u7528\u8005\u53ef\u80fd\u9084\u9700\u8981\u9032\u884c\u4e00\u4e9b\u9032\u968e\u914d\u7f6e\uff0c\u4f8b\u5982\u8a2d\u7f6e\u5bc6\u78bc\u3001\u8abf\u6574\u5167\u5b58\u9650\u5236\u7b49\u3002\u4ee5\u4e0b\u662f\u4e00\u4e9b\u5e38\u898b\u7684\u914d\u7f6e\u9078\u9805\uff1a<\/p>\n<ul>\n<li><strong>\u8a2d\u7f6e\u5bc6\u78bc\uff1a<\/strong>\u5728redis.conf\u4e2d\u627e\u5230\u4e26\u4fee\u6539\u4ee5\u4e0b\u884c\uff1a<\/li>\n<pre><code>requirepass yourpassword<\/code><\/pre>\n<li><strong>\u8abf\u6574\u5167\u5b58\u9650\u5236\uff1a<\/strong>\u53ef\u4ee5\u901a\u904e\u4fee\u6539\u4ee5\u4e0b\u884c\u4f86\u8a2d\u7f6e\u6700\u5927\u5167\u5b58\u4f7f\u7528\u91cf\uff1a<\/li>\n<pre><code>maxmemory 256mb<\/code><\/pre>\n<\/ul>\n<h2 id=\"%e7%b5%90%e8%ab%96-EfQVWaHKmT\">\u7d50\u8ad6<\/h2>\n<p>\u4f7f\u7528Redis\u81ea\u52d5\u90e8\u7f72\u8173\u672c\u4e0d\u50c5\u80fd\u5920\u63d0\u9ad8\u90e8\u7f72\u6548\u7387\uff0c\u9084\u80fd\u6e1b\u5c11\u4eba\u70ba\u932f\u8aa4\uff0c\u8b93\u958b\u767c\u8005\u80fd\u5920\u5c08\u6ce8\u65bc\u696d\u52d9\u908f\u8f2f\u7684\u5be6\u73fe\u3002\u96a8\u8457\u6280\u8853\u7684\u767c\u5c55\uff0c\u8d8a\u4f86\u8d8a\u591a\u7684\u4f01\u696d\u9078\u64c7\u81ea\u52d5\u5316\u90e8\u7f72\u4f86\u63d0\u5347\u904b\u71df\u6548\u7387\u3002\u5c0d\u65bc\u9700\u8981\u9ad8\u6548\u80fd\u548c\u7a69\u5b9a\u6027\u7684\u61c9\u7528\u4f86\u8aaa\uff0cRedis\u7121\u7591\u662f\u4e00\u500b\u7406\u60f3\u7684\u9078\u64c7\u3002<\/p>\n<p>\u5982\u679c\u60a8\u6b63\u5728\u5c0b\u627e\u53ef\u9760\u7684 <a href=\"https:\/\/server.hk\">VPS<\/a> \u89e3\u6c7a\u65b9\u6848\u4f86\u904b\u884c\u60a8\u7684Redis\u5be6\u4f8b\uff0cServer.HK\u63d0\u4f9b\u591a\u7a2e\u9078\u64c7\uff0c\u6eff\u8db3\u4e0d\u540c\u9700\u6c42\u7684\u5ba2\u6236\u3002\u7121\u8ad6\u662f\u5c0f\u578b\u9805\u76ee\u9084\u662f\u5927\u578b\u4f01\u696d\u61c9\u7528\uff0c\u6211\u5011\u7684 <a href=\"https:\/\/server.hk\">\u9999\u6e2fVPS<\/a> \u670d\u52d9\u90fd\u80fd\u70ba\u60a8\u63d0\u4f9b\u7a69\u5b9a\u7684\u652f\u6301\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u89e3\u653e\u96d9\u624b\uff0c\u4f7f\u7528Redis\u81ea\u52d5\u90e8\u7f72\u8173\u672c\u8f15\u9b06\u5be6\u73feRedis\u7684\u5feb\u901f\u90e8\u7f72\u8207\u7ba1\u7406\uff0c\u63d0\u9ad8\u6548\u7387\uff0c\u7bc0\u7701\u6642\u9593\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-163199","post","type-post","status-publish","format-standard","hentry","category-database"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/163199","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=163199"}],"version-history":[{"count":1,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/163199\/revisions"}],"predecessor-version":[{"id":163200,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/163199\/revisions\/163200"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=163199"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=163199"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=163199"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}