{"id":43778,"date":"2024-10-06T09:53:00","date_gmt":"2024-10-06T01:53:00","guid":{"rendered":"https:\/\/server.hk\/cnblog\/43778\/"},"modified":"2024-10-06T09:53:00","modified_gmt":"2024-10-06T01:53:00","slug":"centos-7-%e5%ae%89%e8%a3%9d%e9%85%8d%e7%bd%ae-redis-3-0-0","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/43778\/","title":{"rendered":"CentOS 7 \u5b89\u88dd\u914d\u7f6e Redis-3.0.0"},"content":{"rendered":"<h1 id=\"centos-7-%e5%ae%89%e8%a3%9d%e9%85%8d%e7%bd%ae-redis-3-0-0-DFSaXwaLPw\">CentOS 7 \u5b89\u88dd\u914d\u7f6e Redis-3.0.0<\/h1>\n<p>Redis \u662f\u4e00\u500b\u958b\u6e90\u7684\u9ad8\u6027\u80fd\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\u672c\u6587\u5c07\u4ecb\u7d39\u5982\u4f55\u5728 CentOS 7 \u4e0a\u5b89\u88dd\u548c\u914d\u7f6e Redis 3.0.0\uff0c\u5e6b\u52a9\u7528\u6236\u5feb\u901f\u4e0a\u624b\u3002<\/p>\n<h2 id=\"%e5%89%8d%e6%9c%9f%e6%ba%96%e5%82%99-DFSaXwaLPw\">\u524d\u671f\u6e96\u5099<\/h2>\n<p>\u5728\u958b\u59cb\u5b89\u88dd\u4e4b\u524d\uff0c\u8acb\u78ba\u4fdd\u60a8\u7684 CentOS 7 \u7cfb\u7d71\u5df2\u7d93\u66f4\u65b0\u5230\u6700\u65b0\u7248\u672c\u3002\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u9032\u884c\u66f4\u65b0\uff1a<\/p>\n<pre><code>sudo yum update -y<\/code><\/pre>\n<p>\u63a5\u4e0b\u4f86\uff0c\u60a8\u9700\u8981\u5b89\u88dd\u4e00\u4e9b\u5fc5\u8981\u7684\u4f9d\u8cf4\u5305\uff1a<\/p>\n<pre><code>sudo yum install gcc make -y<\/code><\/pre>\n<h2 id=\"%e4%b8%8b%e8%bc%89-redis-DFSaXwaLPw\">\u4e0b\u8f09 Redis<\/h2>\n<p>Redis \u7684\u6e90\u4ee3\u78bc\u53ef\u4ee5\u5f9e\u5b98\u65b9\u7db2\u7ad9\u4e0b\u8f09\u3002\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u4e0b\u8f09 Redis 3.0.0\uff1a<\/p>\n<pre><code>wget http:\/\/download.redis.io\/releases\/redis-3.0.0.tar.gz<\/code><\/pre>\n<p>\u4e0b\u8f09\u5b8c\u6210\u5f8c\uff0c\u89e3\u58d3\u7e2e\u6587\u4ef6\uff1a<\/p>\n<pre><code>tar xzf redis-3.0.0.tar.gz<\/code><\/pre>\n<h2 id=\"%e7%b7%a8%e8%ad%af-redis-DFSaXwaLPw\">\u7de8\u8b6f Redis<\/h2>\n<p>\u9032\u5165\u89e3\u58d3\u5f8c\u7684\u76ee\u9304\uff0c\u7136\u5f8c\u7de8\u8b6f Redis\uff1a<\/p>\n<pre><code>cd redis-3.0.0\nmake<\/code><\/pre>\n<p>\u7de8\u8b6f\u5b8c\u6210\u5f8c\uff0c\u60a8\u53ef\u4ee5\u904b\u884c\u4ee5\u4e0b\u547d\u4ee4\u4f86\u6e2c\u8a66 Redis \u662f\u5426\u6b63\u5e38\u5de5\u4f5c\uff1a<\/p>\n<pre><code>make test<\/code><\/pre>\n<p>\u5982\u679c\u6240\u6709\u6e2c\u8a66\u90fd\u901a\u904e\uff0c\u60a8\u53ef\u4ee5\u5b89\u88dd Redis\uff1a<\/p>\n<pre><code>sudo make install<\/code><\/pre>\n<h2 id=\"%e9%85%8d%e7%bd%ae-redis-DFSaXwaLPw\">\u914d\u7f6e Redis<\/h2>\n<p>\u5b89\u88dd\u5b8c\u6210\u5f8c\uff0c\u60a8\u9700\u8981\u914d\u7f6e Redis\u3002\u9996\u5148\uff0c\u5275\u5efa\u4e00\u500b\u914d\u7f6e\u76ee\u9304\uff1a<\/p>\n<pre><code>sudo mkdir \/etc\/redis<\/code><\/pre>\n<p>\u7136\u5f8c\uff0c\u5c07 Redis \u7684\u914d\u7f6e\u6587\u4ef6\u8907\u88fd\u5230\u8a72\u76ee\u9304\uff1a<\/p>\n<pre><code>sudo cp redis.conf \/etc\/redis<\/code><\/pre>\n<p>\u63a5\u4e0b\u4f86\uff0c\u7de8\u8f2f\u914d\u7f6e\u6587\u4ef6\u4ee5\u9069\u61c9\u60a8\u7684\u9700\u6c42\uff1a<\/p>\n<pre><code>sudo nano \/etc\/redis\/redis.conf<\/code><\/pre>\n<p>\u5728\u914d\u7f6e\u6587\u4ef6\u4e2d\uff0c\u60a8\u53ef\u4ee5\u4fee\u6539\u4ee5\u4e0b\u5e7e\u500b\u91cd\u8981\u53c3\u6578\uff1a<\/p>\n<ul>\n<li><strong>daemonize<\/strong>: \u5c07\u5176\u8a2d\u7f6e\u70ba <code>yes<\/code> \u4ee5\u4f7f Redis \u5728\u5f8c\u53f0\u904b\u884c\u3002<\/li>\n<li><strong>pidfile<\/strong>: \u8a2d\u7f6e\u9032\u7a0b ID \u6587\u4ef6\u7684\u8def\u5f91\uff0c\u4f8b\u5982 <code>\/var\/run\/redis\/redis.pid<\/code>\u3002<\/li>\n<li><strong>port<\/strong>: \u9ed8\u8a8d\u7aef\u53e3\u70ba <code>6379<\/code>\uff0c\u53ef\u4ee5\u6839\u64da\u9700\u8981\u9032\u884c\u4fee\u6539\u3002<\/li>\n<li><strong>bind<\/strong>: \u8a2d\u7f6e Redis \u76e3\u807d\u7684 IP \u5730\u5740\uff0c\u9ed8\u8a8d\u70ba <code>127.0.0.1<\/code>\uff0c\u5982\u679c\u9700\u8981\u5916\u90e8\u8a2a\u554f\uff0c\u53ef\u4ee5\u8a2d\u7f6e\u70ba <code>0.0.0.0<\/code>\u3002<\/li>\n<\/ul>\n<h2 id=\"%e5%95%9f%e5%8b%95-redis-DFSaXwaLPw\">\u555f\u52d5 Redis<\/h2>\n<p>\u70ba\u4e86\u4f7f Redis \u5728\u7cfb\u7d71\u555f\u52d5\u6642\u81ea\u52d5\u555f\u52d5\uff0c\u60a8\u9700\u8981\u5275\u5efa\u4e00\u500b systemd \u670d\u52d9\u6587\u4ef6\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\/local\/bin\/redis-server \/etc\/redis\/redis.conf\nExecStop=\/usr\/local\/bin\/redis-cli shutdown\nUser=redis\nGroup=redis\nPIDFile=\/var\/run\/redis\/redis.pid\nRestart=always\n\n[Install]\nWantedBy=multi-user.target<\/code><\/pre>\n<p>\u4fdd\u5b58\u4e26\u9000\u51fa\u5f8c\uff0c\u555f\u7528\u4e26\u555f\u52d5 Redis \u670d\u52d9\uff1a<\/p>\n<pre><code>sudo systemctl start redis\nsudo systemctl enable redis<\/code><\/pre>\n<h2 id=\"%e9%a9%97%e8%ad%89-redis-%e6%98%af%e5%90%a6%e9%81%8b%e8%a1%8c-DFSaXwaLPw\">\u9a57\u8b49 Redis \u662f\u5426\u904b\u884c<\/h2>\n<p>\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u6aa2\u67e5 Redis \u7684\u72c0\u614b\uff1a<\/p>\n<pre><code>sudo systemctl status redis<\/code><\/pre>\n<p>\u5982\u679c Redis \u6b63\u5728\u904b\u884c\uff0c\u60a8\u61c9\u8a72\u6703\u770b\u5230\u985e\u4f3c\u65bc <code>active (running)<\/code> \u7684\u72c0\u614b\u4fe1\u606f\u3002\u60a8\u9084\u53ef\u4ee5\u4f7f\u7528 Redis \u5ba2\u6236\u7aef\u9032\u884c\u9023\u63a5\u6e2c\u8a66\uff1a<\/p>\n<pre><code>redis-cli ping<\/code><\/pre>\n<p>\u5982\u679c\u8fd4\u56de <code>PONG<\/code>\uff0c\u5247\u8868\u793a Redis \u6b63\u5e38\u904b\u884c\u3002<\/p>\n<h2 id=\"%e7%b8%bd%e7%b5%90-DFSaXwaLPw\">\u7e3d\u7d50<\/h2>\n<p>\u672c\u6587\u4ecb\u7d39\u4e86\u5982\u4f55\u5728 CentOS 7 \u4e0a\u5b89\u88dd\u548c\u914d\u7f6e Redis 3.0.0\u3002\u901a\u904e\u4ee5\u4e0a\u6b65\u9a5f\uff0c\u60a8\u53ef\u4ee5\u8f15\u9b06\u5730\u5728\u60a8\u7684\u4f3a\u670d\u5668\u4e0a\u904b\u884c Redis\uff0c\u70ba\u60a8\u7684\u61c9\u7528\u63d0\u4f9b\u9ad8\u6548\u7684\u6578\u64da\u5b58\u5132\u89e3\u6c7a\u65b9\u6848\u3002\u5982\u679c\u60a8\u9700\u8981\u66f4\u9ad8\u6548\u7684 <a href=\"https:\/\/server.hk\">VPS<\/a> \u89e3\u6c7a\u65b9\u6848\uff0c\u8acb\u8003\u616e\u4f7f\u7528\u6211\u5011\u7684\u670d\u52d9\uff0c\u8b93\u60a8\u7684\u61c9\u7528\u904b\u884c\u5f97\u66f4\u52a0\u6d41\u66a2\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Learn how to install and configure Redis 3.0.0 on CentOS 7 with step-by-step instructions for optimal performance and setup.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4924],"tags":[],"class_list":["post-43778","post","type-post","status-publish","format-standard","hentry","category-setup-tutorials"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/43778","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"}],"author":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/comments?post=43778"}],"version-history":[{"count":1,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/43778\/revisions"}],"predecessor-version":[{"id":43779,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/43778\/revisions\/43779"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=43778"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=43778"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=43778"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}