0
votes

I have 6 mongod server.

2 shard with replica set of two servers each(totally 4 mongod server) 2 config server 2 mongos which will run on shard server itself

I would like to enable authentication on sharded cluster. I tried enabling --auth while starting the 6 mongod instances but it throwing below error.

SHARDING [mongosMain] Error initializing sharding state, sleeping for 2 seconds and trying again :: caused by :: Unauthorized: could not get updated shard list from config server due to not authorized for query on config.shards

How to enable authentication in sharded cluster? I'm using mongodb 3.2.4 version.

How config server will communicate internally with other mongod server?

Do i need to create user on each mongod separately in admin db?

Please help me to understand this.

-Thanks in advance.

1

1 Answers

0
votes

For shared cluster, you have to use keyfile or x.509 certificate authentication for inter cluster communication.

Please refer to this link: https://docs.mongodb.com/manual/core/security-internal-authentication/

To create users, connect to the mongos and add the users. Since version 2.6+, MongoDB stores user login data in the admin database of the config servers, so you don't have to create user on each mongod separately. Also you can refer to these links:

http://pe-kay.blogspot.in/2016/02/update-existing-mongodb-replica-set-to.html

http://pe-kay.blogspot.in/2016/02/securing-mongodb-using-x509-certificate.html