在 mongoDB 中添加分片时连接被拒绝

Connection refused when adding shard in mongoDB

我按照 Digital Ocean tutorial 在 MongoDB 中创建了一个基本的分片集群,其中包含 1 个查询路由器、1 个配置服务器和 2 个分片,但没有在 Ubuntu 16.04 的 Virtual box 上进行复制。我已根据提供的教程成功建立了查询路由器和配置服务器之间的连接,但出现错误

   { "ok" : 0, "errmsg" : "Connection refused", "code" : 6 }

当我运行sh.addShard("ip:port")。有人可以指出我做错了什么吗? PS: 我的所有节点上的 bindIP 都是 0.0.0.0。

错误的原因很简单,我使用工具 nmap

弄清楚了
    sudo nmap -p 27017 IP_of_the_shard_node

发现27017端口被关闭了connections.I意识到mongod服务不是运行。因此一个简单的

   sudo systemctl start mongod

在分片节点上可以解决问题。