mongostat 一屏的列该怎么读?数字准不准?mongotop 看到的又是什么?这篇用已知负载逐列对照。
$ mongostat --host 127.0.0.1:9901 --rowcount 3 1
insert query update delete getmore command dirty used flushes vsize res qrw arw net_in net_out conn time
*0 *0 *0 *0 0 0|0 0.3% 1.4% 0 467G 138M 0|0 0|0 111b 168k 8 <时间>
*0 *0 *0 *0 0 1|0 0.3% 1.4% 0 467G 138M 0|0 0|0 112b 170k 8 <时间>
*0 *0 *0 *0 0 1|0 0.3% 1.4% 0 467G 138M 0|0 0|0 112b 170k 8 <时间>空闲时 insert/query/update/delete 写 *0,dirty/used 是缓存比例,vsize/res 是内存,net_out 仍有约 170 KB/秒(推测是 mongostat 自己取 serverStatus 的响应)。
$ mongostat --host 127.0.0.1:9901 --rowcount 4 1
insert query update delete getmore command dirty used flushes vsize res qrw arw net_in net_out conn time
300 100 50 20 0 1|0 0.5% 1.6% 0 467G 139M 0|0 0|0 66.2k 210k 9 <时间>
300 100 50 3 0 1|0 0.6% 1.6% 0 467G 139M 0|1 0|0 63.9k 209k 9 <时间>
299 17 *0 16 0 0|0 0.6% 1.7% 0 467G 139M 0|0 0|0 45.7k 187k 9 <时间>
299 119 49 19 0 4|0 0.6% 1.7% 0 467G 139M 0|0 0|0 69.3k 215k 9 <时间>
load 线程累计: {'ins': 1500, 'qry': 497, 'upd': 244, 'del': 100}(4 秒内;一秒大约 300 / 100 / 50 / 20)每秒 300/100/50/20 的负载,首行与之吻合;后面几行有偏差,因为 mongostat 的一秒和负载循环的一秒并不对齐。
$ mongostat --host 127.0.0.1:9901 --rowcount 2 -o 'insert=insert,query=query,update=update,delete=delete,command=command,conn=conn,time=time' 1
insert query update delete command conn time
300 100 50 11 1|0 9 <时间>
300 100 50 29 1|0 9 <时间>
$ mongostat --host 127.0.0.1:9901 --rowcount 2 --json 1
{"127.0.0.1:9901":{"arw":"0|0","command":"1|0","conn":"9","delete":"20","dirty":"0.8%","flushes":"0","getmore":"0","insert":"300","net_in":"66.3k","net_out":"210k","qrw":"0|0","query":"100",
{"127.0.0.1:9901":{"arw":"0|0","command":"1|0","conn":"9","delete":"20","dirty":"0.8%","flushes":"0","getmore":"0","insert":"300","net_in":"66.2k","net_out":"210k","qrw":"0|0","query":"100",-o 自选列,--json 每秒一行 JSON,值是字符串。
$ mongotop --host 127.0.0.1:9901 --rowcount 2 1
ns total read write <时间>
test.a 9ms 1ms 7ms
config.system.sessions 0ms 0ms 0ms
test.b 0ms 0ms 0ms
ns total read write <时间>
test.a 7ms 1ms 5ms
config.system.sessions 0ms 0ms 0ms
test.b 0ms 0ms 0msmongotop 按命名空间列出 total/read/write 的毫秒数:test.a 是 7~9 ms,几乎不碰的 test.b 是 0 ms。
$ mongostat --host 127.0.0.1:9901 --rowcount 4 -o 'insert=insert,dirty=dirty,used=used,flushes=flushes,net_in=net_in,time=time' 1 insert dirty used flushes net_in time 309376 1.8% 70.8% 0 322m <时间> 312840 3.1% 78.1% 0 324m <时间> 309775 3.4% 75.4% 0 321m <时间> 310133 4.4% 55.0% 0 322m <时间>
批量写入时 insert 约 31 万/秒,dirty 1.8% → 4.4%,used 在 55%~78% 波动。
serverStatus: globalLock.currentQueue = {'total': 0, 'readers': 0, 'writers': 0},globalLock.activeClients = {'total': 8, 'readers': 8, 'writers': 0}
serverStatus.queues = {"execution": {"usesThroughputProbing": true, "usesPrioritization": false, "deprioritizationGate": false, "heuristicDeprioritization": true, "backgroundTasksDeprioritization": true, "totalDeprioritizations": 0, "totalMarkedNonDeprioritizable": 2, "heuristicDeprioritizationThreshold": 3, "read": {"normalPriority": {"out": 8, "available": 2, "totalTickets": 10, "addedToQueue": 0, "removedFromQueue":
$ mongostat --host 127.0.0.1:9901 --rowcount 2 -o 'query=query,qrw=qrw,arw=arw,conn=conn,time=time' 1
query qrw arw conn time
*0 8|0 0|0 33 <时间>
*0 0|0 0|0 33 <时间>8 个并发读时 serverStatus 显示 activeClients.readers = 8、currentQueue = 0,mongostat 却是 qrw 8|0、arw 0|0,两边对不上。