MongoDB Replica Set: Can’t Add Member/Connect

mongodbUbuntu

I'm building a MongoDB replicaset w/ three Ubuntu 14 servers.

I'm connected to the primary server and authenticated w/ userAdminAnyDatabase and clusterAdmin privileges.

When I run rs.add(xx.xx.xx.xx:27017), I get this error:

exception: set name does not match the set name host xx.xx.xx.xx:27017 expects

I've tried using the IP address, external hostname, and internal hostname.

I have xx.xx.xx.xx rs2 in my /etc/hosts file and use rs2 in the config file of the server I want to add (replSet=rs2). No matter what I try, it says the name doesn't match.

What am I doing wrong?

Best Answer

The issue was a result of having different values for replSet in /etc/mongod.conf. I thought the servers should be named uniquely -- this is incorrect. Each server in the replicaset must have the same value for replSet.