My replica set is not working in HW1.3

I have started a three member replica set that uses X.509 certificates for internal authentication following the instructions.

But when I connect using mongo shell to any one of the ports to initiate the replica, I got error stating

MongoDB Enterprise > use admin
switched to db admin

MongoDB Enterprise > rs.initiate()
{
“info2” : “no configuration specified. Using a default configuration for the set”,
“me” : “database:31130”,
“ok” : 1
}

Both rs.status() and rs.isMaster() show that there is only one member in the replica set.
I can’t not add more members.

Please help.

Well, you didn’t say what errors you had when adding new members to the replica set. But be caseful with rs.initiate(). Try to run rs.status() and see what’s the host name listed in the response. If you see “database:31130”, then you may have problem there.

In my env, when I run rs.initiate() with no parameters, the instance was automatically identified and added as “database” rather than “database.m310.mongodb.university”. However the name “database” doesn’t match the name included in the certificate which expects the full qualified name. So in my case, I can add the other two instances to the set but rs.status() always reported the other two as STARTUP, and the logs of those two instances were fully of network errors complaining about the TLS handshake failure tot he mismatched name. So check if you are having the same issue and we can see how to fix.

I did see “database:31130”.

When you set up your replica set make sure that you use the fully qualified domain name (FQDN) when initiating the replica set

When you run rs.initiate() without parameters it uses default values. One of those default values is hostname. In this environment the hostname is database. database does not match the certificate (in our lab environment the certificates contain the FQDN in the subject alternative name).

These are some options for deploying a replica set for HW 1.3:

  • You can initiate the replica set with all three nodes using the FQDN.

  • Or you can initiate the replica set with one node passing the FQDN as the host - then run rs.add() passing the correct parameters to add the other members.

  • Additionally if you’ve initiated with default name you can update the replica set configuration with the FQDN hostname using rs.reconfig().

  • Lastly, you can always start over if some of these configuration steps are unfamiliar.

Also, if you need a refresher on deploying replica sets :

https://docs.mongodb.com/manual/tutorial/deploy-replica-set/

hope this helps,

David

As dschupp suggested you should initiate nodes using FQDN. You can do that with bind_ip argument. If you are using config file it is bindIP
When starting without this argument, mongod automatically takes doman name ‘database’. Probably because it is specified in /etc/hosts. Why it selects this one and not FQDN, I do not know.

Yes. it worked. I initiated my replica set with all three nodes using the FQDN.

Thanks all.

Renlong