当前位置: 代码迷 >> 综合 >> 在SHELL脚本中判断mongo节点是否为主
  详细解决方案

在SHELL脚本中判断mongo节点是否为主

热度:80   发布时间:2024-02-12 13:46:04.0

result=`ssh -Tq root@10.1.1.1 -p 10022 "/usr/local/mongodb/bin/mongo --quiet --eval 'printjson(db.isMaster().ismaster)'"`

echo "the result is: $result"

利用printjson,直接把查询的结果返回出来

 

 

  相关解决方案