{"id":46043,"date":"2024-12-01T13:36:43","date_gmt":"2024-12-01T05:36:43","guid":{"rendered":"https:\/\/fwq.ai\/blog\/46043\/"},"modified":"2024-12-01T13:36:43","modified_gmt":"2024-12-01T05:36:43","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:\/\/fwq.ai\/blog\/46043\/","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><i><\/i>0\u6d4f\u89c8<\/span><br \/>\n<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\" title=\"liunx php\u5982\u4f55\u5b89\u88c5redis\u6269\u5c55\u63d2\u56fe\" alt=\"liunx php\u5982\u4f55\u5b89\u88c5redis\u6269\u5c55\u63d2\u56fe\" \/><\/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\" title=\"liunx php\u5982\u4f55\u5b89\u88c5redis\u6269\u5c55\u63d2\u56fe1\" alt=\"liunx php\u5982\u4f55\u5b89\u88c5redis\u6269\u5c55\u63d2\u56fe1\" \/> <\/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\" title=\"liunx php\u5982\u4f55\u5b89\u88c5redis\u6269\u5c55\u63d2\u56fe2\" alt=\"liunx php\u5982\u4f55\u5b89\u88c5redis\u6269\u5c55\u63d2\u56fe2\" \/><\/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\" title=\"liunx php\u5982\u4f55\u5b89\u88c5redis\u6269\u5c55\u63d2\u56fe3\" alt=\"liunx php\u5982\u4f55\u5b89\u88c5redis\u6269\u5c55\u63d2\u56fe3\" \/><\/p>\n<p>\u8bbe\u7f6e\u548c\u83b7\u53d6\u90fd\u6b63\u5e38\uff0c\u8bf4\u660eredis\u5df2\u7ecf\u5b89\u88c5\u6210\u529f\u5566\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u672c\u6587\u7684\u5168\u90e8\u5185\u5bb9\u4e86\uff0c\u662f\u5426\u6709\u987a\u5229\u5e2e\u52a9\u4f60\u89e3\u51b3\u95ee\u9898\uff1f\u82e5\u662f\u80fd\u7ed9\u4f60\u5e26\u6765\u5b66\u4e60\u4e0a\u7684\u5e2e\u52a9\uff0c\u8bf7\u5927\u5bb6\u591a\u591a\u652f\u6301golang\u5b66\u4e60\u7f51\uff01\u66f4\u591a\u5173\u4e8e\u6570\u636e\u5e93\u7684\u76f8\u5173\u77e5\u8bc6\uff0c\u4e5f\u53ef\u5173\u6ce8golang\u5b66\u4e60\u7f51\u516c\u4f17\u53f7\u3002<\/p>\n<p>    \u7248\u672c\u58f0\u660e \u672c\u6587\u8f6c\u8f7d\u4e8e\uff1a\u4ebf\u901f\u4e91 \u5982\u6709\u4fb5\u72af\uff0c\u8bf7\u8054\u7cfb \u5220\u9664  <\/p>\n<dl>\n<dt>\n <\/dt>\n<dd>\n   \u5982\u4f55\u89e3\u51b3\u672c\u5730\u6a21\u5757\u7684\u4f20\u9012\u4f9d\u8d56\n <\/dd>\n<\/dl>\n<dl>\n<dt>\n <\/dt>\n<dd>\n   \u4f7f\u7528 Go \u8bed\u8a00\u8fdb\u884c POST \u8bf7\u6c42\u7684\u6700\u4f73\u65b9\u6848\n <\/dd>\n<\/dl>\n","protected":false},"excerpt":{"rendered":"<p>liunx php\u5982\u4f55\u5b89\u88c5redis\u6269\u5c55 0\u6d4f\u89c8 \u6536\u85cf \u4e00\u5206\u8015\u8018\uff0c\u4e00\u5206\u6536\u83b7\uff01\u65e2\u7136\u90fd\u6253\u5f00\u8fd9\u7bc7\u300aliunx php\u5982\u4f55\u5b89\u88c5redis\u6269\u5c55\u300b\uff0c\u5c31\u575a\u6301\u770b\u4e0b\u53bb\uff0c\u5b66\u4e0b\u53bb\u5427\uff01\u672c\u6587\u4e3b\u8981\u4f1a\u7ed9\u5927\u5bb6\u8bb2\u5230\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\u6570\u636e\u5e93\u76f8\u5173\u7684\u5185\u5bb9\uff0c\u5e0c\u671b\u5bf9\u5927\u5bb6\u90fd\u6709\u6240\u5e2e\u52a9\uff01 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 linux \u5b89\u88c5redis linux \u5b89\u88c5redis \u975e\u5e38\u7b80\u5355\uff0c\u5b98\u7f51\u6709\u4ecb\u7ecd\u3002 \u5b89\u88c5redis\uff1a 1.\u5148\u67e5\u770bredis\u7248\u672c 2.\u5b89\u88c5redis #2.1 \u4e0b\u8f7d\u5b89\u88c5\u5305 wget http:\/\/download.redis.io\/releases\/redis-4.0.8.tar.gz #2.2 \u89e3\u538b tar zxf redis-4.0.8.tar.gz 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 #2.3\u7f16\u8bd1 cd redis-4.0.8\/src make undefined #2.4 \u65b0\u5efaredis\u6587\u4ef6\u5939 mkdir \/usr\/local\/redis #2.5\u79fb\u52a8\u6587\u4ef6 cd&nbsp;redis-4.0.8\/src mv&nbsp;redis-server&nbsp;\/usr\/local\/redis mv&nbsp;redis-benchmark&nbsp;\/usr\/local\/redis mv&nbsp;redis-cli&nbsp;\/usr\/local\/redis cd&nbsp;..\/ mv&nbsp;redis.conf&nbsp;\/usr\/local\/redis #2.6 \u542f\u52a8redis cd \/usr\/local\/redis .\/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 \u5982\u4e0a\u56fe\u6240\u793a\uff0c\u6309\u914d\u7f6e\u6587\u4ef6\u542f\u52a8\uff0c\u63d0\u793a\u542f\u52a8\u6210\u529f\u3002 \u53ef\u80fd\u51fa\u73b0\u7684\u8b66\u544a\uff1a [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[],"class_list":["post-46043","post","type-post","status-publish","format-standard","hentry","category-os"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/46043","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=46043"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/46043\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=46043"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=46043"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=46043"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}