- 查看目前集群的慢日志配置
db.getProfilingStatus(); // 如果 slowms:示意慢日志配置的工夫
db.getProfilingLevel(); // 示意是否将慢日志写入零碎表 db.system.profile 中,0 示意敞开,1,开启。 - mongo 的 lock Mode
Mode Description
R Represents Shared (S) lock. // 共享
W Represents Exclusive (X) lock. // 排他
r Represents Intent Shared (IS) lock.
w Represents Intent Exclusive (IX) lock. -
mongo 慢日志含意
2021-08-13T23:52:53.546+0800 I COMMAND [conn125972] command wisteria_assets.cmcc_detect_abnormallogin command: aggregate {aggregate: "cmcc_detect_abnormallogin", pipeline: [ { $match: { abnormal: 1, loginTime: { $gte: 1628784000, $lte: 1628869500} } } ], allowDiskUse: true, fromMongos: true, cursor: {batchSize: 2147483647}, useNewUpsert: true, shardVersion: [Timestamp(0, 0), ObjectId('000000000000000000000000') ], $clusterTime: {clusterTime: Timestamp(1628869497, 1), signature: {hash: BinData(0, C001936257A29DCD858A0256B8540A51EE813919), keyId: 6958721217163427843 } }, $audit: {$impersonatedUsers: [ { user: "qingteng", db: "admin"} ], $impersonatedRoles: [{ role: "root", db: "admin"} ] }, $client: {driver: { name: "mongo-java-driver", version: "3.4.3-dirty"}, os: {type: "Linux", name: "Linux", architecture: "amd64", version: "3.10.0-957HG.el7.x86_64"}, platform: "Java/Oracle Corporation/1.8.0_172-b11", mongos: {host: "WXJD-PSC-P9F1-SPOD2-VM-OS01-BCSAFEBOX-CSCENTER19:27017", client: "10.175.218.65:41057", version: "4.2.10"} }, $configServerState: {opTime: { ts: Timestamp(1628869497, 1), t: 44 } }, $db: "wisteria_assets" } planSummary: COLLSCAN // 全表扫描 IXSAN:全索引扫描, COLLSCAN:全表扫描,IDHACK:id 查问 keysExamined:0 // MongoDB 为执行操作而扫描的索引键的数量 docsExamined:76476 // MongoDB 为了执行操作而扫描的汇合中的文档数 cursorExhausted:1 numYields:824 //// 退让次数,操作时让其余的操作实现的次数。nreturned:23 // 操作返回的文档数 queryHash:AF74EFB7 planCacheKey:03E2CBD0 // 应用的缓存 key reslen:11512 // 返回数据的大小,单位字节 locks:{ReplicationStateTransition: { acquireCount: { w: 825} }, // 获取 ReplicationStateTransition 写锁的次数 Global: {acquireCount: { r: 825} }, // 获取全局读锁的次数 Database: {acquireCount: { r: 825} }, // 获取数据库读锁次数 Collection: {acquireCount: { r: 825} }, Mutex: {acquireCount: { r: 2} } } flowControl:{ acquireCount: 2, acquireWaitCount: 2, timeAcquiringMicros: 34859732 // 示意 flow 耗费的工夫,这个 } storage:{ data: { bytesRead: 37201774, bytesWritten: 35637499, timeReadingMicros: 9355695, // 读数据破费的工夫奥妙 timeWritingMicros: 2719607 // 写数据破费的工夫奥妙 }, timeWaitingMicros: {cache: 4760364} // 花在期待的工夫 } protocol:op_msg 473472ms // 操作的破费的工夫