{"id":1895,"date":"2021-07-31T12:06:39","date_gmt":"2021-07-31T12:06:39","guid":{"rendered":"https:\/\/www.ipcpu.com\/?p=1895"},"modified":"2022-07-31T12:07:22","modified_gmt":"2022-07-31T12:07:22","slug":"redis-monitor-3","status":"publish","type":"post","link":"https:\/\/c.ipcpu.com\/2021\/07\/redis-monitor-3\/","title":{"rendered":"Redis\u4e2dmonitor\u547d\u4ee4\u89e3\u8bfb"},"content":{"rendered":"
<\/div>\n

<\/p>\n

\u4e00\u3001Redis MONITOR\u547d\u4ee4\u6982\u8ff0<\/h2>\n

Redis\u4e2dMONITOR\u547d\u4ee4\u7528\u4e8e\u5b9e\u65f6\u6253\u5370\u51fa Redis \u670d\u52a1\u5668\u63a5\u6536\u5230\u7684\u547d\u4ee4\u3002
\n\u5b83\u7684\u8fd4\u56de\u503c\u603b\u662fOK\u3002<\/p>\n

\u4e8c\u3001Redis MONITOR\u547d\u4ee4\u7684\u6267\u884c\u7ed3\u679c<\/h2>\n
\n
127.0.0.1:6379> MONITOR\nOK\n1648778398.868239 [0 10.193.0.200:48530] \"HGETALL\" \"PUSH.DeviceFull:I:114338169\"\n1648778398.868294 [0 10.193.49.226:35128] \"GET\" \"PUSH.DevicePidInfo:S:80D-002B675E9BD8\"\n1648778398.871154 [0 10.193.0.211:49272] \"GET\" \"PUSH.DevicePidInfo:S:867363029034364\"<\/code><\/pre>\n<\/div>\n

\u4ed6\u7684\u8fd4\u56de\u7ed3\u679c\u6709\u4e09\u4e2a\u90e8\u5206\uff1a<\/p>\n

\n

\u65f6\u95f4\uff0c\u683c\u5f0fseconds.microseconds \u79d2(\u65f6\u95f4\u6233).\u5fae\u79d2
\n \u6570\u636e\u5e93\u540d\u79f0\u3001\u5ba2\u6237\u7aefIP\u548c\u7aef\u53e3
\n \u6267\u884c\u7684\u547d\u4ee4<\/p>\n<\/blockquote>\n

\u65f6\u95f4\u53ea\u6709\u4e00\u4e2a\uff0c\u90a3\u5c31\u5f88\u7591\u60d1\u4e86\uff0c\u90a3\u8fd9\u4e2a\u662f\u5f00\u59cb\u65f6\u95f4\u3001\u7ed3\u675f\u65f6\u95f4\uff1f \u6bcf\u4e2a\u547d\u4ee4\u6267\u884c\u82b1\u8d39\u4e86\u591a\u5c11\u65f6\u95f4\uff1f
\n\u7ecf\u8fc7\u4e00\u756a\u8d44\u6599\u67e5\u627e\uff0c\u6211\u4eec\u7ec8\u4e8e\u627e\u5230\u4e86\uff1a
\nOne caveat on timing: MONITOR only shows the time a command completed, not when it started. On a very busy Redis server (like most of ours), this is fine because there\u2019s always a request waiting to execute, but if you\u2019re at a lesser rate of requests, the time taken will not be accurate.
\nMONITOR\u4e2d\u7684\u65f6\u95f4\u662f\u6267\u884c\u7ed3\u675f\u7684\u65f6\u95f4\uff0c\u7531\u4e8eRedis\u662f\u5355\u7ebf\u7a0b\u6267\u884c\u7684\uff0c\u6267\u884c\u5b8c\u4e00\u4e2a\u547d\u4ee4\uff0c\u518d\u53bb\u6267\u884c\u53e6\u5916\u4e00\u4e2a\u3002
\n\u6240\u4ee5\u4f7f\u7528\u672c\u6b21\u7684\u65f6\u95f4\u51cf\u53bb\u4e0a\u6b21\u7684\u65f6\u95f4\uff0c\u5c31\u662f\u672c\u6b21\u547d\u4ee4\u7684\u6267\u884c\u82b1\u8d39\u65f6\u95f4\u3002
\n\u8fd9\u79cd\u8ba1\u7b97\u65b9\u5f0f\uff0c\u5bf9\u4e8e\u6bd4\u8f83\u7e41\u5fd9\u7684Redis\u670d\u52a1\u5668\u6765\u8bf4\uff0c\u76f8\u5bf9\u6bd4\u8f83\u51c6\u786e\uff0c\u4f46\u662f\u5bf9\u4e8e\u6bd4\u8f83\u7a7a\u95f2\u7684Redis\u5c31\u6ca1\u5565\u53c2\u8003\u610f\u4e49\u4e86\u3002<\/p>\n

\u4e09\u3001Redis MONITOR\u5bf9\u4e8e\u6027\u80fd\u7684\u635f\u8017<\/h2>\n

Redis MONITOR\u5f00\u542f\u4e4b\u540e\uff0c\u5bf9Redis\u6027\u80fd\u6709\u4e00\u5b9a\u7684\u5f71\u54cd\uff0c\u5b98\u65b9\u8bf4\u5927\u698230%\u5de6\u53f3\u3002
\n\u56e0\u6b64\u751f\u4ea7\u73af\u5883\u4e0d\u8981\u957f\u671f\u5f00\u542f\uff0c\u53ef\u4ee5\u4ec5\u5728\u6392\u9664\u6545\u969c\u65f6\u4f7f\u7528\u3002<\/p>\n

\u56db\u3001Redis MONITOR\u7684\u642d\u6863redis-faina<\/h2>\n

redis-faina\u662f\u4e00\u4e2a\u901a\u8fc7\u89e3\u6790redis\u7684MONITOR\u547d\u4ee4\uff0c\u4ece\u800c\u5bf9redis\u5b9e\u4f8b\u8fdb\u884c\u6027\u80fd\u8bca\u65ad\u7684\u5de5\u5177\u3002python2\u7f16\u5199\uff0c\u53ea\u6709\u4e00\u4e2a\u6587\u4ef6\uff0c\u77ed\u5c0f\u7cbe\u608d\u3002\u6bd4\u8f83\u5b9e\u7528\uff0c\u662f\u4e00\u6b3e\u6392\u9519\u65f6\u4f7f\u7528\u7684\u826f\u54c1\u3002\u4f7f\u7528\u65b9\u6cd5\u5982\u4e0b\uff1a<\/p>\n

\n
$ redis-cli -p 6379 MONITOR > m.log\n$ .\/redis-faina.py .\/m.log<\/code><\/pre>\n<\/div>\n

redis-faina\u53ef\u4ee5\u5206\u6790\u51faRedisQPS\u3001\u6700\u591a\u8bbf\u95ee\u7684\u524d\u7f00\u3001\u8bbf\u95ee\u6b21\u6570\u6700\u591a\u7684key\u3001\u4f7f\u7528\u7684\u6700\u591a\u7684\u547d\u4ee4\u3001\u8bf7\u6c42\u7684\u54cd\u5e94\u65f6\u95f4\u5206\u5e03\u3001\u8017\u65f6\u6700\u591a\u7684\u547d\u4ee4\u3001\u6162\u8bf7\u6c42\u5217\u8868\u7b49\u6570\u636e\u3002\u672c\u7ad9\u5f88\u65e9\u4e4b\u524d\u7684Redis\u76d1\u63a7\u4e2d\u5c31\u6709\u4ecb\u7ecd\u3002<\/p>\n

\u8f6c\u8f7d\u8bf7\u6ce8\u660e\uff1aIPCPU-\u7f51\u7edc\u4e4b\u8def<\/a> » Redis\u4e2dmonitor\u547d\u4ee4\u89e3\u8bfb<\/a><\/p>","protected":false},"excerpt":{"rendered":"

\u4e00\u3001Redis MONITOR\u547d\u4ee4\u6982\u8ff0 Redis\u4e2dMONITOR\u547d\u4ee4\u7528\u4e8e\u5b9e\u65f6\u6253\u5370\u51fa Redis \u670d\u52a1\u5668\u63a5\u6536\u5230\u7684\u547d\u4ee4\u3002 \u5b83\u7684\u8fd4\u56de\u503c\u603b\u662fOK\u3002 \u4e8c\u3001Redis MONITOR\u547d\u4ee4\u7684\u6267\u884c\u7ed3\u679c 127.0.0.1:6379> MONITOR OK 1648778398.868239 [0 10.193.0.200:48530] “HGETALL” “PUSH.DeviceFull:I:114338169” 1648778398.868294 [0 10.193.49.226:35128] “GET” “PUSH.DevicePidInfo:S:80D-002B675E9BD8” 1648778398.871154 [0 10.193.0.211:49272] “GET” “PUSH.DevicePidInfo:S:867363029034364” \u4ed6\u7684\u8fd4\u56de\u7ed3\u679c\u6709\u4e09\u4e2a\u90e8\u5206\uff1a \u65f6\u95f4\uff0c\u683c\u5f0fseconds.microseconds \u79d2(\u65f6\u95f4\u6233).\u5fae\u79d2 \u6570\u636e\u5e93\u540d\u79f0\u3001\u5ba2\u6237\u7aefIP\u548c\u7aef\u53e3 \u6267\u884c\u7684\u547d\u4ee4 \u65f6\u95f4\u53ea\u6709\u4e00\u4e2a\uff0c\u90a3\u5c31\u5f88\u7591\u60d1\u4e86\uff0c\u90a3\u8fd9\u4e2a\u662f\u5f00\u59cb\u65f6\u95f4\u3001\u7ed3\u675f\u65f6\u95f4\uff1f \u6bcf\u4e2a\u547d\u4ee4\u6267\u884c\u82b1\u8d39\u4e86\u591a\u5c11\u65f6\u95f4\uff1f \u7ecf\u8fc7\u4e00\u756a\u8d44\u6599\u67e5\u627e\uff0c\u6211\u4eec\u7ec8\u4e8e\u627e\u5230\u4e86\uff1a One caveat on timing: MONITOR only shows the time a command completed, not when it started. On a very busy Redis […]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[3],"tags":[142],"_links":{"self":[{"href":"https:\/\/c.ipcpu.com\/wp-json\/wp\/v2\/posts\/1895"}],"collection":[{"href":"https:\/\/c.ipcpu.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/c.ipcpu.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/c.ipcpu.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/c.ipcpu.com\/wp-json\/wp\/v2\/comments?post=1895"}],"version-history":[{"count":1,"href":"https:\/\/c.ipcpu.com\/wp-json\/wp\/v2\/posts\/1895\/revisions"}],"predecessor-version":[{"id":1896,"href":"https:\/\/c.ipcpu.com\/wp-json\/wp\/v2\/posts\/1895\/revisions\/1896"}],"wp:attachment":[{"href":"https:\/\/c.ipcpu.com\/wp-json\/wp\/v2\/media?parent=1895"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/c.ipcpu.com\/wp-json\/wp\/v2\/categories?post=1895"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/c.ipcpu.com\/wp-json\/wp\/v2\/tags?post=1895"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}