MongoDB查看当前操作db.currentOp()

db.currentOp()  
    返回数据库实例上正在运行的操作信息的文档。

等待锁的写操作

下面的示例返回正在等待锁的所有写操作信息:

db.currentOp(   
   {    
     "waitingForLock" : true,    
     $or: [    
        { "op" : { "$in" : [ "insert", "update", "remove" ] } },    
        { "query.findandmodify": { $exists: true } }    
    ]    
   }    
)

没有Yields的活动操作

下面的示例返回所有活动的正在运行的还没有Yields的操作的信息:

db.currentOp(   
   {    
     "active" : true,    
     "numYields" : 0,    
     "waitingForLock" : false    
   }    
)

对于特定数据库的活动操作

下面的示例返回对于数据库db1运行时间大于3秒的所有活动操作:

db.currentOp(   
   {    
     "active" : true,    
     "secs_running" : { "$gt" : 3 },    
     "ns" : /^db1\./    
   }    
)

活动索引操作

下面的示例返回索引创建操作的信息

db.currentOp(   
    {    
      $or: [    
        { op: "command", "query.createIndexes": { $exists: true } },    
        { op: "insert", ns: /\.system\.indexes\b/ }    
      ]    
    }    
)

杀掉进程

杀掉进程
db.killOp(<opid>)

猜你喜欢

转载自blog.csdn.net/zhuchunyan_aijia/article/details/116308296
今日推荐