Mongo性能监控

监控指标

  1. CPU
  2. 内存
  3. 磁盘IO
  4. 网络IO
  5. 进程状态
  6. 错误日志

# 1. database信息

db.stats();
1

img.png

# 2. mongostat

间隔固定时间(1s)输出mongo实例状态,

mongostat -hlocalhost -uroot -p123456 --authenticationDatabase admin
1

img.png

vsize 虚拟内存占用(稳定不变)
res 物理内存占用(持续增长)
qrw q表示队列,r表示读,w表示写;客户端等待从mongo实例读写数据的队列长度
arw a表示活跃,r表示读,w表示写;正在执行读写的客户端数量
1
2
3
4

# 3.db.currentOp()查看当前实例的所有客户端操作

{
	"inprog" : [
		{
			"host" : "cmac.local:27017",
			"desc" : "conn31",
			"connectionId" : 31,
			"client" : "127.0.0.1:54069",
			"appName" : "MongoDB Shell",
			"clientMetadata" : {
				"application" : {
					"name" : "MongoDB Shell"
				},
				"driver" : {
					"name" : "MongoDB Internal Client",
					"version" : "4.0.6"
				},
				"os" : {
					"type" : "Darwin",
					"name" : "Mac OS X",
					"architecture" : "x86_64",
					"version" : "20.6.0"
				}
			},
			"active" : true,
			"currentOpTime" : "2021-10-09T15:55:59.997+0800",
			"opid" : 23254,
			"lsid" : {
				"id" : UUID("ceeb4c51-dddc-4ff0-87cf-4f5c7311166c"),
				"uid" : BinData(0,"47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU=")
			},
			"secs_running" : NumberLong(0),
			"microsecs_running" : NumberLong(94),
			"op" : "command",
			"ns" : "admin.$cmd.aggregate",
			"command" : {
				"currentOp" : 1,
				"lsid" : {
					"id" : UUID("ceeb4c51-dddc-4ff0-87cf-4f5c7311166c")
				},
				"$db" : "admin"
			},
			"numYields" : 0,
			"locks" : {

			},
			"waitingForLock" : false,
			"lockStats" : {

			}
		}
	],
	"ok" : 1
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53

其中释义 opid:操作id,op:命令(还有query或者delete),client:客户端主机和端口号;secs_running:op持续时间