代码改变世界

MongoDB性能监控调优

  abce  阅读(196)  评论(0编辑  收藏  举报

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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
> db.serverStatus().globalLock
{
        "totalTime" : NumberLong("5011164491000"),
        "currentQueue" : {
                "total" : 0,
                "readers" : 0,
                "writers" : 0
        },
        "activeClients" : {
                "total" : 0,
                "readers" : 0,
                "writers" : 0
        }
}
 
 
> db.serverStatus().locks
{
        "ParallelBatchWriterMode" : {
                "acquireCount" : {#该类型的锁被获取的次数
                        "r" : NumberLong(36502976),
                        "W" : NumberLong(1955332)
                },
                "acquireWaitCount" : {#锁等待的次数
                        "r" : NumberLong(1082),
                        "W" : NumberLong(306)
                },
                "timeAcquiringMicros" : {#等待的累计时间,单位是微妙
                        "r" : NumberLong(1154708),
                        "W" : NumberLong(129211)
                }
        },
        "FeatureCompatibilityVersion" : {
                "acquireCount" : {
                        "r" : NumberLong(68900575),
                        "w" : NumberLong(43441060)
                }
        },
        "ReplicationStateTransition" : {
                "acquireCount" : {
                        "w" : NumberLong(87266132),
                        "W" : NumberLong(2)
                },
                "acquireWaitCount" : {
                        "w" : NumberLong(2)
                },
                "timeAcquiringMicros" : {
                        "w" : NumberLong(2959)
                }
        },
        "Global" : {#全局锁
                "acquireCount" : {
                        "r" : NumberLong(70768407),
                        "w" : NumberLong(45449430),
                        "W" : NumberLong(6)
                }
        },
        "Database" : {#数据库级别锁
                "acquireCount" : {
                        "r" : NumberLong(8803291),
                        "w" : NumberLong(43475380),
                        "W" : NumberLong(22)
                }
        },
        "Collection" : {#集合级别锁
                "acquireCount" : {
                        "r" : NumberLong(14011371),
                        "w" : NumberLong(43475285),
                        "R" : NumberLong(17),
                        "W" : NumberLong(61)
                }
        },
        "Mutex" : {
                "acquireCount" : {
                        "r" : NumberLong(28749023)
                }
        },
        "oplog" : {#oplog级别的锁
                "acquireCount" : {
                        "r" : NumberLong(5345043),
                        "w" : NumberLong(1)
                }
        }
}

MMAPv1的锁是在整个集合级别;WiredTiger的锁是在文档级别

 

2.检查内存

1
2
> db.serverStatus().mem
{ "bits" : 64, "resident" : 7291, "virtual" : 9530, "supported" : true }

WiredTiger缓存的调优

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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
> db.serverStatus().wiredTiger.cache
{
        "application threads page read from disk to cache count" : 320058297,
        "application threads page read from disk to cache time (usecs)" : NumberLong("17826172899"),
        "application threads page write from cache to disk count" : 12247036,
        "application threads page write from cache to disk time (usecs)" : 197573446,
        "bytes allocated for updates" : 2789574,
        "bytes belonging to page images in the cache" : NumberLong("6186510750"),
        "bytes belonging to the history store table in the cache" : 571,
        "bytes currently in the cache" : NumberLong("6212412873"),#当前缓存数据的大小,不应该超过给wt分配的最大值
        "bytes dirty in the cache cumulative" : NumberLong("1734766997079"),#脏数据的大小
        "bytes not belonging to page images in the cache" : 25902122,
        "bytes read into cache" : NumberLong("18984807567903"),
        "bytes written from cache" : NumberLong("406860409338"),
        "cache overflow score" : 0,
        "checkpoint blocked page eviction" : 1717,
        "checkpoint of history store file blocked non-history store page eviction" : 0,
        "eviction calls to get a page" : 326297146,
        "eviction calls to get a page found queue empty" : 1971080,
        "eviction calls to get a page found queue empty after locking" : 3626168,
        "eviction currently operating in aggressive mode" : 0,
        "eviction empty score" : 0,
        "eviction gave up due to detecting an out of order on disk value behind the last update on the chain" : 0,
        "eviction gave up due to detecting an out of order tombstone ahead of the selected on disk update" : 0,
        "eviction gave up due to detecting an out of order tombstone ahead of the selected on disk update after validating the update chain" : 0,
        "eviction gave up due to detecting out of order timestamps on the update chain after the selected on disk update" : 0,
        "eviction passes of a file" : 9224187,
        "eviction server candidate queue empty when topping up" : 1898078,
        "eviction server candidate queue not empty when topping up" : 1729248,
        "eviction server evicting pages" : 0,
        "eviction server slept, because we did not make progress with eviction" : 6752849,
        "eviction server unable to reach eviction goal" : 0,
        "eviction server waiting for a leaf page" : 8638245,
        "eviction state" : 64,
        "eviction walk most recent sleeps for checkpoint handle gathering" : 312,
        "eviction walk target pages histogram - 0-9" : 3629155,
        "eviction walk target pages histogram - 10-31" : 1147603,
        "eviction walk target pages histogram - 128 and higher" : 0,
        "eviction walk target pages histogram - 32-63" : 1465812,
        "eviction walk target pages histogram - 64-128" : 2981617,
        "eviction walk target pages reduced due to history store cache pressure" : 0,
        "eviction walk target strategy both clean and dirty pages" : 177,
        "eviction walk target strategy only clean pages" : 9169334,
        "eviction walk target strategy only dirty pages" : 54676,
        "eviction walks abandoned" : 264369,
        "eviction walks gave up because they restarted their walk twice" : 2677780,
        "eviction walks gave up because they saw too many pages and found no candidates" : 562949,
        "eviction walks gave up because they saw too many pages and found too few candidates" : 3589,
        "eviction walks reached end of tree" : 5813050,
        "eviction walks restarted" : 0,
        "eviction walks started from root of tree" : 3345605,
        "eviction walks started from saved location in tree" : 5878582,
        "eviction worker thread active" : 4,
        "eviction worker thread created" : 0,
        "eviction worker thread evicting pages" : 320262154,
        "eviction worker thread removed" : 0,
        "eviction worker thread stable number" : 0,
        "files with active eviction walks" : 0,
        "files with new eviction walks started" : 3135270,
        "force re-tuning of eviction workers once in a while" : 0,
        "forced eviction - history store pages failed to evict while session has history store cursor open" : 4,
        "forced eviction - history store pages selected while session has history store cursor open" : 624,
        "forced eviction - history store pages successfully evicted while session has history store cursor open" : 0,
        "forced eviction - pages evicted that were clean count" : 157409,
        "forced eviction - pages evicted that were clean time (usecs)" : 368362,
        "forced eviction - pages evicted that were dirty count" : 4129,
        "forced eviction - pages evicted that were dirty time (usecs)" : 18483606,
        "forced eviction - pages selected because of a large number of updates to a single item" : 4050,
        "forced eviction - pages selected because of too many deleted items count" : 8068,
        "forced eviction - pages selected count" : 166541,
        "forced eviction - pages selected unable to be evicted count" : 805,
        "forced eviction - pages selected unable to be evicted time" : 648,
        "hazard pointer blocked page eviction" : 395989,
        "hazard pointer check calls" : 320440980,
        "hazard pointer check entries walked" : NumberLong("5277438613"),
        "hazard pointer maximum array length" : 1,
        "history store score" : 0,
        "history store table insert calls" : 6531686,
        "history store table insert calls that returned restart" : 0,
        "history store table max on-disk size" : 0,
        "history store table on-disk size" : 32768,
        "history store table out-of-order resolved updates that lose their durable timestamp" : 0,
        "history store table out-of-order updates that were fixed up by reinserting with the fixed timestamp" : 0,
        "history store table reads" : 0,
        "history store table reads missed" : 0,
        "history store table reads requiring squashed modifies" : 0,
        "history store table truncation by rollback to stable to remove an unstable update" : 0,
        "history store table truncation by rollback to stable to remove an update" : 1,
        "history store table truncation to remove an update" : 0,
        "history store table truncation to remove range of updates due to key being removed from the data page during reconciliation" : 0,
        "history store table truncation to remove range of updates due to out-of-order timestamp update on data page" : 0,
        "history store table writes requiring squashed modifies" : 41,
        "in-memory page passed criteria to be split" : 31004,
        "in-memory page splits" : 4213,
        "internal pages evicted" : 117773,
        "internal pages queued for eviction" : 117959,
        "internal pages seen by eviction walk" : 20357482,
        "internal pages seen by eviction walk that are already queued" : 16261,
        "internal pages split during eviction" : 43,
        "leaf pages split during eviction" : 22264,
        "maximum bytes configured" : NumberLong("7781482496"), #wt引擎分配的最大内存
        "maximum page size at eviction" : 360,
        "modified pages evicted" : 143987,
        "modified pages evicted by application threads" : 0,
        "operations timed out waiting for space in cache" : 0,
        "overflow pages read into cache" : 0,
        "page split during eviction deepened the tree" : 0,
        "page written requiring history store records" : 307440,
        "pages currently held in the cache" : 95035,
        "pages evicted by application threads" : 12285,
        "pages evicted in parallel with checkpoint" : 2013599,
        "pages queued for eviction" : 362322071,
        "pages queued for eviction post lru sorting" : 366892162,
        "pages queued for urgent eviction" : 16184398,
        "pages queued for urgent eviction during walk" : 1319,
        "pages queued for urgent eviction from history store due to high dirty content" : 0,
        "pages read into cache" : 320058563,
        "pages read into cache after truncate" : 12961,
        "pages read into cache after truncate in prepare state" : 0,
        "pages requested from the cache" : NumberLong("7901292705"),
        "pages seen by eviction walk" : 407035140,
        "pages seen by eviction walk that are already queued" : 2325112,
        "pages selected for eviction unable to be evicted" : 404950,
        "pages selected for eviction unable to be evicted because of active children on an internal page" : 5533,
        "pages selected for eviction unable to be evicted because of failure in reconciliation" : 4,
        "pages selected for eviction unable to be evicted because of race between checkpoint and out of order timestamps handling" : 0,
        "pages walked for eviction" : NumberLong("3782243302"),
        "pages written from cache" : 12309253,
        "pages written requiring in-memory restoration" : 10496,
        "percentage overhead" : 8,
        "the number of times full update inserted to history store" : 3048395,
        "the number of times reverse modify inserted to history store" : 3483291,
        "tracked bytes belonging to internal pages in the cache" : 18964141,
        "tracked bytes belonging to leaf pages in the cache" : NumberLong("6193448732"),
        "tracked dirty bytes in the cache" : 1451807,
        "tracked dirty pages in the cache" : 5,
        "unmodified pages evicted" : 319887864
}

 

3.连接的监控

1
2
3
4
5
6
7
8
9
10
11
> db.serverStatus().connections
{
        "current" : 78,
        "available" : 51122,
        "totalCreated" : 1011819,
        "active" : 23,
        "threaded" : 78,
        "exhaustIsMaster" : 4,
        "exhaustHello" : 16,
        "awaitingTopologyChanges" : 12371
}

 

4.复制延迟监控

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
abce:PRIMARY> db.printSlaveReplicationInfo()
WARNING: printSlaveReplicationInfo is deprecated and may be removed in the next major release. Please use printSecondaryReplicationInfo instead.
source: 192.16.12.24:27017
        syncedTo: Tue Feb 07 2023 13:41:39 GMT+0800 (CST)
        0 secs (0 hrs) behind the primary
source: 192.16.12.25:27017
        syncedTo: Tue Feb 07 2023 13:41:39 GMT+0800 (CST)
        0 secs (0 hrs) behind the primary
abce:PRIMARY> rs.printSlaveReplicationInfo()
WARNING: printSlaveReplicationInfo is deprecated and may be removed in the next major release. Please use printSecondaryReplicationInfo instead.
source: 192.16.12.24:27017
        syncedTo: Tue Feb 07 2023 13:41:49 GMT+0800 (CST)
        0 secs (0 hrs) behind the primary
source: 192.16.12.25:27017
        syncedTo: Tue Feb 07 2023 13:41:49 GMT+0800 (CST)
        0 secs (0 hrs) behind the primary
abce:PRIMARY>
相关博文:
阅读排行:
· DeepSeek 开源周回顾「GitHub 热点速览」
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· AI与.NET技术实操系列(二):开始使用ML.NET
· .NET10 - 预览版1新功能体验(一)
历史上的今天:
2022-02-07 数据泵在导入数据时为什么会大量使用undo
2017-02-07 12C配置EM Express的https端口
点击右上角即可分享
微信分享提示