{"id":202325,"date":"2025-05-10T10:30:31","date_gmt":"2025-05-10T02:30:31","guid":{"rendered":"https:\/\/server.hk\/cnblog\/202325\/"},"modified":"2025-05-10T10:30:31","modified_gmt":"2025-05-10T02:30:31","slug":"liunx-php%e5%a6%82%e4%bd%95%e5%ae%89%e8%a3%85redis%e6%89%a9%e5%b1%95","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/202325\/","title":{"rendered":"liunx php\u5982\u4f55\u5b89\u88c5redis\u6269\u5c55"},"content":{"rendered":"<p><b><\/b> <\/p>\n<h1>liunx php\u5982\u4f55\u5b89\u88c5redis\u6269\u5c55<\/h1>\n<p><span style=\"cursor: pointer\"><i><\/i>\u6536\u85cf<\/span> <\/p>\n<p>\u4e00\u5206\u8015\u8018\uff0c\u4e00\u5206\u6536\u83b7\uff01\u65e2\u7136\u90fd\u6253\u5f00\u8fd9\u7bc7<span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\">\u300aliunx php\u5982\u4f55\u5b89\u88c5redis\u6269\u5c55\u300b<\/span>\uff0c\u5c31\u575a\u6301\u770b\u4e0b\u53bb\uff0c\u5b66\u4e0b\u53bb\u5427\uff01\u672c\u6587\u4e3b\u8981\u4f1a\u7ed9\u5927\u5bb6\u8bb2\u5230<span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\"><\/span>\u7b49\u7b49\u77e5\u8bc6\u70b9\uff0c\u5982\u679c\u5927\u5bb6\u5bf9\u672c\u6587\u6709\u597d\u7684\u5efa\u8bae\u6216\u8005\u770b\u5230\u6709\u4e0d\u8db3\u4e4b\u5904\uff0c\u975e\u5e38\u6b22\u8fce\u5927\u5bb6\u79ef\u6781\u63d0\u51fa\uff01\u5728\u540e\u7eed\u6587\u7ae0\u6211\u4f1a\u7ee7\u7eed\u66f4\u65b0<span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\">\u6570\u636e\u5e93<\/span>\u76f8\u5173\u7684\u5185\u5bb9\uff0c\u5e0c\u671b\u5bf9\u5927\u5bb6\u90fd\u6709\u6240\u5e2e\u52a9\uff01<\/p>\n<\/p>\n<blockquote>\n<p>liunx php\u5b89\u88c5redis\u6269\u5c55\u7684\u65b9\u6cd5\uff1a1\u3001\u67e5\u770bredis\u7248\u672c\uff1b2\u3001\u901a\u8fc7wget\u547d\u4ee4\u4e0b\u8f7d\u5b89\u88c5\u5305\u5e76\u901a\u8fc7\u201ctar zxf\u201d\u89e3\u538b\u5b89\u88c5\u5305\uff1b3\u3001\u6267\u884c\u201ccd redis-4.0.8\/src make\u201d\u8fdb\u884c\u5b89\u88c5redis\u5373\u53ef\u3002<\/p>\n<\/blockquote>\n<p><strong>linux \u5b89\u88c5redis<\/strong><\/p>\n<p>linux \u5b89\u88c5redis \u975e\u5e38\u7b80\u5355\uff0c\u5b98\u7f51\u6709\u4ecb\u7ecd\u3002<\/p>\n<p><strong>\u5b89\u88c5redis\uff1a<\/strong><\/p>\n<p>1.\u5148\u67e5\u770bredis\u7248\u672c<\/p>\n<p>2.\u5b89\u88c5redis<\/p>\n<pre>#2.1 \u4e0b\u8f7d\u5b89\u88c5\u5305\r\nwget http:\/\/download.redis.io\/releases\/redis-4.0.8.tar.gz\r\n \r\n#2.2 \u89e3\u538b\r\ntar zxf redis-4.0.8.tar.gz\r\n<\/pre>\n<p><img decoding=\"async\" src=\"https:\/\/www.17golang.com\/uploads\/20240407\/171248385566126e0f75c9c.jpg\" class=\"aligncenter\"><\/p>\n<p>1\u662f\u4e0b\u8f7d\u7684\u5b89\u88c5\u5305\uff0c2\u662f\u89e3\u538b\u540e\u7684\u6587\u4ef6\u5939\u3002 \u8bb0\u4f4f\u8fd9\u4e2a\u6587\u4ef6\u76ee\u5f55\uff0c\u6211\u662f\u5728\/root\u4e0b\u9762\u89e3\u538b\u7684\uff0c\u540e\u9762\u81ea\u542f\u8981\u7528\u5230\u8fd9\u4e2aredis\u76ee\u5f55\u91cc\u7684\u6587\u4ef6<\/p>\n<pre>#2.3\u7f16\u8bd1\r\ncd redis-4.0.8\/src\r\nmake\r\n<\/pre>\n<p>undefined<\/p>\n<pre>#2.4 \u65b0\u5efaredis\u6587\u4ef6\u5939\r\nmkdir \/usr\/local\/redis\r\n<\/pre>\n<p><code><\/code><\/p>\n<pre><code>#2.5\u79fb\u52a8\u6587\u4ef6\ncd&nbsp;redis-4.0.8\/src\nmv&nbsp;redis-server&nbsp;\/usr\/local\/redis\nmv&nbsp;redis-benchmark&nbsp;\/usr\/local\/redis\nmv&nbsp;redis-cli&nbsp;\/usr\/local\/redis\ncd&nbsp;..\/\nmv&nbsp;redis.conf&nbsp;\/usr\/local\/redis<\/code><\/pre>\n<p><img decoding=\"async\" src=\"https:\/\/www.17golang.com\/uploads\/20240407\/171248385566126e0f78cd2.jpg\" class=\"aligncenter\"> <\/p>\n<pre>#2.6 \u542f\u52a8redis\r\ncd \/usr\/local\/redis\r\n.\/redis-server #\u8fd9\u4e2a\u662f\u4ee5\u9ed8\u8ba4\u914d\u7f6e\u5f00\u542f\uff0c\u914d\u7f6e\u6587\u4ef6redis.conf \u5f00\u673a\u81ea\u542f\u8981\u7528\u5230\u3002\r\n<\/pre>\n<p><img decoding=\"async\" src=\"https:\/\/www.17golang.com\/uploads\/20240407\/171248385566126e0f7cf81.jpg\" class=\"aligncenter\"><\/p>\n<p>\u5982\u4e0a\u56fe\u6240\u793a\uff0c\u6309\u914d\u7f6e\u6587\u4ef6\u542f\u52a8\uff0c\u63d0\u793a\u542f\u52a8\u6210\u529f\u3002<\/p>\n<p>\u53ef\u80fd\u51fa\u73b0\u7684\u8b66\u544a\uff1a<\/p>\n<pre>WARNING: The TCP backlog setting of 511 cannot be enforced because \/proc\/sys\/net\/core\/somaxconn is set to the lower value of 128.\r\n<\/pre>\n<p>\u89e3\u51b3\u529e\u6cd5\uff1a<\/p>\n<pre>vim \/etc\/sysctl.conf\r\n<\/pre>\n<p>\u53e6\u8d77\u4e00\u884c\u6dfb\u52a0\uff1a<\/p>\n<pre>net.core.somaxconn = 511\r\n<\/pre>\n<p>\u4fdd\u5b58\u540e\u9000\u51fa<\/p>\n<p>\u7136\u540e\uff1asysctl -p<\/p>\n<pre>WARNING overcommit_memory is set to 0! Background save may fail under low memory condition. To fix this issue add 'vm.overcommit_memory = 1' to \/etc\/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect.\r\n<\/pre>\n<p>\u89e3\u51b3\u529e\u6cd5\uff1a<br \/>vim \/etc\/sysctl.conf<br \/>\u6362\u884c\u6dfb\u52a0\uff1a<br \/>vm.overcommit_memory=1<br \/>\u4fdd\u5b58\u540e\u9000\u51fa<br \/>sysctl -p<\/p>\n<pre>WARNING you have Transparent Huge Pages (THP) support enabled in your kernel. This will create latency and memory usage issues with Redis. To fix this issue run the command 'echo never &gt; \/sys\/kernel\/mm\/transparent_hugepage\/enabled' as root, and add it to your \/etc\/rc.local in order to retain the setting after a reboot. Redis must be restarted after THP is disabled.\r\n<\/pre>\n<p>\u89e3\u51b3\u529e\u6cd5\uff1a<br \/>vim \/etc\/rc.local<br \/>\u6362\u884c\u6dfb\u52a0\uff1a<\/p>\n<pre>if test -f \/sys\/kernel\/mm\/transparent_hugepage\/enabled; then\r\n &nbsp; echo never &gt; \/sys\/kernel\/mm\/transparent_hugepage\/enabled\r\nfi\r\n<\/pre>\n<p>\u4fdd\u5b58\u540e\u9000\u51fa<br \/>\u91cd\u542f\u7cfb\u7edf\u3001\u91cd\u542f\u670d\u52a1\u5668\uff1a<br \/>reboot <\/p>\n<p>\u4e00\u822c\u65b0\u670d\u52a1\u5668\u7b2c\u4e00\u6b21\u5b89\u88c5redis\u7136\u540e\u542f\u52a8\u90fd\u4f1a\u6709\u8fd9\u4e09\u4e2a\u8b66\u544a\u3002<\/p>\n<pre>#2.7 \u8fde\u63a5redis\uff0c\u8fdb\u884c\u6d4b\u8bd5\r\n.\/redis-cli\r\nset pandent 2018\r\nget pandent\r\n<\/pre>\n<p><img decoding=\"async\" src=\"https:\/\/www.17golang.com\/uploads\/20240407\/171248385566126e0f81147.jpg\" class=\"aligncenter\"><\/p>\n<p>\u8bbe\u7f6e\u548c\u83b7\u53d6\u90fd\u6b63\u5e38\uff0c\u8bf4\u660eredis\u5df2\u7ecf\u5b89\u88c5\u6210\u529f\u5566\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>liunx php\u5982\u4f55\u5b89\u88c5red&#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-202325","post","type-post","status-publish","format-standard","hentry","category-database"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/202325","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=202325"}],"version-history":[{"count":0,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/202325\/revisions"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=202325"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=202325"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=202325"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}