mongodb 監控工具 mongo-monitor 安裝部署
阿新 • • 發佈:2018-12-04
case 驗證 brew 遠程 vsize bre 8.4 monitor 信息 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
mongodb 監控工具 mongo-monitor 安裝部署