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

前端 未结 2 1138
情话喂你
情话喂你 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:53

    I had the same problem. After rs.initiate() look at the me field in printed result of this command. It's the name of your computer. For me it was Apollo-17:27001 . Having this information add other 2 servers: >rs.add("Apollo-17:27002") etc. Ensure that everything is ok: in console you will see { "ok" : 1 } . That's all.

    0 讨论(0)
  • 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

    0 讨论(0)
提交回复
热议问题