mongodb显示shard状态 博客分类: mongodb
程序员文章站
2024-03-17 22:04:16
...
将如下代码保存到文件mongodbstats.js
在mongos上运行mongo mongodbstats.js --quiet | grep -v "I NETWORK"
效果如下
current shards:
{ "_id" : "s1", "host" : "s1/dev185.smarket:31001,dev186.smarket:31001" }
{ "_id" : "s2", "host" : "s2/dev250.smarket:31002" }
check rs status:
checking s1
dev186.smarket:31001 is PRIMARY
dev185.smarket:31001 is SECONDARY
dev250.smarket:31001 is ARBITER
checking s2
dev250.smarket:31002 is PRIMARY
function checkRS(members){ var valid=true; members.forEach(function(member){ print(member.name+" is "+member.stateStr) if (member.stateStr != "SECONDARY" && member.stateStr != "PRIMARY" && member.stateStr != "ARBITER"){ valid=false; } }); return valid; } db = db.getSiblingDB('config'); shards=db.shards.find(); print("\ncurrent shards:\n") while ( shards.hasNext() ) { printjson( shards.next() ); } print("\ncheck rs status:\n") shards=db.shards.find(); while ( shards.hasNext() ) { shard=shards.next(); print("checking "+shard._id) connStr=shard.host; mongo=new Mongo(connStr); rsStats=mongo.getDB("admin")._adminCommand("replSetGetStatus"); var valid=checkRS(rsStats.members); if(!valid){ print("please check this rs!!") printjson(rsStats) } print("") }
在mongos上运行mongo mongodbstats.js --quiet | grep -v "I NETWORK"
效果如下
引用
current shards:
{ "_id" : "s1", "host" : "s1/dev185.smarket:31001,dev186.smarket:31001" }
{ "_id" : "s2", "host" : "s2/dev250.smarket:31002" }
check rs status:
checking s1
dev186.smarket:31001 is PRIMARY
dev185.smarket:31001 is SECONDARY
dev250.smarket:31001 is ARBITER
checking s2
dev250.smarket:31002 is PRIMARY
上一篇: 各类排序比较
推荐阅读
-
mongodb显示shard状态 博客分类: mongodb
-
记一次mongodb从亚马逊云迁移到微软云 博客分类: 杂谈mongodb mongodb
-
mongodb shell中显示更多数量的结果 博客分类: 大数据 mongodb
-
mongodb显示shard状态 博客分类: mongodb
-
Mongodb相对于关系型数据库的优缺点 博客分类: mongodb & hadoop
-
MongoDB运行状态、性能监控,分析 博客分类: 数据库nosql mongostatmongodb监控数据库
-
mongodb 配置 博客分类: Nosql mongodb
-
nginx 代理 mongodb的 GridFS 博客分类: Nosql mongodbnginx
-
mongodb 集群配置 博客分类: Nosql mongodb
-
Mongodb在Linux下的安装和启动和配置(转载) 博客分类: MongDB MongDB