{"id":201384,"date":"2025-05-10T10:19:04","date_gmt":"2025-05-10T02:19:04","guid":{"rendered":"https:\/\/server.hk\/cnblog\/201384\/"},"modified":"2025-05-10T10:19:04","modified_gmt":"2025-05-10T02:19:04","slug":"%e5%9c%a8centos-7%e7%8e%af%e5%a2%83%e4%b8%8b%e5%ae%89%e8%a3%85redis%e6%95%b0%e6%8d%ae%e5%ba%93%e8%af%a6%e8%a7%a3","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/201384\/","title":{"rendered":"\u5728CentOS 7\u73af\u5883\u4e0b\u5b89\u88c5Redis\u6570\u636e\u5e93\u8be6\u89e3"},"content":{"rendered":"<p><b><\/b> <\/p>\n<h1>\u5728CentOS 7\u73af\u5883\u4e0b\u5b89\u88c5Redis\u6570\u636e\u5e93\u8be6\u89e3<\/h1>\n<p><span style=\"cursor: pointer\"><i><\/i>\u6536\u85cf<\/span> <\/p>\n<p>\u600e\u4e48\u5165\u95e8\u6570\u636e\u5e93\u7f16\u7a0b\uff1f\u9700\u8981\u5b66\u4e60\u54ea\u4e9b\u77e5\u8bc6\u70b9\uff1f\u8fd9\u662f\u65b0\u624b\u4eec\u521a\u63a5\u89e6\u7f16\u7a0b\u65f6\u5e38\u89c1\u7684\u95ee\u9898\uff1b\u4e0b\u9762golang\u5b66\u4e60\u7f51\u5c31\u6765\u7ed9\u5927\u5bb6\u6574\u7406\u5206\u4eab\u4e00\u4e9b\u77e5\u8bc6\u70b9\uff0c\u5e0c\u671b\u80fd\u591f\u7ed9\u521d\u5b66\u8005\u4e00\u4e9b\u5e2e\u52a9\u3002\u672c\u7bc7\u6587\u7ae0\u5c31\u6765\u4ecb\u7ecd\u300a\u5728CentOS 7\u73af\u5883\u4e0b\u5b89\u88c5Redis\u6570\u636e\u5e93\u8be6\u89e3\u300b\uff0c\u6d89\u53ca\u5230centosredis\uff0c\u6709\u9700\u8981\u7684\u53ef\u4ee5\u6536\u85cf\u4e00\u4e0b<\/p>\n<p>\u6b63\u5982\u6211\u4eec\u6240\u77e5\u7684\u90a3\u6837\uff0cRedis\u662f\u4e00\u4e2a\u5f00\u6e90\u7684\u3001\u57fa\u4e8eBSD\u8bb8\u53ef\u8bc1\u7684\uff0c\u57fa\u4e8e\u5185\u5b58\u7684\u3001\u952e\u503c\u5b58\u50a8NoSQL\u6570\u636e\u5e93\u3002Redis\u7ecf\u5e38\u88ab\u89c6\u4e3a\u4e00\u4e2a\u6570\u636e\u7ed3\u6784\u670d\u52a1\u5668\uff0c\u56e0\u4e3aRedis\u652f\u6301\u5b57\u7b26\u4e32strings\u3001\u54c8\u5e0chashes\u3001\u5217\u8868lists\u3001\u96c6\u5408sets\u3001\u6709\u5e8f\u96c6sorted sets\u7b49\u6570\u636e\u7ed3\u6784\u3002Redis\u8fd8\u652f\u6301\u50cf\u4e8b\u52a1Transitions\u3001\u53d1\u5e03\u548c\u8ba2\u9605\u8fd9\u6837\u7684\u6570\u636e\u7c7b\u578b\u3002\u6709\u9274\u4e8e\u6b64\uff0cRedis\u7ecf\u5e38\u88ab\u8ba4\u4e3a\u662f\u66f4\u5f3a\u5927\u7684Memcache\u3002<\/p>\n<p>\u672c\u6587\u4e3b\u8981\u8bb2\u8ff0Redis\u5728CentOS 7\u73af\u5883\u4e0b\u7684\u5b89\u88c5\u6709\u4ec0\u4e48\u4e0d\u540c\u3002\u5047\u5b9aCentOS 7 Server\u5df2\u7ecf\u5c31\u7eea\u3002<\/p>\n<p><strong>1\u3001\u542f\u7528EPEL\u4ed3\u5e93<\/strong><\/p>\n<pre>\n## RHEL\/CentOS 7 64-Bit ##\n# wget http:\/\/dl.fedoraproject.org\/pub\/epel\/7\/x86_64\/e\/epel-release-7-5.noarch.rpm\n# rpm -ivh epel-release-7-5.noarch.rpm<\/pre>\n<p>\u8981\u9a8c\u8bc1EPEL\u4ed3\u5e93\u662f\u5426\u5efa\u7acb\u6210\u529f\uff0c\u53ef\u4ee5\u6267\u884c\uff1a<\/p>\n<pre>\n# yum repolist<\/pre>\n<p><strong>2\u3001\u901a\u8fc7Yum\u5b89\u88c5Redis<\/strong><\/p>\n<pre>\n# yum -y update\n# yum install redis php-pecl-redis<\/pre>\n<p>\u628aRedis\u6dfb\u52a0\u5230\u5f00\u673a\u542f\u52a8\u670d\u52a1\u4e2d\uff1a<\/p>\n<pre>\n# systemctl start redis-server.service\n# systemctl enable redis-server.service<\/pre>\n<p>\u68c0\u67e5Redis\u662f\u5426\u8fd0\u884c\uff1a<\/p>\n<pre>\n# systemctl is-active redis-server.service<\/pre>\n<p><strong>3\u3001\u5b89\u88c5Redis\u7684Web\u7ba1\u7406\u5ba2\u6237\u7aef<\/strong><\/p>\n<p>phpRedisAdmin\u662f\u4e00\u4e2a\u514d\u8d39\u5f00\u6e90\u7684RedisWeb\u7ba1\u7406\u5ba2\u6237\u7aef\uff0c\u5b83\u63d0\u4f9b\u4e86\u4e00\u4e2a\u7b80\u5355\u7684\u754c\u9762\u6765\u5b9e\u73b0\u5bf9Redis\u6570\u636e\u5e93\u7684\u7ba1\u7406\u3002<\/p>\n<pre>\n# git clone https:\/\/github.com\/ErikDubbelboer\/phpRedisAdmin.git\n# cd phpRedisAdmin\/includes\n# cp config.sample.inc.php config.inc.php<\/pre>\n<p>\u8981\u786e\u4fdd\u914d\u7f6e\u6b63\u786e\uff1a<\/p>\n<pre>\n# nano config.inc.php<\/pre>\n<p>\u518d\u628aRedisAdmin\u914d\u7f6e\u6587\u4ef6\u6dfb\u52a0\u5230Apache\u670d\u52a1\u5668\uff0c\u6587\u4ef6\u7684\u5185\u5bb9\u5982\u4e0b\uff1a<\/p>\n<pre>\n### nano \/etc\/httpd\/conf.d\/redisadmin.conf\n### Now add the following ###\n#\n# Web Interface for RedisAdmin\n# \n\n\n   \n    \n Order Deny,Allow\n Deny from all\n Allow from 127.0.0.1\n Allow from \n    \n   \n\nAlias \/redisAdmin \/downloads\/phpRedisAdmin\nAlias \/redisadmin \/downloads\/phpRedisAdmin\n<\/pre>\n<p>\u521b\u5efa\u4e00\u4e2aBash\u811a\u672c\u6765\u786e\u4fddRedis\u7684\u6b63\u5e38\u8fd0\u884c\uff0c\u5185\u5bb9\u5982\u4e0b\uff1a<\/p>\n<pre>\n### nano \/scripts\/redis-check.sh\n#!\/bin\/bash\nPS=$(which ps)\nGREP=$(which grep)\nWHEN=$(date +\"%Y-%m-%d-%H:%M:%S\")\n  if ! $PS aux | $GREP \"redis.conf\" | $GREP -v grep 2&gt;&amp;1 &gt; \/dev\/null; then\n    \/etc\/init.d\/redis restart\n    echo 'Restarted Redis @' $WHEN\n  fi\n#Check Second instance\n  if ! $PS aux | $GREP \"redis2.conf\" | $GREP -v grep 2&gt;&amp;1 &gt; \/dev\/null; then\n    \/etc\/init.d\/redis2 restart\n    echo 'Restarted Redis2 @' $WHEN\n  fi<\/pre>\n<p>\u786e\u4fdd\u811a\u672c\u662f\u53ef\u6267\u884c\u7684\uff1a<\/p>\n<pre>\n# chmod +x \/scripts\/redis-check.sh<\/pre>\n<p>\u901a\u8fc7\u5b9a\u65f6\u5668cron\u6765\u4fdd\u8bc1\u811a\u672c\u7684\u6267\u884c\uff0c\u6bcf3\u5206\u949f\u8fd0\u884c\u4e00\u6b21\uff1a<\/p>\n<pre>\n### nano \/var\/spool\/cron\/root\n*\/3 * * * * \/bin\/bash \/script\/redis-check.sh &gt;&gt; \/var\/log\/redis-check.log<\/pre>\n<p>OK\uff0c\u81f3\u6b64\u5b8c\u5de5\u3002<\/p>\n<p>\u539f\u6587\u94fe\u63a5\uff1ahttp:\/\/blog.csdn.net\/chszs\/article\/details\/51925378<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5728CentOS 7\u73af\u5883\u4e0b\u5b89\u88c5Re&#46;&#46;&#46;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[101],"tags":[],"class_list":["post-201384","post","type-post","status-publish","format-standard","hentry","category-database"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/201384","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=201384"}],"version-history":[{"count":0,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/201384\/revisions"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=201384"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=201384"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=201384"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}