why can't I use IP address of locally running mongod server to add it to mongodb replication set

前端 未结 2 1139
情话喂你
情话喂你 2021-01-21 02:41

I am having 3 mongod servers running locally on different ports as with below command

mongod.exe --port 27017 --replSet rs0 --dbpath C:\\data\\db1 --smallfiles -         


        
2条回答
  •  广开言路
    2021-01-21 02:56

    while going through documentation for mongodb sharding I found following statement

    Because all components of a sharded cluster must communicate with each other over the network, there are special restrictions regarding the use of localhost addresses:

    If you use either “localhost” or “127.0.0.1” as the host identifier, then you must use “localhost” or “127.0.0.1” for all host settings for any MongoDB instances in the cluster. This applies to both the host argument to addShard and the value to the mongos --configdb run time option. If you mix localhost addresses with remote host address, MongoDB will produce errors.

    on page "http://docs.mongodb.org/manual/core/sharded-cluster-architectures/#sharding-requirements-infrastructure"

    This implies that when you are in test environment and do not want to add hosts other than localhost then you can go with the approach of using localhost, otherwise prefer using IP address

提交回复
热议问题