{"id":6268,"date":"2024-11-14T13:50:43","date_gmt":"2024-11-14T05:50:43","guid":{"rendered":"https:\/\/fwq.ai\/blog\/6268\/"},"modified":"2024-11-14T13:50:43","modified_gmt":"2024-11-14T05:50:43","slug":"%e6%80%8e%e6%a0%b7%e6%9f%a5%e7%9c%8bredis%e6%97%a5%e5%bf%97","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/6268\/","title":{"rendered":"\u600e\u6837\u67e5\u770bredis\u65e5\u5fd7"},"content":{"rendered":"<blockquote><p>\n  redis \u65e5\u5fd7\u6587\u4ef6\u901a\u5e38\u4f4d\u4e8e\/var\/log\/redis\/redis-server.log\u6216\/ edis.log\u3002\u60a8\u53ef\u4ee5\u4f7f\u7528\u547d\u4ee4\u884c\u5de5\u5177\uff08\u5982 tail -f redis-server.log\uff09\u67e5\u770b\u65e5\u5fd7\u3002\u9ed8\u8ba4\u65e5\u5fd7\u7ea7\u522b\u4e3a &#8220;verbose&#8221;\uff0c\u53ef\u901a\u8fc7\u4fee\u6539 redis.conf \u914d\u7f6e\u6587\u4ef6\u8fdb\u884c\u66f4\u6539\u3002redis \u4e5f\u652f\u6301\u65e5\u5fd7\u5206\u79bb\uff0c\u5141\u8bb8\u5c06\u65e5\u5fd7\u8bb0\u5f55\u5230\u591a\u4e2a\u6587\u4ef6\u4e2d\u3002\n<\/p><\/blockquote>\n<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/202406\/21\/2024062109132050803.jpg\" class=\"aligncenter\" title=\"\u600e\u6837\u67e5\u770bredis\u65e5\u5fd7\u63d2\u56fe\" alt=\"\u600e\u6837\u67e5\u770bredis\u65e5\u5fd7\u63d2\u56fe\" \/><\/p>\n<h2>\u5982\u4f55\u67e5\u770b Redis \u65e5\u5fd7<\/h2>\n<p>Redis \u7684\u65e5\u5fd7\u8bb0\u5f55\u529f\u80fd\u53ef\u4ee5\u5e2e\u52a9\u7528\u6237\u5feb\u901f\u627e\u51fa\u95ee\u9898\u548c\u89e3\u51b3\u9519\u8bef\u3002\u4ee5\u4e0b\u662f\u67e5\u770b Redis \u65e5\u5fd7\u7684\u6b65\u9aa4\uff1a<\/p>\n<p><strong>1. \u67e5\u627e Redis \u65e5\u5fd7\u6587\u4ef6<\/strong><\/p>\n<p>\u901a\u5e38\u60c5\u51b5\u4e0b\uff0cRedis \u7684\u65e5\u5fd7\u6587\u4ef6\u4f4d\u4e8e\u4ee5\u4e0b\u4f4d\u7f6e\uff1a<\/p>\n<ul>\n<li> <strong>Linux\/macOS\uff1a<\/strong>\/var\/log\/\/redis-server.log<\/li>\n<li> <strong>Windows\uff1a<\/strong>\/ edis.log <\/li>\n<\/ul>\n<p><strong>2. \u4f7f\u7528\u547d\u4ee4\u884c\u5de5\u5177\u67e5\u770b\u65e5\u5fd7<\/strong><\/p>\n<p>\u6253\u5f00\u547d\u4ee4\u884c\u7ec8\u7aef\uff08\u5982 Terminal \u6216 PowerShell\uff09\uff0c\u5e76\u5bfc\u822a\u5230\u65e5\u5fd7\u6587\u4ef6\u6240\u5728\u7684\u76ee\u5f55\u3002\u7136\u540e\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u67e5\u770b\u65e5\u5fd7\uff1a<\/p>\n<pre>tail -f redis-server.log<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>3. \u914d\u7f6e\u65e5\u5fd7\u7ea7\u522b<\/strong><\/p>\n<p>\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0cRedis \u4ee5 &#8220;verbose&#8221; \u7ea7\u522b\u8bb0\u5f55\u65e5\u5fd7\u3002\u4f60\u53ef\u4ee5\u901a\u8fc7\u4fee\u6539 redis.conf \u914d\u7f6e\u6587\u4ef6\u6765\u66f4\u6539\u65e5\u5fd7\u7ea7\u522b\u3002\u4ee5\u4e0b\u662f\u4e00\u4e9b\u5e38\u7528\u7684\u65e5\u5fd7\u7ea7\u522b\uff1a<\/p>\n<ul>\n<li> <strong>debug\uff1a<\/strong> \u8bb0\u5f55\u6240\u6709\u8c03\u8bd5\u4fe1\u606f<\/li>\n<li> <strong>verbose\uff1a<\/strong> \u8bb0\u5f55\u6240\u6709\u9519\u8bef\u3001\u8b66\u544a\u548c\u901a\u77e5\u4fe1\u606f<\/li>\n<li> <strong>notice\uff1a<\/strong> \u8bb0\u5f55\u6240\u6709\u975e\u8c03\u8bd5\u4fe1\u606f<\/li>\n<li> <strong>warning\uff1a<\/strong> \u8bb0\u5f55\u6240\u6709\u8b66\u544a\u548c\u9519\u8bef\u4fe1\u606f<\/li>\n<li> <strong>error\uff1a<\/strong> \u53ea\u8bb0\u5f55\u9519\u8bef\u4fe1\u606f<\/li>\n<\/ul>\n<p><strong>4. \u5206\u79bb\u65e5\u5fd7<\/strong><\/p>\n<p>Redis \u4e5f\u5141\u8bb8\u4f60\u5c06\u65e5\u5fd7\u8bb0\u5f55\u5230\u591a\u4e2a\u6587\u4ef6\u6216 destination \u4e2d\u3002\u4f8b\u5982\uff0c\u4f60\u53ef\u4ee5\u5c06\u9519\u8bef\u65e5\u5fd7\u8bb0\u5f55\u5230\u4e00\u4e2a\u6587\u4ef6\uff0c\u800c\u5c06\u6162\u67e5\u8be2\u65e5\u5fd7\u8bb0\u5f55\u5230\u53e6\u4e00\u4e2a\u6587\u4ef6\u3002<\/p>\n<p>\u8981\u5728 redis.conf \u4e2d\u542f\u7528\u65e5\u5fd7\u5206\u79bb\uff0c\u8bf7\u6dfb\u52a0\u4ee5\u4e0b\u884c\uff1a<\/p>\n<pre>slowlog-log-slower-than 10000\nslowlog-max-len 128<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u8fd9\u5c06\u8bb0\u5f55\u6240\u6709\u6267\u884c\u65f6\u95f4\u8d85\u8fc7 10 \u6beb\u79d2\u7684\u6162\u67e5\u8be2\u3002\u6162\u67e5\u8be2\u65e5\u5fd7\u5c06\u4fdd\u5b58\u5728 <strong>\/var\/log\/redis\/slow.log<\/strong> \u6587\u4ef6\u4e2d\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u600e\u6837\u67e5\u770b\u65e5\u5fd7\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u7f51\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>redis \u65e5\u5fd7\u6587\u4ef6\u901a\u5e38\u4f4d\u4e8e\/var\/log\/redis\/redis-server.log\u6216\/ edis.log\u3002\u60a8\u53ef\u4ee5\u4f7f\u7528\u547d\u4ee4\u884c\u5de5\u5177\uff08\u5982 tail -f redis-server.log\uff09\u67e5\u770b\u65e5\u5fd7\u3002\u9ed8\u8ba4\u65e5\u5fd7\u7ea7\u522b\u4e3a &#8220;verbose&#8221;\uff0c\u53ef\u901a\u8fc7\u4fee\u6539 redis.conf \u914d\u7f6e\u6587\u4ef6\u8fdb\u884c\u66f4\u6539\u3002redis \u4e5f\u652f\u6301\u65e5\u5fd7\u5206\u79bb\uff0c\u5141\u8bb8\u5c06\u65e5\u5fd7\u8bb0\u5f55\u5230\u591a\u4e2a\u6587\u4ef6\u4e2d\u3002 \u5982\u4f55\u67e5\u770b Redis \u65e5\u5fd7 Redis \u7684\u65e5\u5fd7\u8bb0\u5f55\u529f\u80fd\u53ef\u4ee5\u5e2e\u52a9\u7528\u6237\u5feb\u901f\u627e\u51fa\u95ee\u9898\u548c\u89e3\u51b3\u9519\u8bef\u3002\u4ee5\u4e0b\u662f\u67e5\u770b Redis \u65e5\u5fd7\u7684\u6b65\u9aa4\uff1a 1. \u67e5\u627e Redis \u65e5\u5fd7\u6587\u4ef6 \u901a\u5e38\u60c5\u51b5\u4e0b\uff0cRedis \u7684\u65e5\u5fd7\u6587\u4ef6\u4f4d\u4e8e\u4ee5\u4e0b\u4f4d\u7f6e\uff1a Linux\/macOS\uff1a\/var\/log\/\/redis-server.log Windows\uff1a\/ edis.log 2. \u4f7f\u7528\u547d\u4ee4\u884c\u5de5\u5177\u67e5\u770b\u65e5\u5fd7 \u6253\u5f00\u547d\u4ee4\u884c\u7ec8\u7aef\uff08\u5982 Terminal \u6216 PowerShell\uff09\uff0c\u5e76\u5bfc\u822a\u5230\u65e5\u5fd7\u6587\u4ef6\u6240\u5728\u7684\u76ee\u5f55\u3002\u7136\u540e\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u67e5\u770b\u65e5\u5fd7\uff1a tail -f redis-server.log \u767b\u5f55\u540e\u590d\u5236 3. \u914d\u7f6e\u65e5\u5fd7\u7ea7\u522b \u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0cRedis \u4ee5 &#8220;verbose&#8221; \u7ea7\u522b\u8bb0\u5f55\u65e5\u5fd7\u3002\u4f60\u53ef\u4ee5\u901a\u8fc7\u4fee\u6539 redis.conf \u914d\u7f6e\u6587\u4ef6\u6765\u66f4\u6539\u65e5\u5fd7\u7ea7\u522b\u3002\u4ee5\u4e0b\u662f\u4e00\u4e9b\u5e38\u7528\u7684\u65e5\u5fd7\u7ea7\u522b\uff1a debug\uff1a \u8bb0\u5f55\u6240\u6709\u8c03\u8bd5\u4fe1\u606f verbose\uff1a \u8bb0\u5f55\u6240\u6709\u9519\u8bef\u3001\u8b66\u544a\u548c\u901a\u77e5\u4fe1\u606f notice\uff1a \u8bb0\u5f55\u6240\u6709\u975e\u8c03\u8bd5\u4fe1\u606f warning\uff1a \u8bb0\u5f55\u6240\u6709\u8b66\u544a\u548c\u9519\u8bef\u4fe1\u606f error\uff1a \u53ea\u8bb0\u5f55\u9519\u8bef\u4fe1\u606f 4. [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"class_list":["post-6268","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/6268","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=6268"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/6268\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=6268"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=6268"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=6268"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}