{"id":179736,"date":"2024-11-09T04:22:24","date_gmt":"2024-11-08T20:22:24","guid":{"rendered":"https:\/\/server.hk\/cnblog\/179736\/"},"modified":"2024-11-09T04:22:25","modified_gmt":"2024-11-08T20:22:25","slug":"%e5%a6%82%e4%bd%95%e5%9c%a8-windows-%e4%b8%8b%e4%bd%bf%e7%94%a8-redis%ef%bc%88win-%e4%b8%8b-redis-%e6%80%8e%e9%ba%bc%e7%94%a8%ef%bc%89","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/179736\/","title":{"rendered":"\u5982\u4f55\u5728 Windows \u4e0b\u4f7f\u7528 Redis\uff08win \u4e0b redis \u600e\u9ebc\u7528\uff09"},"content":{"rendered":"<h1 id=\"%e5%a6%82%e4%bd%95%e5%9c%a8-windows-%e4%b8%8b%e4%bd%bf%e7%94%a8-redis%ef%bc%88win-%e4%b8%8b-redis-%e6%80%8e%e9%ba%bc%e7%94%a8%ef%bc%89-ERpgtEyzaw\">\u5982\u4f55\u5728 Windows \u4e0b\u4f7f\u7528 Redis\uff08win \u4e0b redis \u600e\u9ebc\u7528\uff09<\/h1>\n<p>Redis \u662f\u4e00\u500b\u9ad8\u6548\u80fd\u7684\u9375\u503c\u5b58\u5132\u7cfb\u7d71\uff0c\u5ee3\u6cdb\u61c9\u7528\u65bc\u7de9\u5b58\u3001\u6d88\u606f\u968a\u5217\u548c\u6578\u64da\u6301\u4e45\u5316\u7b49\u5834\u666f\u3002\u96d6\u7136 Redis \u6700\u521d\u662f\u70ba Linux \u74b0\u5883\u8a2d\u8a08\u7684\uff0c\u4f46\u73fe\u5728\u4e5f\u53ef\u4ee5\u5728 Windows \u4e0a\u904b\u884c\u3002\u672c\u6587\u5c07\u4ecb\u7d39\u5982\u4f55\u5728 Windows \u7cfb\u7d71\u4e0b\u5b89\u88dd\u548c\u4f7f\u7528 Redis\u3002<\/p>\n<h2 id=\"%e4%b8%80%e3%80%81%e5%ae%89%e8%a3%9d-redis-ERpgtEyzaw\">\u4e00\u3001\u5b89\u88dd Redis<\/h2>\n<p>\u5728 Windows \u4e0a\u5b89\u88dd Redis \u6709\u5e7e\u7a2e\u65b9\u6cd5\uff0c\u6700\u5e38\u898b\u7684\u662f\u4f7f\u7528 Windows \u5b50\u7cfb\u7d71 Linux\uff08WSL\uff09\u6216\u76f4\u63a5\u4f7f\u7528 Windows \u7248\u672c\u7684 Redis\u3002\u4ee5\u4e0b\u662f\u5169\u7a2e\u5b89\u88dd\u65b9\u6cd5\u7684\u8a73\u7d30\u6b65\u9a5f\uff1a<\/p>\n<h3 id=\"1-%e4%bd%bf%e7%94%a8-windows-%e7%89%88%e6%9c%ac%e7%9a%84-redis-ERpgtEyzaw\">1. \u4f7f\u7528 Windows \u7248\u672c\u7684 Redis<\/h3>\n<ul>\n<li>\u9996\u5148\uff0c\u8a2a\u554f Redis \u7684 GitHub \u9801\u9762\uff0c\u4e0b\u8f09\u6700\u65b0\u7684 Windows \u7248\u672c\u3002\u53ef\u4ee5\u5728\u4ee5\u4e0b\u93c8\u63a5\u627e\u5230\uff1a<a href=\"https:\/\/github.com\/microsoftarchive\/redis\/releases\" rel=\"nofollow noopener\" target=\"_blank\">Redis for Windows Releases<\/a><\/li>\n<li>\u4e0b\u8f09\u5b8c\u6210\u5f8c\uff0c\u89e3\u58d3\u7e2e\u6587\u4ef6\u5230\u4f60\u5e0c\u671b\u5b89\u88dd\u7684\u76ee\u9304\u3002<\/li>\n<li>\u9032\u5165\u89e3\u58d3\u7e2e\u7684\u6587\u4ef6\u593e\uff0c\u627e\u5230 <code>redis-server.exe<\/code> \u548c <code>redis-cli.exe<\/code> \u9019\u5169\u500b\u53ef\u57f7\u884c\u6587\u4ef6\u3002<\/li>\n<\/ul>\n<h3 id=\"2-%e4%bd%bf%e7%94%a8-wsl-%e5%ae%89%e8%a3%9d-redis-ERpgtEyzaw\">2. \u4f7f\u7528 WSL \u5b89\u88dd Redis<\/h3>\n<ul>\n<li>\u9996\u5148\uff0c\u78ba\u4fdd\u4f60\u7684 Windows 10 \u6216 Windows 11 \u7cfb\u7d71\u5df2\u555f\u7528 WSL\u3002\u53ef\u4ee5\u5728 PowerShell \u4e2d\u904b\u884c\u4ee5\u4e0b\u547d\u4ee4\u4f86\u555f\u7528 WSL\uff1a\n<pre><code>wsl --install<\/code><\/pre>\n<\/li>\n<li>\u5b89\u88dd\u5b8c\u6210\u5f8c\uff0c\u91cd\u555f\u96fb\u8166\uff0c\u7136\u5f8c\u5728 Microsoft Store \u4e2d\u5b89\u88dd\u4e00\u500b Linux \u767c\u884c\u7248\uff08\u5982 Ubuntu\uff09\u3002<\/li>\n<li>\u555f\u52d5 Ubuntu\uff0c\u7136\u5f8c\u66f4\u65b0\u5305\u7ba1\u7406\u5668\uff1a\n<pre><code>sudo apt update<\/code><\/pre>\n<\/li>\n<li>\u63a5\u4e0b\u4f86\uff0c\u5b89\u88dd Redis\uff1a\n<pre><code>sudo apt install redis-server<\/code><\/pre>\n<\/li>\n<li>\u5b89\u88dd\u5b8c\u6210\u5f8c\uff0c\u53ef\u4ee5\u555f\u52d5 Redis \u670d\u52d9\uff1a\n<pre><code>sudo service redis-server start<\/code><\/pre>\n<\/li>\n<\/ul>\n<h2 id=\"%e4%ba%8c%e3%80%81%e9%85%8d%e7%bd%ae-redis-ERpgtEyzaw\">\u4e8c\u3001\u914d\u7f6e Redis<\/h2>\n<p>Redis \u7684\u914d\u7f6e\u6587\u4ef6\u901a\u5e38\u4f4d\u65bc\u5b89\u88dd\u76ee\u9304\u4e0b\u7684 <code>redis.windows.conf<\/code> \u6216\u5728 WSL \u4e2d\u7684 <code>\/etc\/redis\/redis.conf<\/code>\u3002\u4f60\u53ef\u4ee5\u6839\u64da\u9700\u8981\u4fee\u6539\u914d\u7f6e\u6587\u4ef6\u4f86\u8abf\u6574 Redis \u7684\u884c\u70ba\uff0c\u4f8b\u5982\u8a2d\u7f6e\u6301\u4e45\u5316\u3001\u6700\u5927\u5167\u5b58\u4f7f\u7528\u91cf\u7b49\u3002<\/p>\n<h3 id=\"1-%e4%bf%ae%e6%94%b9%e9%85%8d%e7%bd%ae%e6%96%87%e4%bb%b6-ERpgtEyzaw\">1. \u4fee\u6539\u914d\u7f6e\u6587\u4ef6<\/h3>\n<ul>\n<li>\u4f7f\u7528\u6587\u672c\u7de8\u8f2f\u5668\u6253\u958b\u914d\u7f6e\u6587\u4ef6\uff0c\u6839\u64da\u9700\u8981\u9032\u884c\u4fee\u6539\u3002\u4f8b\u5982\uff0c\u8a2d\u7f6e\u6700\u5927\u5167\u5b58\u4f7f\u7528\u91cf\uff1a\n<pre><code>maxmemory 256mb<\/code><\/pre>\n<\/li>\n<li>\u4fdd\u5b58\u4fee\u6539\u5f8c\uff0c\u91cd\u555f Redis \u670d\u52d9\u4ee5\u4f7f\u66f4\u6539\u751f\u6548\u3002<\/li>\n<\/ul>\n<h2 id=\"%e4%b8%89%e3%80%81%e4%bd%bf%e7%94%a8-redis-ERpgtEyzaw\">\u4e09\u3001\u4f7f\u7528 Redis<\/h2>\n<p>\u5b89\u88dd\u548c\u914d\u7f6e\u5b8c\u6210\u5f8c\uff0c\u4f60\u53ef\u4ee5\u4f7f\u7528 <code>redis-cli<\/code> \u4f86\u8207 Redis \u9032\u884c\u4ea4\u4e92\u3002\u4ee5\u4e0b\u662f\u4e00\u4e9b\u57fa\u672c\u7684\u547d\u4ee4\u793a\u4f8b\uff1a<\/p>\n<h3 id=\"1-%e5%95%9f%e5%8b%95-redis-cli-ERpgtEyzaw\">1. \u555f\u52d5 Redis CLI<\/h3>\n<pre><code>redis-cli<\/code><\/pre>\n<h3 id=\"2-%e5%9f%ba%e6%9c%ac%e5%91%bd%e4%bb%a4%e7%a4%ba%e4%be%8b-ERpgtEyzaw\">2. \u57fa\u672c\u547d\u4ee4\u793a\u4f8b<\/h3>\n<ul>\n<li>\u8a2d\u7f6e\u9375\u503c\u5c0d\uff1a\n<pre><code>SET mykey \"Hello, Redis!\"<\/code><\/pre>\n<\/li>\n<li>\u7372\u53d6\u9375\u503c\uff1a\n<pre><code>GET mykey<\/code><\/pre>\n<\/li>\n<li>\u522a\u9664\u9375\uff1a\n<pre><code>DEL mykey<\/code><\/pre>\n<\/li>\n<\/ul>\n<h2 id=\"%e5%9b%9b%e3%80%81%e5%b8%b8%e8%a6%8b%e5%95%8f%e9%a1%8c-ERpgtEyzaw\">\u56db\u3001\u5e38\u898b\u554f\u984c<\/h2>\n<h3 id=\"1-redis-%e5%9c%a8-windows-%e4%b8%8a%e7%9a%84%e6%80%a7%e8%83%bd%e5%a6%82%e4%bd%95%ef%bc%9f-ERpgtEyzaw\">1. Redis \u5728 Windows \u4e0a\u7684\u6027\u80fd\u5982\u4f55\uff1f<\/h3>\n<p>\u96d6\u7136 Redis \u5728 Windows \u4e0a\u53ef\u4ee5\u904b\u884c\uff0c\u4f46\u5176\u6027\u80fd\u548c\u7a69\u5b9a\u6027\u53ef\u80fd\u4e0d\u5982\u5728 Linux \u4e0a\u3002\u56e0\u6b64\uff0c\u5c0d\u65bc\u751f\u7522\u74b0\u5883\uff0c\u5efa\u8b70\u4f7f\u7528 Linux \u7cfb\u7d71\u3002<\/p>\n<h3 id=\"2-%e5%a6%82%e4%bd%95%e7%a2%ba%e4%bf%9d-redis-%e7%9a%84%e5%ae%89%e5%85%a8%e6%80%a7%ef%bc%9f-ERpgtEyzaw\">2. \u5982\u4f55\u78ba\u4fdd Redis \u7684\u5b89\u5168\u6027\uff1f<\/h3>\n<p>\u5728\u751f\u7522\u74b0\u5883\u4e2d\uff0c\u5efa\u8b70\u8a2d\u7f6e\u5bc6\u78bc\u4fdd\u8b77\u548c\u9632\u706b\u7246\u898f\u5247\uff0c\u4ee5\u9632\u6b62\u672a\u7d93\u6388\u6b0a\u7684\u8a2a\u554f\u3002<\/p>\n<h2 id=\"%e7%b8%bd%e7%b5%90-ERpgtEyzaw\">\u7e3d\u7d50<\/h2>\n<p>\u5728 Windows \u4e0b\u4f7f\u7528 Redis \u662f\u4e00\u500b\u76f8\u5c0d\u7c21\u55ae\u7684\u904e\u7a0b\uff0c\u7121\u8ad6\u662f\u901a\u904e\u76f4\u63a5\u5b89\u88dd Windows \u7248\u672c\u9084\u662f\u4f7f\u7528 WSL\u3002\u901a\u904e\u672c\u6587\u7684\u4ecb\u7d39\uff0c\u4f60\u61c9\u8a72\u80fd\u5920\u6210\u529f\u5b89\u88dd\u3001\u914d\u7f6e\u548c\u4f7f\u7528 Redis\u3002\u82e5\u4f60\u9700\u8981\u66f4\u9ad8\u6548\u7684\u670d\u52d9\u5668\u89e3\u6c7a\u65b9\u6848\uff0c\u53ef\u4ee5\u8003\u616e\u4f7f\u7528 <a href=\"https:\/\/server.hk\">\u9999\u6e2fVPS<\/a> \u4f86\u904b\u884c\u4f60\u7684\u61c9\u7528\u7a0b\u5e8f\uff0c\u4eab\u53d7\u66f4\u7a69\u5b9a\u7684\u6027\u80fd\u548c\u66f4\u9ad8\u7684\u5b89\u5168\u6027\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4e86\u89e3\u5982\u4f55\u5728 Windows \u7cfb\u7edf\u4e0a\u5b89\u88c5\u548c\u4f7f\u7528 Redis\uff0c\u5feb\u901f\u914d\u7f6e\u548c\u7ba1\u7406\u6570\u636e\u5e93\uff0c\u63d0\u5347\u5f00\u53d1\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-179736","post","type-post","status-publish","format-standard","hentry","category-database"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/179736","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=179736"}],"version-history":[{"count":1,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/179736\/revisions"}],"predecessor-version":[{"id":179737,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/179736\/revisions\/179737"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=179736"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=179736"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=179736"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}