{"id":14,"date":"2026-06-23T21:23:04","date_gmt":"2026-06-23T13:23:04","guid":{"rendered":"https:\/\/blog.wu2kong.com\/?p=14"},"modified":"2026-06-23T21:23:14","modified_gmt":"2026-06-23T13:23:14","slug":"14","status":"publish","type":"post","link":"https:\/\/blog.wu2kong.com\/?p=14","title":{"rendered":"centos\u5b89\u88c5redis-server"},"content":{"rendered":"<p data-pm-slice=\"0 0 []\">\u5728CentOS\u4e0a\u5b89\u88c5Redis\u670d\u52a1\u5668\u6709\u591a\u79cd\u65b9\u6cd5\uff0c\u4ee5\u4e0b\u662f\u51e0\u79cd\u5e38\u7528\u7684\u5b89\u88c5\u65b9\u5f0f\uff1a<\/p>\r\n\r\n<h2 id=\"%E6%96%B9%E6%B3%95%E4%B8%80%EF%BC%9A%E4%BD%BF%E7%94%A8yum%E5%AE%89%E8%A3%85%EF%BC%88%E6%8E%A8%E8%8D%90%EF%BC%89\"><strong>\u65b9\u6cd5\u4e00\uff1a\u4f7f\u7528YUM\u5b89\u88c5\uff08\u63a8\u8350\uff09<\/strong><\/h2>\r\n<h3 id=\"1.-%E6%B7%BB%E5%8A%A0epel%E4%BB%93%E5%BA%93\"><strong>1. \u6dfb\u52a0EPEL\u4ed3\u5e93<\/strong><\/h3>\r\nbash\r\n<pre><code>sudo yum install epel-release<\/code><\/pre>\r\n<h3 id=\"2.-%E5%AE%89%E8%A3%85redis\"><strong>2. \u5b89\u88c5Redis<\/strong><\/h3>\r\nbash\r\n<pre><code>sudo yum install redis<\/code><\/pre>\r\n<h3 id=\"3.-%E5%90%AF%E5%8A%A8redis%E6%9C%8D%E5%8A%A1\"><strong>3. \u542f\u52a8Redis\u670d\u52a1<\/strong><\/h3>\r\nbash\r\n<pre><code>sudo systemctl start redis\r\nsudo systemctl enable redis<\/code><\/pre>\r\n<h3 id=\"4.-%E6%A3%80%E6%9F%A5redis%E7%8A%B6%E6%80%81\"><strong>4. \u68c0\u67e5Redis\u72b6\u6001<\/strong><\/h3>\r\nbash\r\n<pre><code>sudo systemctl status redis<\/code><\/pre>\r\n<h2 id=\"%E6%96%B9%E6%B3%95%E4%BA%8C%EF%BC%9A%E4%BB%8E%E6%BA%90%E7%A0%81%E7%BC%96%E8%AF%91%E5%AE%89%E8%A3%85\"><strong>\u65b9\u6cd5\u4e8c\uff1a\u4ece\u6e90\u7801\u7f16\u8bd1\u5b89\u88c5<\/strong><\/h2>\r\n<h3 id=\"1.-%E5%AE%89%E8%A3%85%E7%BC%96%E8%AF%91%E4%BE%9D%E8%B5%96\"><strong>1. \u5b89\u88c5\u7f16\u8bd1\u4f9d\u8d56<\/strong><\/h3>\r\nbash\r\n<pre><code>sudo yum groupinstall \"Development Tools\"\r\nsudo yum install tcl<\/code><\/pre>\r\n<h3 id=\"2.-%E4%B8%8B%E8%BD%BD%E5%B9%B6%E7%BC%96%E8%AF%91redis\"><strong>2. \u4e0b\u8f7d\u5e76\u7f16\u8bd1Redis<\/strong><\/h3>\r\nbash\r\n<pre><code>cd \/tmp\r\nwget http:\/\/download.redis.io\/releases\/redis-6.2.6.tar.gz\r\ntar xzf redis-6.2.6.tar.gz\r\ncd redis-6.2.6\r\nmake\r\nsudo make install<\/code><\/pre>\r\n<h3 id=\"3.-%E5%88%9B%E5%BB%BAredis%E9%85%8D%E7%BD%AE%E5%92%8C%E7%9B%AE%E5%BD%95\"><strong>3. \u521b\u5efaRedis\u914d\u7f6e\u548c\u76ee\u5f55<\/strong><\/h3>\r\nbash\r\n<pre><code>sudo mkdir \/etc\/redis\r\nsudo mkdir \/var\/lib\/redis\r\nsudo cp redis.conf \/etc\/redis\/<\/code><\/pre>\r\n<h2 id=\"%E6%96%B9%E6%B3%95%E4%B8%89%EF%BC%9A%E4%BD%BF%E7%94%A8remi%E4%BB%93%E5%BA%93%E5%AE%89%E8%A3%85%E6%9B%B4%E6%96%B0%E7%89%88%E6%9C%AC\"><strong>\u65b9\u6cd5\u4e09\uff1a\u4f7f\u7528Remi\u4ed3\u5e93\u5b89\u88c5\u66f4\u65b0\u7248\u672c<\/strong><\/h2>\r\n<h3 id=\"1.-%E5%AE%89%E8%A3%85remi%E4%BB%93%E5%BA%93\"><strong>1. \u5b89\u88c5Remi\u4ed3\u5e93<\/strong><\/h3>\r\nbash\r\n<pre><code>sudo yum install https:\/\/rpms.remirepo.net\/enterprise\/remi-release-7.rpm<\/code><\/pre>\r\n<h3 id=\"2.-%E5%90%AF%E7%94%A8remi%E4%BB%93%E5%BA%93%E5%B9%B6%E5%AE%89%E8%A3%85redis\"><strong>2. \u542f\u7528Remi\u4ed3\u5e93\u5e76\u5b89\u88c5Redis<\/strong><\/h3>\r\nbash\r\n<pre><code>sudo yum --enablerepo=remi install redis<\/code><\/pre>\r\n<h2 id=\"%E5%9F%BA%E6%9C%AC%E9%85%8D%E7%BD%AE%E5%92%8C%E4%BD%BF%E7%94%A8\"><strong>\u57fa\u672c\u914d\u7f6e\u548c\u4f7f\u7528<\/strong><\/h2>\r\n<h3 id=\"1.-%E7%BC%96%E8%BE%91redis%E9%85%8D%E7%BD%AE%E6%96%87%E4%BB%B6\"><strong>1. \u7f16\u8f91Redis\u914d\u7f6e\u6587\u4ef6<\/strong><\/h3>\r\nbash\r\n<pre><code>sudo vi \/etc\/redis.conf<\/code><\/pre>\r\n\u5e38\u7528\u914d\u7f6e\u9879\uff1a\r\n\r\nbash\r\n<pre><code># \u7ed1\u5b9aIP\u5730\u5740\uff080.0.0.0\u8868\u793a\u5141\u8bb8\u6240\u6709IP\u8bbf\u95ee\uff09\r\nbind 0.0.0.0\r\n\r\n# \u8bbe\u7f6e\u5bc6\u7801\r\nrequirepass your_password\r\n\r\n# \u542f\u7528\u5b88\u62a4\u8fdb\u7a0b\u6a21\u5f0f\r\ndaemonize yes\r\n\r\n# \u8bbe\u7f6e\u6570\u636e\u76ee\u5f55\r\ndir \/var\/lib\/redis<\/code><\/pre>\r\n<h3 id=\"2.-%E9%87%8D%E5%90%AFredis%E6%9C%8D%E5%8A%A1\"><strong>2. \u91cd\u542fRedis\u670d\u52a1<\/strong><\/h3>\r\nbash\r\n<pre><code>sudo systemctl restart redis<\/code><\/pre>\r\n<h3 id=\"3.-%E6%B5%8B%E8%AF%95redis%E8%BF%9E%E6%8E%A5\"><strong>3. \u6d4b\u8bd5Redis\u8fde\u63a5<\/strong><\/h3>\r\nbash\r\n<pre><code>redis-cli\r\n\r\n# \u6d4b\u8bd5ping\u547d\u4ee4\r\n127.0.0.1:6379&gt; ping\r\nPONG\r\n\r\n# \u8bbe\u7f6e\u548c\u83b7\u53d6\u952e\u503c\r\n127.0.0.1:6379&gt; set test \"Hello Redis\"\r\nOK\r\n127.0.0.1:6379&gt; get test\r\n\"Hello Redis\"<\/code><\/pre>\r\n<h3 id=\"4.-%E9%98%B2%E7%81%AB%E5%A2%99%E9%85%8D%E7%BD%AE%EF%BC%88%E5%A6%82%E6%9E%9C%E9%9C%80%E8%A6%81%E8%BF%9C%E7%A8%8B%E8%AE%BF%E9%97%AE%EF%BC%89\"><strong>4. \u9632\u706b\u5899\u914d\u7f6e\uff08\u5982\u679c\u9700\u8981\u8fdc\u7a0b\u8bbf\u95ee\uff09<\/strong><\/h3>\r\nbash\r\n<pre><code>sudo firewall-cmd --permanent --add-port=6379\/tcp\r\nsudo firewall-cmd --reload<\/code><\/pre>\r\n<h2 id=\"%E9%AA%8C%E8%AF%81%E5%AE%89%E8%A3%85\"><strong>\u9a8c\u8bc1\u5b89\u88c5<\/strong><\/h2>\r\n<h3 id=\"%E6%A3%80%E6%9F%A5redis%E7%89%88%E6%9C%AC\"><strong>\u68c0\u67e5Redis\u7248\u672c<\/strong><\/h3>\r\nbash\r\n<pre><code>redis-server --version<\/code><\/pre>\r\n<h3 id=\"%E6%A3%80%E6%9F%A5%E6%9C%8D%E5%8A%A1%E7%8A%B6%E6%80%81\"><strong>\u68c0\u67e5\u670d\u52a1\u72b6\u6001<\/strong><\/h3>\r\nbash\r\n<pre><code>sudo systemctl status redis<\/code><\/pre>\r\n<h3 id=\"%E6%B5%8B%E8%AF%95%E6%80%A7%E8%83%BD\"><strong>\u6d4b\u8bd5\u6027\u80fd<\/strong><\/h3>\r\nbash\r\n<pre><code>redis-benchmark -q -n 100000<\/code><\/pre>\r\n<h2 id=\"%E5%AE%89%E5%85%A8%E5%BB%BA%E8%AE%AE\"><strong>\u5b89\u5168\u5efa\u8bae<\/strong><\/h2>\r\n<ol>\r\n \t<li><strong>\u8bbe\u7f6e\u5f3a\u5bc6\u7801<\/strong>\uff1a\u5728\u914d\u7f6e\u6587\u4ef6\u4e2d\u4f7f\u7528<code>requirepass<\/code>\u6307\u4ee4<\/li>\r\n \t<li><strong>\u9650\u5236\u7ed1\u5b9aIP<\/strong>\uff1a\u53ea\u7ed1\u5b9a\u5fc5\u8981\u7684IP\u5730\u5740<\/li>\r\n \t<li><strong>\u542f\u7528\u4fdd\u62a4\u6a21\u5f0f<\/strong>\uff1a\u4fdd\u6301<code>protected-mode yes<\/code><\/li>\r\n \t<li><strong>\u8003\u8651\u4f7f\u7528SSL<\/strong>\uff1a\u5bf9\u4e8e\u8fdc\u7a0b\u8fde\u63a5\u5efa\u8bae\u4f7f\u7528SSL\u52a0\u5bc6<\/li>\r\n<\/ol>\r\n\u63a8\u8350\u4f7f\u7528\u7b2c\u4e00\u79cd\u65b9\u6cd5\uff08YUM\u5b89\u88c5\uff09\uff0c\u56e0\u4e3a\u5b83\u6700\u7b80\u5355\u4e14\u6613\u4e8e\u7ef4\u62a4\u3002\u5982\u679c\u9700\u8981\u7279\u5b9a\u7248\u672c\u7684Redis\uff0c\u53ef\u4ee5\u9009\u62e9\u6e90\u7801\u7f16\u8bd1\u5b89\u88c5\u6216\u4f7f\u7528Remi\u4ed3\u5e93\u3002","protected":false},"excerpt":{"rendered":"<p>\u5728CentOS\u4e0a\u5b89\u88c5Redis\u670d\u52a1\u5668\u6709\u591a\u79cd\u65b9\u6cd5\uff0c\u4ee5\u4e0b\u662f\u51e0\u79cd\u5e38\u7528\u7684\u5b89\u88c5\u65b9\u5f0f\uff1a \u65b9\u6cd5\u4e00\uff1a\u4f7f\u7528YUM\u5b89\u88c5\uff08\u63a8\u8350\uff09 1 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-14","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/blog.wu2kong.com\/index.php?rest_route=\/wp\/v2\/posts\/14","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.wu2kong.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.wu2kong.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.wu2kong.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.wu2kong.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=14"}],"version-history":[{"count":2,"href":"https:\/\/blog.wu2kong.com\/index.php?rest_route=\/wp\/v2\/posts\/14\/revisions"}],"predecessor-version":[{"id":16,"href":"https:\/\/blog.wu2kong.com\/index.php?rest_route=\/wp\/v2\/posts\/14\/revisions\/16"}],"wp:attachment":[{"href":"https:\/\/blog.wu2kong.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=14"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.wu2kong.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=14"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.wu2kong.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=14"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}