{"id":254713,"date":"2022-10-20T08:38:49","date_gmt":"2022-10-20T00:38:49","guid":{"rendered":"https:\/\/lrxjmw.cn\/?p=254713"},"modified":"2022-10-16T23:39:16","modified_gmt":"2022-10-16T15:39:16","slug":"redis-install-uninstall","status":"publish","type":"post","link":"https:\/\/lrxjmw.cn\/redis-install-uninstall.html","title":{"rendered":"linux\u4e0bredis\u7684\u5b89\u88c5\u4e0e\u5378\u8f7d"},"content":{"rendered":"\n\n\n
\u5bfc\u8bfb<\/td>\nRedis\u662f\u4e00\u79cd\u5e94\u7528\u975e\u5e38\u5e7f\u6cdb\u7684\u975e\u5173\u7cfb\u578b\u6570\u636e\u5e93\uff0c\u81f3\u4e8e\u5b83\u7684\u8bf4\u660e\u548c\u4f18\u7f3a\u70b9\u8fd9\u91cc\u6211\u4eec\u5c31\u4e0d\u8fc7\u591a\u9610\u8ff0\u4e86\uff0c\u76f8\u4fe1\u6765\u5230\u8fd9\u91cc\u7684\u4eba\u591a\u5c11\u77e5\u9053\u4e00\u4e9b\u3002redis\u5728Linux\u548cWindows\u4e0b\u7684\u5b89\u88c5\u662f\u6709\u5f88\u5927\u7684\u4e0d\u540c\u7684\uff0c\u548c\u901a\u5e38\u7684\u8f6f\u4ef6\u5b89\u88c5\u662f\u4e00\u6837\u7684\u3002<\/strong><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n
\u5b89\u88c5<\/strong><\/div>\n

1. \u9996\u5148\u5728Redis\u5b98\u7f51\u4e0b\u8f7dtar.gz\u7684\u5b89\u88c5\u5305\uff0c\u6216\u8005\u901a\u8fc7wget\u7684\u65b9\u5f0f\u5728Redis\u91ca\u51fa\u7248\u672c\u91cc\u76f4\u63a5\u4e0b\u8f7d\uff1b<\/p>\n

2. \u5c06\u4e0b\u8f7d\u597d\u7684\u6587\u4ef6\u89e3\u538b\u7f29\uff1b<\/p>\n

3. \u5c06\u89e3\u538b\u540e\u7684\u76ee\u5f55\u79fb\u52a8\u5230\/usr\/local\/redis\u76ee\u5f55\u4e2d\uff1b<\/p>\n

4. \u63a5\u4e0b\u6765\u8fdb\u5165redis\u76ee\u5f55\u4f7f\u7528make\u81ea\u52a8\u7f16\u8bd1\uff1b<\/p>\n

\r\nwget http:\/\/download.redis.io\/releases\/redis-5.0.8.tar.gz  # 1.\u4e0b\u8f7d\r\ntar -zxvf redis-5.0.8.tar.gz  # 2.\u89e3\u538b\u7f29\r\nmv redis-5.0.8.tar.gz \/usr\/local\/redis  # 3.\u79fb\u52a8\u6587\u4ef6\r\ncd \/usr\/local\/redis  # 4.\u8fdb\u5165\u76ee\u5f55\r\nmake  # 5. \u7f16\u8bd1\r\nmake install  # 6.\u5b89\u88c5 \u53ef\u4ee5\u770b\u5230\u5728src\u76ee\u5f55\u4e0b\u751f\u6210\u4e86\u51e0\u4e2a\u65b0\u7684\u6587\u4ef6\uff0c\u4e3a\u4e86\u4f7f\u7528\u65b9\u4fbf\uff0c\u6211\u4eec\u9700\u8981\u5c06\u8fd9\u4e2a\u51e0\u4e2a\u6587\u4ef6\u52a0\u5230\/usr\/local\/bin\u76ee\u5f55\u4e0b\u53bb\u3002\r\n<\/pre>\n

\u6700\u540e\u542f\u52a8\u670d\u52a1\u770b\u4e0b\u662f\u5426\u5b89\u88c5\u6210\u529f\uff0c\u4f7f\u7528redis-server\u547d\u4ee4\u3002<\/p>\n

\"\"<\/p>\n

\u53ef\u4ee5\u770b\u5230redis\u5df2\u7ecf\u5b89\u88c5\u6210\u529f\u4e86\u3002\u8fd9\u4e2a\u65f6\u5019\u4f60\u4f1a\u53d1\u73b0\u4e0d\u80fd\u8fdb\u884c\u5176\u4ed6\u64cd\u4f5c\u4e86\uff0c\u56e0\u4e3a\u8fd9\u662f\u5728\u524d\u53f0\u542f\u52a8\u7684redis\u3002\u8fd9\u4e2a\u65f6\u5019\u53ef\u4ee5\u518d\u542f\u52a8\u4e00\u4e2a\u5ba2\u6237\u7aef\u4f7f\u7528redis-cli shutdown\u547d\u4ee4\u5173\u95edredis\u670d\u52a1\uff0c\u7136\u540e\u4f1a\u5728\u4e4b\u524d\u7684\u5ba2\u6237\u7aef\u770b\u5230\u65e5\u5fd7\u4fe1\u606f\u3002<\/p>\n

\u914d\u7f6e<\/strong><\/div>\n

\u524d\u9762\u5728\u542f\u52a8redis\u670d\u52a1\u5668\u540e\uff0c\u90fd\u662f\u5728\u524d\u53f0\u542f\u52a8\u7684\uff0c\u9700\u8981\u91cd\u65b0\u542f\u52a8\u4e00\u4e2a\u5ba2\u6237\u7aef\u6765\u8fdb\u884c\u767b\u9646\u64cd\u4f5c\u3002\u4e3a\u4e86\u89e3\u51b3\u8fd9\u4e2a\u95ee\u9898\uff0c\u6211\u4eec\u9700\u8981\u8bbe\u7f6e\u540e\u53f0\u542f\u52a8\u3002<\/p>\n

1. \u4fee\u6539redis.conf\u6587\u4ef6\uff0cdaemonize no\u4fee\u6539\u4e3adaemonize yes \u8fd9\u91cc\u8868\u793a\u5c06redis\u4ee5\u5b88\u62a4\u8fdb\u7a0b\u7684\u65b9\u5f0f\u5728\u540e\u53f0\u8fd0\u884c\uff1b<\/p>\n

2. \u8bbe\u7f6eredis\u670d\u52a1\u5f00\u673a\u81ea\u52a8\u542f\u52a8<\/p>\n

\u5728\/etc\/init.d\u76ee\u5f55\u4e0b\u521b\u5efaredis\u7684\u542f\u52a8\u811a\u672c\uff1b
\n\u5c06redis\u5b89\u88c5\u76ee\u5f55\u4e0b\u7684utils\/redis_init_script\u590d\u5236\u5230\/etc\/init.d\u76ee\u5f55\u4e0b\uff0c\u547d\u540d\u4e3aredis\uff1b
\n\u7ee7\u7eed\u7f16\u8f91\u542f\u52a8\u6587\u4ef6\uff0c\u4fee\u6539\u5176\u4e2d\u6307\u5b9a\u7684pid\u548c\u914d\u7f6e\u6587\u4ef6\uff1b<\/p>\n

\r\ncp utils\/redis_init_script \/etc\/init.d\/redis\r\nll \/etc\/init.d\/redis\r\n-rwxr-xr-x. 1 root root 1352 4\u6708  11 15:18 \/etc\/init.d\/redis\r\nvim \/etc\/init.d\/redis  # \u7f16\u8f91\u542f\u52a8\u6587\u4ef6\r\nPIDFILE=\/var\/run\/redis_${REDISPORT}.pid\r\nCONF=\"\/etc\/redis\/${REDISPORT}.conf\"\r\n\u4fee\u6539\u4e3a\r\nPIDFILE=\/var\/redis\/run\/redis_${REDISPORT}.pid  # \u5b58\u653epid\u7684\u76ee\u5f55\uff0c\u5982\u679c\u6ca1\u6709\u8bb0\u5f97\u521b\u5efa\r\nCONF=\"\/etc\/redis\/redis.conf\"\r\nmkdir -p \/var\/redis\/run  # \u521b\u5efa\u5b58\u653epid\u76ee\u5f55\r\n<\/pre>\n

3. \u628a\u914d\u7f6e\u6587\u4ef6\u590d\u5236\u4e00\u4efd\u5230\/etc\/redis\u8fd9\u4e2a\u76ee\u5f55\u4e0b\u9762\uff0c\u7136\u540e\u4fee\u6539\u6587\u4ef6pid\u5730\u5740\u4e3a\u524d\u9762\u914d\u7f6e\u7684\u5730\u5740<\/p>\n

\r\nmkdir -p \/etc\/redis\r\ncp \/usr\/local\/redis\/redis.conf \/etc\/redis\/redis.conf\r\nvim \/etc\/redis\/redis.conf\r\npidfile \/var\/run\/redis_6379.pid\r\n\u4fee\u6539\u4e3a\r\npidfile \/var\/redis\/run\/redis_6379.pid\r\n<\/pre>\n

\u81ea\u6b64\uff0c\u6211\u4eec\u5df2\u7ecf\u53ef\u4ee5\u901a\u8fc7service redis start\/stop\u6765\u542f\u52a8\u548c\u5173\u95edredis\u670d\u52a1\u4e86\u3002<\/p>\n

\u6700\u540e\u53ea\u9700\u8981\u901a\u8fc7chkconfig redis on\u547d\u4ee4\u6765\u8bbe\u7f6e\u5f00\u673a\u542f\u52a8\u5373\u53ef\u3002<\/p>\n

\u5982\u679c\u63d0\u793aredis \u670d\u52a1\u4e0d\u652f\u6301 chkconfig\u7684\u8bdd\uff0c\u53ea\u9700\u8981\u5728\/etc\/init.d\/redis\u8fd9\u4e2a\u542f\u52a8\u811a\u672c\u7684\u7b2c\u4e8c\u884c\u540e\u9762\u52a0\u4e0a\u4e0b\u9762\u7684\u5185\u5bb9\u5373\u53ef<\/p>\n

\r\n# chkconfig:2345 90 10\r\n#\r\n# description:Redis is a persistent key-value database\r\n<\/pre>\n
\u5378\u8f7d<\/strong><\/div>\n

1. \u505c\u6b62redis\u670d\u52a1\u5668\uff0c\u901a\u8fc7\u547d\u4ee4ps aux|grep redis\u67e5\u770bredis\u670d\u52a1\u662f\u5426\u5728\u8fd0\u884c\u3002\u53ef\u4ee5\u770b\u5230\u57286379\u7aef\u53e3\uff0c\u6709redis-server\u7684\u76d1\u542c\u3002<\/p>\n

\"\"<\/p>\n

\u4f7f\u7528\u547d\u4ee4redis-cli shutdown\u505c\u6b62redis\u670d\u52a1\u5668\u3002<\/p>\n

\u9700\u8981\u6ce8\u610f\u7684\u662f\uff0c\u7531\u4e8e\u6211\u7684redis\u547d\u4ee4\u90fd\u5b89\u88c5\u5230\/usr\/local\/bin\u76ee\u5f55\u4e0b\u9762\u4e86\uff0c\u5e76\u4e14\u6dfb\u52a0\u5230\u73af\u5883\u53d8\u91cfPATH\u91cc\u9762\u4e86\uff0c\u6240\u4ee5\u53ef\u4ee5\u76f4\u63a5\u8fd0\u884c\u3002<\/p>\n

2. \u5220\u9664make\u7684\u65f6\u5019\u751f\u6210\u7684\u51e0\u4e2aredis-***\u7684\u6587\u4ef6rm -f \/usr\/local\/bin\/redis*<\/p>\n

3. \u5220\u9664\u6389\u89e3\u538b\u540e\u7684\u6587\u4ef6\u76ee\u5f55\u548c\u6240\u6709\u6587\u4ef6<\/p>\n

\u8fd9\u6837redis\u5c31\u5378\u8f7d\u5b8c\u6210\u4e86\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"

1. \u9996\u5148\u5728Redis\u5b98\u7f51\u4e0b\u8f7dtar.gz\u7684\u5b89\u88c5\u5305\uff0c\u6216\u8005\u901a\u8fc7wget\u7684\u65b9\u5f0f\u5728Redis\u91ca\u51fa\u7248\u672c\u91cc\u76f4\u63a5\u4e0b\u8f7d\uff1b 2 […]<\/p>\n","protected":false},"author":1903,"featured_media":254717,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[55],"tags":[],"class_list":["post-254713","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-thread"],"acf":[],"_links":{"self":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/254713","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/users\/1903"}],"replies":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/comments?post=254713"}],"version-history":[{"count":1,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/254713\/revisions"}],"predecessor-version":[{"id":254716,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/254713\/revisions\/254716"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media\/254717"}],"wp:attachment":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media?parent=254713"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/categories?post=254713"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/tags?post=254713"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}