mongo 集群监控工具 mongo-monitor 安装部署
调试mongodb 集群期间发现一个小神器,不敢独享!相关介绍如下:
mongo-monitor CLI是一个简洁和简单的工具来检查MongoDB的服务,在集群调试升级期间,故障排查,添加节点,调整分片、修改配置等操作时可以实时查看整个集群状态,全方位了解集群状态,自动秒级刷新状态。
显示效果预览:
Shard: shard1
SECONDARY : 172.19.9.11:27001
PRIMARY : 172.19.9.12:27001
SECONDARY : 172.19.9.13:27001
Shard: shard2
SECONDARY : 172.19.9.11:27002
PRIMARY : 172.19.9.12:27002
SECONDARY : 172.19.9.13:27002
Shard: shard3
PRIMARY : 172.19.9.11:27003
SECONDARY : 172.19.9.12:27003
STARTUP : 172.19.9.13:27003
Events:
Time : 2018-12-04T05:22:48.687Z
Connection : mongodb://127.0.0.1:27017
Configuration : sharded
安装 mongo-monitor CLI
使用npm 安装
yum install npm -y
npm install -g mongo-monitor
mac 安装
brew install npm
npm install -g mongo-monitor
常规使用
连接本地mongo
mongo-monitor mongodb://127.0.0.1:27017
单独查本地集群某一个分片状态
mongo-monitor 127.0.0.1:27001,127.0.0.1:27002,127.0.0.1:27003?replicaSet=shard3
查看远程mongodb 集群 shard 2 分片状态;
mongo-monitor 10.12.7.194:27002,10.12.7.165:27002,10.12.7.78:27002?replicaSet=shard2
Time : 2018-12-04T05:43:28.414Z
Connection : mongodb://10.12.7.194:27002,10.12.7.165:27002,10.12.7.78:27002?replicaSet=shard2
Configuration : replicaset
Replicaset: shard2
SECONDARY : 10.12.7.165:27002
PRIMARY : 10.12.7.194:27002
SECONDARY : 10.12.7.78:27002
Events:
2018-12-04T05:43:26.366Z : joined
2018-12-04T05:43:26.364Z : joined
验证方式登录
mongo-monitor admin:P@[email protected]:27002,10.12.7.165:27002,10.12.7.78:27002?replicaSet=shard2
如果输入连接端口和shard不匹配,将打印告警信息如下:
Events:
2018-12-04T05:42:46.306Z : setName from ismaster does not match provided connection setName [shard2] != [shard1]
2018-12-04T05:42:45.291Z : setName from ismaster does not match provided connection setName [shard2] != [shard1]
连接远程待认证集群节点
mongo-monitor 192.168.1.5:27001,127.0.0.1:27002,127.0.0.1:27003?replicaSet=shard3
项目地址:
https://github.com/dwmkerr/mongo-monitor
问题
调试期间发现这个工具打印的信息略少,给开发者提了一个 issues ,希望能多输出点信息,加上分片使用内存,网络等信息:
https://github.com/dwmkerr/mongo-monitor/issues/20
Shard: shard1
SECONDARY : 172.19.9.11:27001 vsize:9.85G res:8.43G net_in:159b net_out:64.8k conn:18
PRIMARY : 172.19.9.12:27001 vsize:9.85G res:8.43G net_in:140b net_out:64.8k conn:18
SECONDARY : 172.19.9.13:27001 vsize:9.85G res:8.43G net_in:119b net_out:64.8k conn:18