{"id":42966,"date":"2024-10-04T11:16:43","date_gmt":"2024-10-04T03:16:43","guid":{"rendered":"https:\/\/server.hk\/cnblog\/42966\/"},"modified":"2024-10-04T11:16:43","modified_gmt":"2024-10-04T03:16:43","slug":"centos-7-3-%e6%90%ad%e5%bb%ba-redis-4-0-1-%e5%96%ae%e6%a9%9f%e6%9c%8d%e5%8b%99","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/42966\/","title":{"rendered":"CentOS 7.3 \u642d\u5efa Redis-4.0.1 \u55ae\u6a5f\u670d\u52d9"},"content":{"rendered":"<h1 id=\"centos-7-3-%e6%90%ad%e5%bb%ba-redis-4-0-1-%e5%96%ae%e6%a9%9f%e6%9c%8d%e5%8b%99-foqQHhdLoM\">CentOS 7.3 \u642d\u5efa Redis-4.0.1 \u55ae\u6a5f\u670d\u52d9<\/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\u6307\u5c0e\u60a8\u5982\u4f55\u5728 CentOS 7.3 \u4e0a\u642d\u5efa Redis 4.0.1 \u55ae\u6a5f\u670d\u52d9\uff0c\u4e26\u63d0\u4f9b\u8a73\u7d30\u7684\u6b65\u9a5f\u548c\u4ee3\u78bc\u793a\u4f8b\u3002<\/p>\n<h2 id=\"%e5%89%8d%e6%9c%9f%e6%ba%96%e5%82%99-foqQHhdLoM\">\u524d\u671f\u6e96\u5099<\/h2>\n<p>\u5728\u958b\u59cb\u4e4b\u524d\uff0c\u8acb\u78ba\u4fdd\u60a8\u7684 CentOS 7.3 \u7cfb\u7d71\u5df2\u7d93\u66f4\u65b0\u5230\u6700\u65b0\u7248\u672c\u3002\u60a8\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\uff0c\u9019\u4e9b\u5305\u5c07\u5e6b\u52a9\u60a8\u7de8\u8b6f\u548c\u5b89\u88dd Redis\uff1a<\/p>\n<pre><code>sudo yum install gcc make -y<\/code><\/pre>\n<h2 id=\"%e4%b8%8b%e8%bc%89-redis-foqQHhdLoM\">\u4e0b\u8f09 Redis<\/h2>\n<p>\u63a5\u4e0b\u4f86\uff0c\u60a8\u9700\u8981\u4e0b\u8f09 Redis \u7684\u6e90\u4ee3\u78bc\u3002\u53ef\u4ee5\u4f7f\u7528 wget \u547d\u4ee4\u4f86\u4e0b\u8f09 Redis 4.0.1 \u7684\u58d3\u7e2e\u5305\uff1a<\/p>\n<pre><code>wget http:\/\/download.redis.io\/releases\/redis-4.0.1.tar.gz<\/code><\/pre>\n<p>\u4e0b\u8f09\u5b8c\u6210\u5f8c\uff0c\u89e3\u58d3\u7e2e\u8a72\u6587\u4ef6\uff1a<\/p>\n<pre><code>tar xzvf redis-4.0.1.tar.gz<\/code><\/pre>\n<h2 id=\"%e7%b7%a8%e8%ad%af-redis-foqQHhdLoM\">\u7de8\u8b6f Redis<\/h2>\n<p>\u9032\u5165\u89e3\u58d3\u5f8c\u7684\u76ee\u9304\uff0c\u7136\u5f8c\u4f7f\u7528 make \u547d\u4ee4\u7de8\u8b6f Redis\uff1a<\/p>\n<pre><code>cd redis-4.0.1\nmake<\/code><\/pre>\n<p>\u7de8\u8b6f\u5b8c\u6210\u5f8c\uff0c\u60a8\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u4f86\u6e2c\u8a66 Redis \u662f\u5426\u7de8\u8b6f\u6210\u529f\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-foqQHhdLoM\">\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\u4e2d\uff1a<\/p>\n<pre><code>sudo cp redis.conf \/etc\/redis<\/code><\/pre>\n<p>\u63a5\u4e0b\u4f86\uff0c\u60a8\u53ef\u4ee5\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\u8a2d\u7f6e\u4ee5\u4e0b\u5e7e\u500b\u91cd\u8981\u53c3\u6578\uff1a<\/p>\n<ul>\n<li><strong>daemonize<\/strong>: \u5c07\u5176\u8a2d\u7f6e\u70ba yes\uff0c\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\u3002<\/li>\n<li><strong>port<\/strong>: \u8a2d\u7f6e Redis \u670d\u52d9\u7684\u7aef\u53e3\uff0c\u9ed8\u8a8d\u70ba 6379\u3002<\/li>\n<li><strong>dir<\/strong>: \u8a2d\u7f6e\u6578\u64da\u6301\u4e45\u5316\u7684\u76ee\u9304\u3002<\/li>\n<\/ul>\n<h2 id=\"%e5%95%9f%e5%8b%95-redis-%e6%9c%8d%e5%8b%99-foqQHhdLoM\">\u555f\u52d5 Redis \u670d\u52d9<\/h2>\n<p>\u914d\u7f6e\u5b8c\u6210\u5f8c\uff0c\u60a8\u53ef\u4ee5\u555f\u52d5 Redis \u670d\u52d9\u3002\u9996\u5148\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\u8a72\u6587\u4ef6\u4e2d\uff0c\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\nRestart=always\n\n[Install]\nWantedBy=multi-user.target<\/code><\/pre>\n<p>\u4fdd\u5b58\u4e26\u9000\u51fa\u5f8c\uff0c\u91cd\u65b0\u52a0\u8f09 systemd \u914d\u7f6e\uff1a<\/p>\n<pre><code>sudo systemctl daemon-reload<\/code><\/pre>\n<p>\u7136\u5f8c\u555f\u52d5 Redis \u670d\u52d9\u4e26\u8a2d\u7f6e\u70ba\u958b\u6a5f\u81ea\u555f\uff1a<\/p>\n<pre><code>sudo systemctl start redis\nsudo systemctl enable redis<\/code><\/pre>\n<h2 id=\"%e6%b8%ac%e8%a9%a6-redis-%e6%98%af%e5%90%a6%e9%81%8b%e8%a1%8c-foqQHhdLoM\">\u6e2c\u8a66 Redis \u662f\u5426\u904b\u884c<\/h2>\n<p>\u60a8\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u4f86\u6aa2\u67e5 Redis \u7684\u904b\u884c\u72c0\u614b\uff1a<\/p>\n<pre><code>sudo systemctl status redis<\/code><\/pre>\n<p>\u5982\u679c Redis \u6b63\u5728\u904b\u884c\uff0c\u60a8\u53ef\u4ee5\u4f7f\u7528 redis-cli \u9032\u884c\u9023\u63a5\u6e2c\u8a66\uff1a<\/p>\n<pre><code>redis-cli ping<\/code><\/pre>\n<p>\u5982\u679c\u8fd4\u56de &#8220;PONG&#8221;\uff0c\u5247\u8868\u793a Redis \u5df2\u6210\u529f\u555f\u52d5\u4e26\u904b\u884c\u3002<\/p>\n<h2 id=\"%e7%b8%bd%e7%b5%90-foqQHhdLoM\">\u7e3d\u7d50<\/h2>\n<p>\u672c\u6587\u4ecb\u7d39\u4e86\u5982\u4f55\u5728 CentOS 7.3 \u4e0a\u642d\u5efa Redis 4.0.1 \u55ae\u6a5f\u670d\u52d9\uff0c\u5f9e\u4e0b\u8f09\u3001\u7de8\u8b6f\u5230\u914d\u7f6e\u548c\u555f\u52d5\uff0c\u63d0\u4f9b\u4e86\u8a73\u7d30\u7684\u6b65\u9a5f\u548c\u4ee3\u78bc\u793a\u4f8b\u3002Redis \u662f\u4e00\u500b\u5f37\u5927\u7684\u6578\u64da\u5b58\u5132\u89e3\u6c7a\u65b9\u6848\uff0c\u9069\u5408\u5404\u7a2e\u61c9\u7528\u5834\u666f\u3002\u5982\u679c\u60a8\u9700\u8981\u7a69\u5b9a\u7684 <a href=\"https:\/\/server.hk\">VPS<\/a> \u670d\u52d9\u4f86\u904b\u884c\u60a8\u7684\u61c9\u7528\uff0c\u8acb\u8003\u616e\u6211\u5011\u7684\u89e3\u6c7a\u65b9\u6848\uff0c\u8b93\u60a8\u7684\u696d\u52d9\u66f4\u4e0a\u4e00\u5c64\u6a13\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Learn how to set up a Redis 4.0.1 single-instance service on CentOS 7.3 with this step-by-step guide for optimal performance and configuration.<\/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-42966","post","type-post","status-publish","format-standard","hentry","category-setup-tutorials"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/42966","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=42966"}],"version-history":[{"count":1,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/42966\/revisions"}],"predecessor-version":[{"id":42967,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/42966\/revisions\/42967"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=42966"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=42966"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=42966"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}