Reputation: 6060
I'm new at mongodb so this replication is kinda confusing for me. I follow the tutorial here. I have set up 2 mongod instance in my machine:
localhost:27018
localhost:27019
with this command:
mongod --dbpath /home/db2 --port 27019 --replSet "rs1"
mongod --dbpath /data/db1 --port 27018 --replSet "rs1"
When I try to connect and set up replication using this set of command
mongo --port 27019
rs1:PRIMARY> rs.add("localhost:27018")
It always says:
{
"ok" : 0,
"errmsg" : "Either all host names in a replica set configuration must
be localhost references, or none must be; found 1 out of 2",
"code" : 103
}
Any help, please ?
Upvotes: 5
Views: 2992
Reputation: 942
It would be better if you choose the machine name (available in terminal right after your username like [email protected]
) instead of localhost,
Like rs1:PRIMARY> rs.add("10gen.local:27018")
as the best practice always use a logical name to define the replicaset.
Upvotes: 3