{"id":43074,"date":"2024-10-04T15:47:08","date_gmt":"2024-10-04T07:47:08","guid":{"rendered":"https:\/\/server.hk\/cnblog\/43074\/"},"modified":"2024-10-04T15:47:08","modified_gmt":"2024-10-04T07:47:08","slug":"centos-7-%e5%ae%89%e8%a3%9d-redis-5-0-5-%e4%b8%a6%e5%8a%a0%e5%85%a5-systemd-%e6%9c%8d%e5%8b%99","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/43074\/","title":{"rendered":"CentOS 7 \u5b89\u88dd Redis 5.0.5 \u4e26\u52a0\u5165 Systemd \u670d\u52d9"},"content":{"rendered":"<h1 id=\"centos-7-%e5%ae%89%e8%a3%9d-redis-5-0-5-%e4%b8%a6%e5%8a%a0%e5%85%a5-systemd-%e6%9c%8d%e5%8b%99-hoAARpxEaC\">CentOS 7 \u5b89\u88dd Redis 5.0.5 \u4e26\u52a0\u5165 Systemd \u670d\u52d9<\/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\u6307\u5c0e\u60a8\u5982\u4f55\u5728 CentOS 7 \u4e0a\u5b89\u88dd Redis 5.0.5 \u4e26\u5c07\u5176\u914d\u7f6e\u70ba Systemd \u670d\u52d9\uff0c\u4ee5\u4fbf\u65bc\u7ba1\u7406\u548c\u555f\u52d5\u3002<\/p>\n<h2 id=\"%e5%89%8d%e7%bd%ae%e6%a2%9d%e4%bb%b6-hoAARpxEaC\">\u524d\u7f6e\u689d\u4ef6<\/h2>\n<ul>\n<li>\u4e00\u53f0\u904b\u884c CentOS 7 \u7684\u4f3a\u670d\u5668\u3002<\/li>\n<li>\u64c1\u6709 sudo \u6b0a\u9650\u7684\u7528\u6236\u3002<\/li>\n<\/ul>\n<h2 id=\"%e5%ae%89%e8%a3%9d-epel-%e5%80%89%e5%ba%ab-hoAARpxEaC\">\u5b89\u88dd EPEL \u5009\u5eab<\/h2>\n<p>Redis \u5728 EPEL\uff08Extra Packages for Enterprise Linux\uff09\u5009\u5eab\u4e2d\u53ef\u7528\uff0c\u56e0\u6b64\u9996\u5148\u9700\u8981\u5b89\u88dd EPEL \u5009\u5eab\u3002<\/p>\n<pre><code>sudo yum install epel-release -y<\/code><\/pre>\n<h2 id=\"%e5%ae%89%e8%a3%9d-redis-hoAARpxEaC\">\u5b89\u88dd Redis<\/h2>\n<p>\u63a5\u4e0b\u4f86\uff0c\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u5b89\u88dd Redis\uff1a<\/p>\n<pre><code>sudo yum install redis-5.0.5 -y<\/code><\/pre>\n<h2 id=\"%e9%85%8d%e7%bd%ae-redis-hoAARpxEaC\">\u914d\u7f6e Redis<\/h2>\n<p>\u5b89\u88dd\u5b8c\u6210\u5f8c\uff0c\u60a8\u53ef\u4ee5\u901a\u904e\u7de8\u8f2f Redis \u7684\u914d\u7f6e\u6587\u4ef6\u4f86\u9032\u884c\u81ea\u5b9a\u7fa9\u8a2d\u7f6e\u3002\u914d\u7f6e\u6587\u4ef6\u4f4d\u65bc \/etc\/redis.conf\u3002\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u6253\u958b\u914d\u7f6e\u6587\u4ef6\uff1a<\/p>\n<pre><code>sudo vi \/etc\/redis.conf<\/code><\/pre>\n<p>\u5728\u914d\u7f6e\u6587\u4ef6\u4e2d\uff0c\u60a8\u53ef\u4ee5\u6839\u64da\u9700\u8981\u4fee\u6539\u4ee5\u4e0b\u5e7e\u500b\u91cd\u8981\u53c3\u6578\uff1a<\/p>\n<ul>\n<li><strong>bind<\/strong>: \u8a2d\u7f6e Redis \u76e3\u807d\u7684 IP \u5730\u5740\uff0c\u9ed8\u8a8d\u70ba 127.0.0.1\uff0c\u60a8\u53ef\u4ee5\u6839\u64da\u9700\u8981\u4fee\u6539\u3002<\/li>\n<li><strong>protected-mode<\/strong>: \u5982\u679c\u60a8\u5e0c\u671b Redis \u50c5\u5728\u672c\u5730\u8a2a\u554f\uff0c\u8acb\u4fdd\u6301\u70ba yes\u3002<\/li>\n<li><strong>supervised<\/strong>: \u5c07\u6b64\u8a2d\u7f6e\u70ba systemd\uff0c\u4ee5\u4fbf\u8207 Systemd \u96c6\u6210\u3002<\/li>\n<\/ul>\n<h2 id=\"%e5%95%9f%e7%94%a8%e5%92%8c%e5%95%9f%e5%8b%95-redis-%e6%9c%8d%e5%8b%99-hoAARpxEaC\">\u555f\u7528\u548c\u555f\u52d5 Redis \u670d\u52d9<\/h2>\n<p>\u63a5\u4e0b\u4f86\uff0c\u60a8\u9700\u8981\u555f\u7528 Redis \u670d\u52d9\u4e26\u4f7f\u5176\u5728\u7cfb\u7d71\u555f\u52d5\u6642\u81ea\u52d5\u555f\u52d5\uff1a<\/p>\n<pre><code>sudo systemctl enable redis<\/code><\/pre>\n<p>\u7136\u5f8c\u555f\u52d5 Redis \u670d\u52d9\uff1a<\/p>\n<pre><code>sudo systemctl start redis<\/code><\/pre>\n<h2 id=\"%e6%aa%a2%e6%9f%a5-redis-%e6%9c%8d%e5%8b%99%e7%8b%80%e6%85%8b-hoAARpxEaC\">\u6aa2\u67e5 Redis \u670d\u52d9\u72c0\u614b<\/h2>\n<p>\u60a8\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u6aa2\u67e5 Redis \u670d\u52d9\u7684\u72c0\u614b\uff1a<\/p>\n<pre><code>sudo systemctl status redis<\/code><\/pre>\n<p>\u5982\u679c\u4e00\u5207\u6b63\u5e38\uff0c\u60a8\u61c9\u8a72\u6703\u770b\u5230\u985e\u4f3c\u65bc\u4ee5\u4e0b\u7684\u8f38\u51fa\uff1a<\/p>\n<pre><code>\u25cf redis.service - Advanced key-value store\n   Loaded: loaded (\/usr\/lib\/systemd\/system\/redis.service; enabled; vendor preset: disabled)\n   Active: active (running) since ...<\/code><\/pre>\n<h2 id=\"%e6%b8%ac%e8%a9%a6-redis-%e5%ae%89%e8%a3%9d-hoAARpxEaC\">\u6e2c\u8a66 Redis \u5b89\u88dd<\/h2>\n<p>\u8981\u78ba\u8a8d Redis \u662f\u5426\u6b63\u5e38\u904b\u884c\uff0c\u60a8\u53ef\u4ee5\u4f7f\u7528 redis-cli \u5de5\u5177\u9032\u884c\u6e2c\u8a66\u3002\u9996\u5148\uff0c\u555f\u52d5 Redis CLI\uff1a<\/p>\n<pre><code>redis-cli<\/code><\/pre>\n<p>\u7136\u5f8c\uff0c\u60a8\u53ef\u4ee5\u57f7\u884c\u4ee5\u4e0b\u547d\u4ee4\u4f86\u6e2c\u8a66 Redis\uff1a<\/p>\n<pre><code>set test \"Hello, Redis!\"\nget test<\/code><\/pre>\n<p>\u5982\u679c\u8fd4\u56de\u503c\u70ba &#8220;Hello, Redis!&#8221;\uff0c\u5247\u8868\u793a Redis \u5b89\u88dd\u6210\u529f\u4e14\u904b\u884c\u6b63\u5e38\u3002<\/p>\n<h2 id=\"%e7%b8%bd%e7%b5%90-hoAARpxEaC\">\u7e3d\u7d50<\/h2>\n<p>\u5728\u672c\u6587\u4e2d\uff0c\u6211\u5011\u4ecb\u7d39\u4e86\u5982\u4f55\u5728 CentOS 7 \u4e0a\u5b89\u88dd Redis 5.0.5 \u4e26\u5c07\u5176\u914d\u7f6e\u70ba Systemd \u670d\u52d9\u3002\u9019\u6a23\u7684\u914d\u7f6e\u4e0d\u50c5\u63d0\u9ad8\u4e86 Redis \u7684\u53ef\u7ba1\u7406\u6027\uff0c\u9084\u80fd\u78ba\u4fdd\u5176\u5728\u7cfb\u7d71\u91cd\u555f\u5f8c\u81ea\u52d5\u555f\u52d5\u3002\u5982\u679c\u60a8\u9700\u8981\u66f4\u591a\u7684\u4f3a\u670d\u5668\u89e3\u6c7a\u65b9\u6848\uff0c\u8acb\u8a2a\u554f\u6211\u5011\u7684 <a href=\"https:\/\/server.hk\">\u9999\u6e2f\u4f3a\u670d\u5668<\/a> \u670d\u52d9\u3002\u7121\u8ad6\u662f <a href=\"https:\/\/server.hk\">VPS<\/a> \u9084\u662f\u5176\u4ed6\u96f2\u670d\u52d9\uff0c\u6211\u5011\u90fd\u80fd\u63d0\u4f9b\u7a69\u5b9a\u53ef\u9760\u7684\u652f\u6301\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Learn how to install Redis 5.0.5 on CentOS 7 and configure it as a Systemd service for easy management and startup.<\/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-43074","post","type-post","status-publish","format-standard","hentry","category-setup-tutorials"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/43074","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=43074"}],"version-history":[{"count":1,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/43074\/revisions"}],"predecessor-version":[{"id":43075,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/43074\/revisions\/43075"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=43074"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=43074"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=43074"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}