根据 documentation , shardsvr
选项的默认值为 false
:
Set this value to true to configure this mongod instance as a shard in a partitioned cluster. The default port for these instances is 27018. The only affect of shardsvr is to change the port number.
似乎需要 shardsvr
才能将实例配置为分片。但随后它说唯一的影响是更改端口号。
为什么我需要这样更改端口?已经有 port
选项...
mongod --port 27019 --dbpath /data/shard1
mongod --shardsvr --port 27019 --dbpath /data/shard1
最佳答案
此答案不再有效
查看评论。
不,您不需要通过--shardsvr
选项更改端口。此外,您根本不需要更改端口。您可以使用默认端口组装一个 mongod
实例集群。
据我了解,更改端口的目的是降低直接连接到分片的机会。在集群设置中,您应该通过 mongos
路由器工作。
关于MongoDB shardsvr 选项?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16800145/