zoukankan      html  css  js  c++  java
  • mongodb的currentOp

    ###################################

    返回正在执行且运行时间超过10s的连接信息:

    db.currentOp({"secs_running": {"$gt": 10},"active": true})

     返回去掉系统线程的连接:

    db.currentOp({ "active" : true,"ns": {$nin:["local.oplog.rs"]},"desc" :{$nin: ["rsSync-0","ReplBatcher","monitoring keys for HMAC","WT OplogTruncaterThread: local.oplog.rs","NoopWriter"]}});

    insert语句:

      "host" : "c3-dba-glc-db03.bj:28042",
      "desc" : "conn3099",
      "connectionId" : 3099,
      "client" : "10.10.10.10:39573",
      "appName" : "MongoDB Shell",
      "clientMetadata" : {
              "application" : {
                      "name" : "MongoDB Shell"
              },
              "driver" : {
                      "name" : "MongoDB Internal Client",
                      "version" : "4.0.10-5"
              },
              "os" : {
                      "type" : "Linux",
                      "name" : "CentOS Linux release 7.3.1611 (Core) ",
                      "architecture" : "x86_64",
                      "version" : "Kernel 3.10.0-693.21.1.std7a.el7.0.x86_64"
              }
      },
      "active" : true,
      "currentOpTime" : "2021-01-27T16:37:47.664+0800",
      "opid" : 13949528,
      "lsid" : {
              "id" : UUID("6408991e-feb4-4470-b644-9cc2d66f4835"),
              "uid" : BinData(0,"o/6W9HojLAaDkSXLEEkW8L5LOrGfZaJEyQ8SL+OeBfY=")
      },
      "secs_running" : NumberLong(0),
      "microsecs_running" : NumberLong(47),
      "op" : "insert",
      "ns" : "apple.foo",
      "command" : {
              "insert" : "foo",
              "ordered" : true,
              "lsid" : {
                      "id" : UUID("6408991e-feb4-4470-b644-9cc2d66f4835")
              },
              "$clusterTime" : {
                      "clusterTime" : Timestamp(1611736667, 1051),
                      "signature" : {
                              "hash" : BinData(0,"A+ZpOjBSqPD4Ga/99Uxd3SIIcNw="),
                              "keyId" : NumberLong("6919692836459773955")
                      }
              },
              "$db" : "apple"
      },
      "numYields" : 0,
      "locks" : {
    
      },
      "waitingForLock" : false,
      "lockStats" : {
              "Global" : {
                      "acquireCount" : {
                              "r" : NumberLong(1),
                              "w" : NumberLong(1)
                      }
              },
              "Database" : {
                      "acquireCount" : {
                              "w" : NumberLong(1)
                      }
              },
              "Collection" : {
                      "acquireCount" : {
                              "w" : NumberLong(1)
                      }
              }
      }

    query语句:

    {
    "host" : "xxx:28001",
    "desc" : "conn85393",
    "connectionId" : 85393,
    "client" : "10.10.10.10:47753",
    "clientMetadata" : {
            "driver" : {
                    "name" : "mgo",
                    "version" : "globalsign"
            },
            "os" : {
                    "type" : "linux",
                    "architecture" : "amd64"
            }
    },
    "active" : true,
    "currentOpTime" : "2021-01-27T18:14:08.517+0800",
    "opid" : 2124735857,
    "secs_running" : NumberLong(0),
    "microsecs_running" : NumberLong(26160),
    "op" : "query",
    "ns" : "cmdb.equipment",
    "command" : {
            "find" : "equipment",
            "filter" : {
                    "$or" : [
                            {
                                    "sn" : {
                                            "$regex" : "FW2",
                                            "$options" : "i"
                                    }
                            },
                            {
                                    "sn" : {
                                            "$options" : "i",
                                            "$regex" : "4C4C4544-C6C04F365732"
                                    }
                            }
                    ]
            },
            "sort" : {
                    "id" : 1
            },
            "projection" : {
                    "create_time" : 0,
                    "update_time" : 0,
                    "_id" : 0
            },
            "skip" : 0,
            "$db" : "cmdb"
    },
    "numYields" : 49,
    "locks" : {
            "Global" : "r",
            "Database" : "r",
            "Collection" : "r"
    },
    "waitingForLock" : false,
    "lockStats" : {
            "Global" : {
                    "acquireCount" : {
                            "r" : NumberLong(100)
                    }
            },
            "Database" : {
                    "acquireCount" : {
                            "r" : NumberLong(50)
                    }
            },
            "Collection" : {
                    "acquireCount" : {
                            "r" : NumberLong(50)
                    }
            }
    }

    杀掉超过5s时间的操作:

    db.currentOp({"secs_running":{"$gt":5}}).inprog.forEach(function(item){db.killOp(item.opid)})

    ###############################

    igoodful@qq.com
  • 相关阅读:
    Linux基础优化(二)
    权限
    分页
    序列化
    forms
    redis
    Django缓存机制
    跨域问题
    Django的ORM
    模板层
  • 原文地址:https://www.cnblogs.com/igoodful/p/14314339.html
Copyright © 2011-2022 走看看