{"id":45016,"date":"2024-10-06T19:51:18","date_gmt":"2024-10-06T11:51:18","guid":{"rendered":"https:\/\/server.hk\/cnblog\/45016\/"},"modified":"2024-10-06T19:51:18","modified_gmt":"2024-10-06T11:51:18","slug":"redis-%e5%9c%a8-centos-6-4-%e4%b8%ad%e7%9a%84%e5%ae%89%e8%a3%9d","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/45016\/","title":{"rendered":"Redis \u5728 CentOS 6.4 \u4e2d\u7684\u5b89\u88dd"},"content":{"rendered":"<h1 id=\"redis-%e5%9c%a8-centos-6-4-%e4%b8%ad%e7%9a%84%e5%ae%89%e8%a3%9d-iPfNPEdcrp\">Redis \u5728 CentOS 6.4 \u4e2d\u7684\u5b89\u88dd<\/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\u672c\u6587\u5c07\u4ecb\u7d39\u5982\u4f55\u5728 CentOS 6.4 \u7cfb\u7d71\u4e0a\u5b89\u88dd Redis\uff0c\u4e26\u63d0\u4f9b\u8a73\u7d30\u7684\u6b65\u9a5f\u548c\u6ce8\u610f\u4e8b\u9805\u3002<\/p>\n<h2 id=\"%e5%89%8d%e6%9c%9f%e6%ba%96%e5%82%99-iPfNPEdcrp\">\u524d\u671f\u6e96\u5099<\/h2>\n<p>\u5728\u958b\u59cb\u5b89\u88dd\u4e4b\u524d\uff0c\u8acb\u78ba\u4fdd\u60a8\u7684 CentOS 6.4 \u7cfb\u7d71\u5df2\u7d93\u66f4\u65b0\u5230\u6700\u65b0\u7248\u672c\u3002\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u4f86\u66f4\u65b0\u7cfb\u7d71\uff1a<\/p>\n<pre><code>sudo yum update<\/code><\/pre>\n<p>\u6b64\u5916\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\u904b\u884c Redis\u3002\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u5b89\u88dd\uff1a<\/p>\n<pre><code>sudo yum install gcc make<\/code><\/pre>\n<h2 id=\"%e4%b8%8b%e8%bc%89-redis-iPfNPEdcrp\">\u4e0b\u8f09 Redis<\/h2>\n<p>\u63a5\u4e0b\u4f86\uff0c\u60a8\u9700\u8981\u5f9e Redis \u7684\u5b98\u65b9\u7db2\u7ad9\u4e0b\u8f09\u6700\u65b0\u7248\u672c\u7684 Redis\u3002\u53ef\u4ee5\u4f7f\u7528 wget \u547d\u4ee4\u4f86\u4e0b\u8f09\uff1a<\/p>\n<pre><code>wget http:\/\/download.redis.io\/releases\/redis-6.0.9.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-6.0.9.tar.gz<\/code><\/pre>\n<h2 id=\"%e7%b7%a8%e8%ad%af-redis-iPfNPEdcrp\">\u7de8\u8b6f Redis<\/h2>\n<p>\u9032\u5165\u89e3\u58d3\u7e2e\u5f8c\u7684\u76ee\u9304\uff0c\u7136\u5f8c\u4f7f\u7528 make \u547d\u4ee4\u7de8\u8b6f Redis\uff1a<\/p>\n<pre><code>cd redis-6.0.9\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-iPfNPEdcrp\">\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 &#8220;yes&#8221;\uff0c\u4ee5\u4fbf 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\u5668\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-iPfNPEdcrp\">\u555f\u52d5 Redis<\/h2>\n<p>\u914d\u7f6e\u5b8c\u6210\u5f8c\uff0c\u60a8\u53ef\u4ee5\u555f\u52d5 Redis \u670d\u52d9\u3002\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u555f\u52d5 Redis\uff1a<\/p>\n<pre><code>redis-server \/etc\/redis\/redis.conf<\/code><\/pre>\n<p>\u8981\u6aa2\u67e5 Redis \u662f\u5426\u6b63\u5728\u904b\u884c\uff0c\u60a8\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<pre><code>redis-cli ping<\/code><\/pre>\n<p>\u5982\u679c\u8fd4\u56de &#8220;PONG&#8221;\uff0c\u5247\u8868\u793a Redis \u6b63\u5728\u6b63\u5e38\u904b\u884c\u3002<\/p>\n<h2 id=\"%e8%a8%ad%e7%bd%ae%e7%82%ba%e7%b3%bb%e7%b5%b1%e6%9c%8d%e5%8b%99-iPfNPEdcrp\">\u8a2d\u7f6e\u70ba\u7cfb\u7d71\u670d\u52d9<\/h2>\n<p>\u70ba\u4e86\u8b93 Redis \u5728\u7cfb\u7d71\u555f\u52d5\u6642\u81ea\u52d5\u555f\u52d5\uff0c\u60a8\u53ef\u4ee5\u5275\u5efa\u4e00\u500b systemd \u670d\u52d9\u6587\u4ef6\u3002\u9996\u5148\uff0c\u5275\u5efa\u4e00\u500b\u540d\u70ba redis.service \u7684\u6587\u4ef6\uff1a<\/p>\n<pre><code>sudo nano \/etc\/systemd\/system\/redis.service<\/code><\/pre>\n<p>\u5728\u8a72\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\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 enable redis\nsudo systemctl start redis<\/code><\/pre>\n<h2 id=\"%e7%b8%bd%e7%b5%90-iPfNPEdcrp\">\u7e3d\u7d50<\/h2>\n<p>\u5728\u672c\u6587\u4e2d\uff0c\u6211\u5011\u4ecb\u7d39\u4e86\u5982\u4f55\u5728 CentOS 6.4 \u7cfb\u7d71\u4e0a\u5b89\u88dd\u548c\u914d\u7f6e Redis\u3002\u901a\u904e\u9019\u4e9b\u6b65\u9a5f\uff0c\u60a8\u53ef\u4ee5\u8f15\u9b06\u5730\u5c07 Redis \u90e8\u7f72\u5230\u60a8\u7684\u4f3a\u670d\u5668\u4e0a\uff0c\u4e26\u5229\u7528\u5176\u9ad8\u6548\u80fd\u7684\u6578\u64da\u5b58\u5132\u80fd\u529b\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\u6211\u5011\u7684\u670d\u52d9\uff0c\u8b93\u60a8\u7684\u61c9\u7528\u7a0b\u5e8f\u904b\u884c\u5f97\u66f4\u52a0\u6d41\u66a2\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5b78\u7fd2\u5982\u4f55\u5728 CentOS 6.4 \u4e0a\u5b89\u88dd Redis\uff0c\u6b65\u9a5f\u7c21\u55ae\u660e\u77ad\uff0c\u52a9\u4f60\u5feb\u901f\u642d\u5efa\u9ad8\u6548\u7684\u6578\u64da\u5b58\u5132\u89e3\u6c7a\u65b9\u6848\u3002<\/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-45016","post","type-post","status-publish","format-standard","hentry","category-setup-tutorials"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/45016","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=45016"}],"version-history":[{"count":1,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/45016\/revisions"}],"predecessor-version":[{"id":45017,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/45016\/revisions\/45017"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=45016"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=45016"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=45016"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}