在 MongoDB 分片中添加分片时遇到问题

Trouble to Add Shards in MongoDB Sharding

我正在开发我的项目,使用 Microsoft Azure Ubuntu 14.01 虚拟机在 MongoDB 中创建分片集群。

我正在按照本指南创建分片集群:https://www.digitalocean.com/community/tutorials/how-to-create-a-sharded-cluster-in-mongodb-using-an-ubuntu-12-04-vps

它一直有效,直到我尝试将分片添加到集群。

mongos> sh.addShard("shard0.example.net:27017")
{
    "ok" : 0,
    "errmsg" : "couldn't connect to new shard socket exception [CONNECT_ERROR] for shard0.example.net:27017"
}

PS:然后我尝试在 shard0.example.net 上 运行 Mongod 进程并尝试从 运行 Mongo 进程 shard1.example.net 与 --host shard0.example.net 和 --port 27017,但它也不起作用。

有没有可能是服务器之间的连接问题?我该如何解决这个问题?

谢谢,穆萨。

首先,从 mongos 路由器节点 ping 每个分片主节点并确保它可见

ubuntu@ubuntu-azure:~$ping shard0.example.net    

如果没问题并且回复正确,下一步就是修改端口号了。确保输入正确。

如果它们完全相同,则第三步是检查防火墙并确保您使用的端口是空闲的并且能够接收连接。