We have a Sharded cluster in production setup already. while running COMPACT command to disk reclaim in mogos is not working so we have tried in Sharded cluster instance to login with connection string getting error . Could anyone please help to fix. I am new to Mongodb
I have updated MongoDB connection string like below:
mongodb://user:‘password’@ip-192-168-133-183.ec2.internal:27017,ip-192-168-145-243.ec2.internal:27017,ip-192-168-222-182.ec2.internal:27017/admin?replicaSet=shardreplica01&authSource=admin
but still I am getting below error. I have googled but not much idea. Please guide me to fix and let me know if you need addition config informations.
Error: can’t connect to new replica set master [ip-192-168-133-183.ec2.internal:27017], err: AuthenticationFailed: Authentication failed. :
connect@src/mongo/shell/mongo.js:374:17
@(connect):2:6
exception: connect failed
exiting with code 1
Are you using correct userid/pwd?
Can you connect to your replica nodes using the same id&pwd
You are authenticating against admin db and connecting to admin db
Is that user have admin private or a app user?
Did this connect string work before?
From where you got this?
Yes, We are using the Mongos user ID and PWD.
How do I connect replica nodes ?
I am not sure. The MongoDB sharded cluster already formed . While I am trying to run the COMPACT query to reclaim the disk space through mongos shell facing the error. So Google about the issue then I got the idea to run the command through Mongod shell. When tried to connect getting the authentication issue.
So consider me as a newbie MongoDB. Please guide me
where I can find the connection string(/etc/mongod.conf) in which nodes
Please check this link and refer to mongo documentation for Compact and connect strings for standalone,replica etc
Compact is a maintenance operation.Do not run any compact without understanding the implications
From your connect string remove replicaset and other nodes.
It will put you directly to the node you passed
Be clear about data bearing replica nodes and mongos
But still I am getting authentication error:
Error: Authentication failed. :
connect@src/mongo/shell/mongo.js:374:17
@(connect):2:6
exception: connect failed
exiting with code 1
Does this user exist?
In which db this user was created?
You have to authenticate in that db
Try mongo --host IP --port port_num -user -pwd --authenticationDatabase db_name instead of connect string you are trying
Check documentation or our forum threads for exact syntax
As mentioned from the documentation, you Need to create user in the primary of shard to perform operation directly on the shard.
These shard local users are completely independent from the users added to the sharded cluster via mongos. Shard local users are local to the shard and are inaccessible by mongos.
Direct connections to a shard should only be for shard-specific maintenance and configuration. In general, clients should connect to the sharded cluster through the mongos
I have followed the documentation and give the privilege to access user and role but still I am getting same error while running from route node ( mongos).
I cannot able to login shared cluster node to run the compact query.