mongodb6.0统计信息
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了mongodb6.0统计信息相关的知识,希望对你有一定的参考价值。
1.db.stats()
db.stats()作为数据库命令,用于显示具体某个数据库的统计信息(如果部署了分片集群就会显示该数据库在每个分片中的情况,此处以单实例为例):
wang> db.stats()
db: wang, #数据库名
collections: 111, #集合个数
views: 0, #视图个数
objects: 2694190, #文档记录总数
avgObjSize: 498.9666062898311, #数据库中文档记录的平均大小,这是 dataSize 除以文档的数量得到的(单位字节)
dataSize: 1344310841, #数据库中保存的未压缩数据的总大小(单位字节),dataSize可能比storageSize启用压缩时更大 1282M
storageSize: 234012672, #分配给数据库的总存储空间(启用压缩后,单位字节),storageSize不包括分配给索引的空间。 223M
indexes: 122, #索引总数
indexSize: 50819072, #索引占用的存储空间(单位字节) 48M
totalSize: 284831744, #为数据库中所有集合中的文档和索引分配的空间总和。包括已用和可用存储空间。这是总和storageSize + indexSize
scaleFactor: 1, #scale命令使用的值
fsUsedSize: 34739814400, #MongoDB 存储数据的文件系统上正在使用的所有磁盘空间的总大小(linux已经用的磁盘大小,单位字节) 33130M
fsTotalSize: 527809224704, #服务器的磁盘容量 503358M
ok: 1
2.db.serverStatus()
db.serverStatus()数据库命令用于显示具体某个实例上的统计信息,实例可以为mongod 或者 mongos。
(1).查看mongodb实例中的连接数信息
wang> db.serverStatus().connections
current: 7, #当前客户端的连接数,包括复制集之间的连接数
available: 4993, #可用的客户端连接数
totalCreated: 126, #所有已创建的连接数(包括已关闭)
active: 2, #当前活跃的、有读写等操作的客户端连接数
threaded: 7, #线程数
exhaustIsMaster: 0, #最后一个请求是一个 isMaster请求的连接数( MongoDB5.0或更高版本,请不要使用该 isMaster命令。相反,使用hello)
exhaustHello: 1, #最后一个请求的连接数是hello请求
awaitingTopologyChanges: 1 #当前等待的客户数量hello 或 isMaster请求更改拓扑
wang>
(2).查询内存相关信息
wang> db.serverStatus().mem
bits: 64, #运行实例的变异架构
resident: 1677, #使用的物理内存总量(单位MB),在正常使用期间,该值趋于增长。在专用数据库服务器中,这个数字趋向于接近系统内存的总量。
virtual: 4529, #使用虚拟内存大小(单位MB)
supported: true #指示底层系统是否支持扩展内存信息
(3).查看实例中wiredTiger存储引擎的cache相关信息
wang> db.serverStatus().wiredTiger.cache
application threads page read from disk to cache count: 7883,
application threads page read from disk to cache time (usecs): 666789,
application threads page write from cache to disk count: 824928,
application threads page write from cache to disk time (usecs): 18824415,
bytes allocated for updates: 2202265,
bytes belonging to page images in the cache: 1664217947,
bytes belonging to the history store table in the cache: 191,
bytes currently in the cache: 1699830124, #当前数据占用的内存大小(单位为字节)1621M,取值小于maximum bytes configured
bytes dirty in the cache cumulative: Long("46185937545"),
bytes not belonging to page images in the cache: 35612177,
bytes read into cache: 898014386,
bytes written from cache: Long("24704614250"),
checkpoint blocked page eviction: 2,
checkpoint of history store file blocked non-history store page eviction: 0,
eviction calls to get a page: 33137,
eviction calls to get a page found queue empty: 7969,
eviction calls to get a page found queue empty after locking: 587,
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: 43972,
eviction server candidate queue empty when topping up: 880,
eviction server candidate queue not empty when topping up: 527,
eviction server evicting pages: 0,
eviction server slept, because we did not make progress with eviction: 23639,
eviction server unable to reach eviction goal: 0,
eviction server waiting for a leaf page: 176,
eviction state: 64,
eviction walk most recent sleeps for checkpoint handle gathering: 0,
eviction walk target pages histogram - 0-9: 34005,
eviction walk target pages histogram - 10-31: 8073,
eviction walk target pages histogram - 128 and higher: 0,
eviction walk target pages histogram - 32-63: 707,
eviction walk target pages histogram - 64-128: 1187,
eviction walk target pages reduced due to history store cache pressure: 0,
eviction walk target strategy both clean and dirty pages: 4277,
eviction walk target strategy only clean pages: 2296,
eviction walk target strategy only dirty pages: 37399,
eviction walks abandoned: 1064,
eviction walks gave up because they restarted their walk twice: 38345,
eviction walks gave up because they saw too many pages and found no candidates: 2701,
eviction walks gave up because they saw too many pages and found too few candidates: 12,
eviction walks reached end of tree: 79315,
eviction walks restarted: 0,
eviction walks started from root of tree: 41323,
eviction walks started from saved location in tree: 2649,
eviction worker thread active: 4,
eviction worker thread created: 0,
eviction worker thread evicting pages: 24554,
eviction worker thread removed: 0,
eviction worker thread stable number: 0,
files with active eviction walks: 0,
files with new eviction walks started: 40970,
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: 0,
forced eviction - history store pages selected while session has history store cursor open: 0,
forced eviction - history store pages successfully evicted while session has history store cursor open: 0,
forced eviction - pages evicted that were clean count: 68,
forced eviction - pages evicted that were clean time (usecs): 130,
forced eviction - pages evicted that were dirty count: 19,
forced eviction - pages evicted that were dirty time (usecs): 2260,
forced eviction - pages selected because of a large number of updates to a single item: 0,
forced eviction - pages selected because of too many deleted items count: 38,
forced eviction - pages selected count: 500,
forced eviction - pages selected unable to be evicted count: 0,
forced eviction - pages selected unable to be evicted time: 0,
hazard pointer blocked page eviction: 5,
hazard pointer check calls: 25054,
hazard pointer check entries walked: 209276,
hazard pointer maximum array length: 18,
history store table insert calls: 0,
history store table insert calls that returned restart: 0,
history store table max on-disk size: 0,
history store table on-disk size: 4096,
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: 0,
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: 0,
in-memory page passed criteria to be split: 826,
in-memory page splits: 413,
internal pages evicted: 0,
internal pages queued for eviction: 0,
internal pages seen by eviction walk: 0,
internal pages seen by eviction walk that are already queued: 0,
internal pages split during eviction: 0,
leaf pages split during eviction: 955,
maximum bytes configured: Long("2147483648"), #分配给cache的最大内存(单位为字节) 2G
maximum page size at eviction: 0,
modified pages evicted: 1514,
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: 0,
pages currently held in the cache: 14117,
pages evicted by application threads: 0,
pages evicted in parallel with checkpoint: 136,
pages queued for eviction: 39292,
pages queued for eviction post lru sorting: 42684,
pages queued for urgent eviction: 457,
pages queued for urgent eviction during walk: 95,
pages queued for urgent eviction from history store due to high dirty content: 0,
pages read into cache: 7883, #读入缓存的页数(可以提供 I/O 活动的概览)
pages read into cache after truncate: 565,
pages read into cache after truncate in prepare state: 0,
pages requested from the cache: 23470228,
pages seen by eviction walk: 1863082,
pages seen by eviction walk that are already queued: 72690,
pages selected for eviction unable to be evicted: 11,
pages selected for eviction unable to be evicted because of active children on an internal page: 0,
pages selected for eviction unable to be evicted because of failure in reconciliation: 0,
pages selected for eviction unable to be evicted because of race between checkpoint and out of order timestamps handling: 0,
pages walked for eviction: 4127580,
pages written from cache: 854280, #从缓存写入的页数(可以提供 I/O 活动的概览)
pages written requiring in-memory restoration: 1028,
percentage overhead: 8,
the number of times full update inserted to history store: 0,
the number of times reverse modify inserted to history store: 0,
tracked bytes belonging to internal pages in the cache: 2514977,
tracked bytes belonging to leaf pages in the cache: 1697315147,
tracked dirty bytes in the cache: 0, #缓存中脏数据的大小(以字节为单位),该值应小于该bytes currently in the cache值
tracked dirty pages in the cache: 0,
unmodified pages evicted: 23202 #页面驱逐的主要统计数据
(4).查看锁相关的总体信息
wang> db.serverStatus().globalLock
totalTime: Long("2515065515000"), #服务器上线总时长(单位为微秒,1 秒=1000000 微秒),2515065515000/1000000/60/60/24=29天
currentQueue: #提供有关因锁定而排队的操作数信息的文档
total: 0, #当前排队等待锁的操作数量
readers: 0, #当前排队等待读锁的操作数量,持续小的读取队列,尤其是较短的操作,应该不会引起关注
writers: 0 #当前排队等待写锁的操作数量,持续小的写入队列,尤其是较短的操作,无需担心。
,
activeClients: #提供有关已连接客户端数量以及这些客户端执行的读取和写入操作的信息的文档。
total: 0, #执行操作的活跃客户端连接数
readers: 0, #执行读操作的活跃客户端连接数
writers: 0 #执行写操作的活跃客户端连接数
(5).查看锁相关的详细信息
wang> db.serverStatus().locks
ParallelBatchWriterMode: #批量并行写的锁
acquireCount: #获取锁的次数
r: Long("1058410") #获取意向共享锁的次数
,
FeatureCompatibilityVersion: #兼容性版本
acquireCount:
r: Long("5063906"), #意向共享锁
w: Long("1058545") #意向排他锁
,
ReplicationStateTransition: #复制集节点状态变更的锁
acquireCount: #获取锁的次数
w: Long("3574552") #获取意向排它锁的次数
,
Global: #全局实例级别的锁
acquireCount:
r: Long("5063906"), #意向共享锁
w: Long("1058540"), #意向排他锁
W: Long("5") #排它锁
,
Database: #数据库级别的锁
acquireCount:
r: Long("127"), #意向共享锁
w: Long("1058391"), #意向排他锁
W: Long("1") #排它锁
,
Collection: #集合级别的锁
acquireCount:
r: Long("356"), #意向共享锁
w: Long("1058253"), #意向排他锁
R: Long("26"), #共享锁
W: Long("112") #排它锁
,
Mutex: #互斥锁
acquireCount:
r: Long("1085003") #意向共享锁
官方文档:https://www.mongodb.com/docs/v6.0/reference/method/db.stats/
以上是关于mongodb6.0统计信息的主要内容,如果未能解决你的问题,请参考以下文章