脚本抓取mongoDB慢查询进程,生成kill语句,快速恢复mongodb CPU打满情况
2020-06-18 17:08 ndzj 阅读(827) 评论(0) 编辑 收藏 举报场景 |
---|
临时解决方法 |
---|
脚本及使用方法如下(脚本分副本集和分片集群):
一 副本集:
#!/bin/bash user='xxxx'
|
---|
sh mongo_replica_kill.sh yl_jms_css db.killOp(459688754); |
---|
sh mongo_replica_kill.sh yl_jms_css.customerservicestaff db.killOp(432739282); |
---|
二 分片集群:
#!/bin/bash user='xxxx' /usr/local/mongodb/bin/mongo --port "$port" --host "$host" -u"$user" -p"$passw" << EOF |grep $1|grep 'query|true'|cut -d'|' -f4|sed -r 's@\(.*:@\(@g' |
---|
sh mongo_sharding_kill.sh yl_jms_ops
|
---|
sh mongo_sharding_kill.sh yl_jms_ops.arrivalscanlist db.killOp(460474112); |
---|