{"id":3708,"date":"2019-01-10T16:15:13","date_gmt":"2019-01-10T08:15:13","guid":{"rendered":"http:\/\/www.xttblog.com\/?p=3708"},"modified":"2019-01-10T16:15:13","modified_gmt":"2019-01-10T08:15:13","slug":"%e4%bd%bf%e7%94%a8-redis-%e7%9a%84-slowlog-get-n-%e6%85%a2%e6%9f%a5%e8%af%a2%e6%97%a5%e5%bf%97%e5%bd%bb%e5%ba%95%e8%a7%a3%e5%86%b3%e7%94%9f%e4%ba%a7%e9%97%ae%e9%a2%98%ef%bc%81","status":"publish","type":"post","link":"https:\/\/www.xttblog.com\/?p=3708","title":{"rendered":"\u4f7f\u7528 Redis \u7684 slowlog get [n] \u6162\u67e5\u8be2\u65e5\u5fd7\u5f7b\u5e95\u89e3\u51b3\u751f\u4ea7\u95ee\u9898\uff01"},"content":{"rendered":"<p>\n\t\u6216\u591a\u6216\u5c11\uff0c\u4f60\u4eec\u53ef\u80fd\u542c\u8fc7 MySQL \u7684\u6162\u67e5\u8be2\u65e5\u5fd7\u3002\u5176\u5b9e Redis \u4e5f\u6709\uff0c\u800c\u4e14 Redis \u7684\u6162\u67e5\u8be2\u65e5\u5fd7\u5bf9\u6027\u80fd\u7684\u5f71\u54cd\u5f88\u5c0f\uff0c\u56e0\u4e3a\u5b83\u5c31\u4fdd\u5b58\u5728\u5185\u5b58\u4e2d\u3002\n<\/p>\n<p>\n\tslowlog \u662f Redis \u7528\u6765\u8bb0\u5f55\u67e5\u8be2\u6267\u884c\u65f6\u95f4\u7684\u65e5\u5fd7\u7cfb\u7edf\u3002\u6ce8\u610f\uff0c\u8fd9\u4e2a\u67e5\u8be2\u6267\u884c\u65f6\u95f4\u6307\u7684\u662f\u4e0d\u5305\u62ec\u50cf\u5ba2\u6237\u7aef\u54cd\u5e94(talking)\u3001\u53d1\u9001\u56de\u590d\u7b49 IO \u64cd\u4f5c\uff0c\u800c\u5355\u5355\u662f\u6267\u884c\u4e00\u4e2a\u67e5\u8be2\u547d\u4ee4\u6240\u8017\u8d39\u7684\u65f6\u95f4\u3002&nbsp;\n<\/p>\n<p>\n\t<img decoding=\"async\" alt=\"Redis \u7684\u6162\u67e5\u8be2\u65e5\u5fd7\" src=\"https:\/\/images.weserv.nl\/?url=https:\/\/wx1.sinaimg.cn\/large\/8fa5dcfcgy1fz1k0suucxj20mm09o41c.jpg\" style=\"width: 814px;height: 348px\" \/>\n<\/p>\n<p>\n\tslowlog \u4fdd\u5b58\u5728\u5185\u5b58\u91cc\u9762\uff0c\u8bfb\u5199\u901f\u5ea6\u975e\u5e38\u5feb\uff0c\u56e0\u6b64\u6211\u4eec\u53ef\u4ee5\u653e\u5fc3\u5730\u4f7f\u7528\u5b83\uff0c\u4e0d\u5fc5\u62c5\u5fc3\u56e0\u4e3a\u5f00\u542f slowlog \u800c\u635f\u5bb3 Redis \u7684\u901f\u5ea6\u3002\n<\/p>\n<p>\n\tslowlog \u6709\u4e24\u4e2a\u91cd\u8981\u7684\u914d\u7f6e\uff0c\u6211\u4eec\u5148\u901a\u8fc7 CONFIG GET slowlog-* \u547d\u4ee4\u6765\u67e5\u770b\u73b0\u6709\u7684\u914d\u7f6e\u3002\n<\/p>\n<pre class=\"brush:bash;\">\r\n127.0.0.1:6379&gt; CONFIG GET slowlog-*\r\n1) &quot;slowlog-log-slower-than&quot;\r\n2) &quot;100&quot;\r\n3) &quot;slowlog-max-len&quot;\r\n4) &quot;1024&quot;<\/pre>\n<p>\n\tslowlog-log-slower-than \u4ee3\u8868\u6162\u67e5\u8be2\u7684\u9608\u503c\uff0c\u5355\u4f4d\u4e3a\uff1a\u5fae\u79d2\u3002\u5f53\u6267\u884c\u67e5\u8be2\u547d\u4ee4\u6d88\u8017\u65f6\u95f4\u5927\u4e8e\u914d\u7f6e\u7684\u9608\u503c\u65f6\uff0c\u4f1a\u5c06\u8be5\u6761\u547d\u4ee4\u8bb0\u5f55\u5230\u6162\u67e5\u8be2\u65e5\u5fd7\u3002\u5f53 slowlog-log-slower-than=0 \u65f6\uff0c\u8bb0\u5f55\u6240\u6709\u547d\u4ee4\u3002slowlog-log-slower-than&lt;0 \u65f6\uff0c\u4e0d\u8bb0\u5f55\u4efb\u4f55\u547d\u4ee4\u3002slowlog-log-slower-than \u7684\u9ed8\u8ba4\u503c\u4e3a 10000 \uff0810\u6beb\u79d2\uff0c1\u79d2 = 1,000\u6beb\u79d2 = 1,000,000\u5fae\u79d2\uff09\u3002\n<\/p>\n<p>\n\tslowlog-max-len \u4ee3\u8868\u6162\u67e5\u8be2\u65e5\u5fd7\u6700\u5927\u6761\u6570\u3002\u5b83\u662f\u4e00\u4e2a\u961f\u5217\u5f62\u5f0f\u7684\u5b58\u50a8\u7ed3\u6784\uff0c\u5148\u8fdb\u5148\u51fa\u7684\u961f\u5217\uff0c\u5373\u5f53\u6162\u67e5\u8be2\u65e5\u5fd7\u8fbe\u5230\u6700\u5927\u6761\u6570\u540e\uff0c\u4f1a\u9500\u6bc1\u6700\u65e9\u8bb0\u5f55\u7684\u65e5\u5fd7\u6761\u76ee\u3002slowlog-max-len \u7684\u9ed8\u8ba4\u503c\u4e3a 128\uff0c\u4fdd\u5b58\u5728\u5185\u5b58\u5185\uff0c\u6240\u4ee5\u91cd\u542f redis \u4f1a\u6e05\u7a7a\u6162\u67e5\u8be2\u65e5\u5fd7\u3002\n<\/p>\n<p>\n\t\u914d\u7f6e slowlog-log-slower-than \u548c slowlog-max-len \u7684\u547d\u4ee4\u975e\u5e38\u7b80\u5355\uff0c\u5982\u4e0b\uff1a\n<\/p>\n<pre class=\"brush:bash;\">\r\nCONFIG SET slowlog-log-slower-than 100\r\nCONFIG SET slowlog-max-len 1024<\/pre>\n<p>\n\t\u4f7f\u7528 SLOWLOG LEN \u547d\u4ee4\uff0c\u67e5\u8be2\u5f53\u524d\u7684\u6162\u67e5\u8be2\u65e5\u5fd7\u8bb0\u5f55\u6570\u3002\n<\/p>\n<pre class=\"brush:bash;\">\r\n127.0.0.1:6379&gt; SLOWLOG LEN\r\n(integer) 2019<\/pre>\n<p>\n\t\u5f53\u6211\u4eec\u53ea\u9700\u8981\u67e5\u8be2\u524d\u51e0\u4e2a\u6162\u67e5\u8be2\u8bb0\u5f55\u65f6\uff0c\u53ef\u4ee5\u4f7f\u7528 SLOWLOG GET [n] \u547d\u4ee4\u3002\n<\/p>\n<pre class=\"brush:bash;\">\r\n127.0.0.1:6379&gt; SLOWLOG GET 3\r\n1) 1) (integer) 14                # \u552f\u4e00\u6027(unique)\u7684\u65e5\u5fd7\u6807\u8bc6\u7b26\r\n   2) (integer) 1522808219        # \u88ab\u8bb0\u5f55\u547d\u4ee4\u7684\u6267\u884c\u65f6\u95f4\u70b9\uff0c\u4ee5 UNIX \u65f6\u95f4\u6233\u683c\u5f0f\u8868\u793a\r\n   3) (integer) 16                # \u67e5\u8be2\u6267\u884c\u65f6\u95f4\uff0c\u4ee5\u5fae\u79d2\u4e3a\u5355\u4f4d\r\n   4) 1) &quot;keys&quot;                   # \u6267\u884c\u7684\u547d\u4ee4\uff0c\u4ee5\u6570\u7ec4\u7684\u5f62\u5f0f\u6392\u5217\r\n      2) &quot;*&quot;                      # \u8fd9\u91cc\u5b8c\u6574\u7684\u547d\u4ee4\u662f &quot;keys *&quot;\r\n2) 1) (integer) 13\r\n   2) (integer) 1522808215\r\n   3) (integer) 7\r\n   4) 1) &quot;set&quot;\r\n      2) &quot;name&quot;\r\n      3) &quot;baicai&quot;\r\n3) 1) (integer) 12\r\n   2) (integer) 1522808198\r\n   3) (integer) 101\r\n   4) 1) &quot;set&quot;\r\n      2) &quot;age&quot;\r\n      3) &quot;25&quot;<\/pre>\n<p>\n\tSLOWLOG GET [n] \u82e5\u4e0d\u52a0 n ,\u5219\u83b7\u53d6\u5168\u90e8\u6162\u67e5\u8be2\u8bb0\u5f55\u3002\n<\/p>\n<p>\n\t\u6e05\u7a7a\u6162\u67e5\u8be2\u65e5\u5fd7\u4f7f\u7528 SLOWLOG RESET\u3002\u6ce8\u610f\uff0cslowlog-log-slower-than \u4e0d\u8981\u8bbe\u7f6e\u8fc7\u5927\uff0c\u8bbe\u7f6e\u8fc7\u5927\u6709\u53ef\u80fd\u4e00\u6761\u8bb0\u5f55\u4e5f\u4e0d\u4f1a\u8bb0\u5f55\u3002<\/p>\n<!-- <audio autoplay=\"autoplay\" height=\"100\" width=\"100\" hidden=\"true\"><source src=\"https:\/\/c.coka.la\/orAvPR.mp3\" type=\"audio\/mp3\"\/><\/audio><img decoding=\"async\" src=\"https:\/\/images.weserv.nl\/?url=https:\/\/ws3.sinaimg.cn\/large\/8fa5dcfcgy1g4em3rzar5j20ib089ae0.jpg\" alt=\"\u4e1a\u4f59\u8349\u516c\u4f17\u53f7\"\/> --><p><!-- <img decoding=\"async\" src=\"https:\/\/raw.githubusercontent.com\/xmt1139057136\/xttblog\/master\/8fa5dcfcgy1g4em3rzar5j20ib089ae0.jpg\" alt=\"\u4e1a\u4f59\u8349\u516c\u4f17\u53f7\"\/>--><img decoding=\"async\" src=\"https:\/\/saas.51autoparts.cn\/api\/admin\/sys-file\/oss\/file?fileName=84db51f8561e448f9a4fda2eff0811f9.jpg\" alt=\"\u4e1a\u4f59\u8349\u516c\u4f17\u53f7\"\/><\/p><p>\u6700\u540e\uff0c\u6b22\u8fce\u5173\u6ce8\u6211\u7684\u4e2a\u4eba\u5fae\u4fe1\u516c\u4f17\u53f7\uff1a\u4e1a\u4f59\u8349\uff08yyucao\uff09\uff01<b>\u53ef\u52a0\u4f5c\u8005\u5fae\u4fe1\u53f7\uff1a<font color=\"red\">xttblog2<\/font>\u3002\u5907\u6ce8\uff1a\u201c1\u201d\uff0c\u6dfb\u52a0\u535a\u4e3b\u5fae\u4fe1\u62c9\u4f60\u8fdb\u5fae\u4fe1\u7fa4\u3002\u5907\u6ce8\u9519\u8bef\u4e0d\u4f1a\u540c\u610f\u597d\u53cb\u7533\u8bf7\u3002<\/b>\u518d\u6b21\u611f\u8c22\u60a8\u7684\u5173\u6ce8\uff01\u540e\u7eed\u6709\u7cbe\u5f69\u5185\u5bb9\u4f1a\u7b2c\u4e00\u65f6\u95f4\u53d1\u7ed9\u60a8\uff01\u539f\u521b\u6587\u7ae0\u6295\u7a3f\u8bf7\u53d1\u9001\u81f3532009913@qq.com\u90ae\u7bb1\u3002\u5546\u52a1\u5408\u4f5c\u4e5f\u53ef\u6dfb\u52a0\u4f5c\u8005\u5fae\u4fe1\u8fdb\u884c\u8054\u7cfb\uff01<\/p><p>\u672c\u6587\u539f\u6587\u51fa\u5904\uff1a<a href=\"https:\/\/www.xttblog.com\">\u4e1a\u4f59\u8349<\/a>\uff1a &raquo; <a href=\"https:\/\/www.xttblog.com\/?p=3708\">\u4f7f\u7528 Redis \u7684 slowlog get [n] \u6162\u67e5\u8be2\u65e5\u5fd7\u5f7b\u5e95\u89e3\u51b3\u751f\u4ea7\u95ee\u9898\uff01<\/a><\/p><!-- <div class=\"bd-reward-stl\"><button id=\"bdRewardBtn\"><span><\/span><\/button><\/div> -->","protected":false},"excerpt":{"rendered":"<p>\u6216\u591a\u6216\u5c11\uff0c\u4f60\u4eec\u53ef\u80fd\u542c\u8fc7 MySQL \u7684\u6162\u67e5\u8be2\u65e5\u5fd7\u3002\u5176\u5b9e Redis \u4e5f\u6709\uff0c\u800c\u4e14 Redis \u7684\u6162\u67e5\u8be2\u65e5\u5fd7\u5bf9\u6027\u80fd [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6],"tags":[97,669,672,1342,1880],"class_list":["post-3708","post","type-post","status-publish","format-standard","hentry","category-yyzt","tag-mysqldumpslow","tag-redis","tag-redis-cluster","tag-redis-cli","tag-1880"],"_links":{"self":[{"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts\/3708","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3708"}],"version-history":[{"count":1,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts\/3708\/revisions"}],"predecessor-version":[{"id":3709,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts\/3708\/revisions\/3709"}],"wp:attachment":[{"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3708"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3708"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3708"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}