mongodb显示shard状态 博客分类: mongodb
程序员文章站
2024-03-17 21:04:04
...
将如下代码保存到文件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 & hadoop
-
MongoDB运行状态、性能监控,分析 博客分类: 数据库nosql mongostatmongodb监控数据库
-
mongodb 配置 博客分类: Nosql mongodb
-
nginx 代理 mongodb的 GridFS 博客分类: Nosql mongodbnginx
-
mongodb 集群配置 博客分类: Nosql mongodb
-
Mongodb在Linux下的安装和启动和配置(转载) 博客分类: MongDB MongDB
-
Mongodb C++ driver中的逻辑操作“或” 博客分类: mongodb记录点滴 mongdblogic operationorand
-
mongodb-win32-x86_64-2.4.1的安装 博客分类: database mongdb
-
mongodb安装、配置以及命令创建服务 博客分类: mongodb基本操作 mongdb