1. 查看目前集群的慢日志配置
    db.getProfilingStatus(); // 如果slowms:表示慢日志配置的时间
    db.getProfilingLevel(); // 表示是否将慢日志写入系统表db.system.profile中,0表示关闭,1,开启。
  2. 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.
  3. 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  // 操作的花费的时间 

结义
6 声望0 粉丝