MongoDB – temporarily turn shard to standalone for local user creation

authenticationconfigurationmongodbsharding

Following question Mongodb sharded cluster backup user issue
I have a sharded mongodb cluster, with 4 shards, and I'm required to stop the mongod service on each shard, and start it not as a part of a shared cluster, but as a standalone with no authentication.

Today, each shard is configured with the options:

shardsvr=true
keyFile=/etc/mongodb.key

If i comment out these 2 options, will I be able to start the service as standalone with no auth?

Moreover, is there any possible impact on the data/configuration once i finish what I need to do and uncomment the both configuration options?

Thanks in advance

Best Answer

If you comment out keyFile (assuming you have not specified auth explicitly) you will turn off authentication. Basically keyFile implies auth but not the other way around.

When you comment out shardsvr, the port will change from 27018 to the default port number - 27017. That is actually a good thing. When you take a node out of a replica set or a sharded cluster you want to change the port so that the rest of the set/cluster does not attempt to continue to communicate with the node you are working on. Then, once you restore the original configuration, it will rejoin the set and cluster as normal.

Although the port will change when you do this, I tend to prefer explicitly specifying the port number to use for maintenance (30000 is my preference) rather than rely on default settings. Also, I tend to have plenty of instances running on my hosts, so 27017 may well already be in use.

Once you have made your changes, all you have to do to restore the node in question is restart and switch back to your original settings. This should be a relatively quick maintenance, so you should not have to worry about a node going stale (can be a concern with prolonged work).