MongoDB IAM Authentication : Cannot Authenticate using IAM Roles - mongodb

I am unable to authenticate using IAM roles which are added to the cluster.
Currently, There is a Role created and attached with the Ec2 instance. Using the same role while connecting to the DB and running any command. I am getting the following error.
error: {
"operationTime" : Timestamp(1635767862, 1),
"ok" : 0,
"errmsg" : "command find requires authentication",
"code" : 13,
"codeName" : "Unauthorized",
"$clusterTime" : {
"clusterTime" : Timestamp(1635767862, 1),
"signature" : {
"hash" : BinData(0,"WibtM8VK2aorci9mA6QNyP/ummU="),
"keyId" : NumberLong("7023742477949468676")
}
}
}
Has anyone ever faced any issue like this with IAM roles and MongoDB Atlas mongo?

Related

"show dbs" fails on mongo shell

This is the first time I am trying to connect to this mongo instance, which is setup by my ex-colleague. when I run "show dbs", I have seen such message:
rs0:SECONDARY> show dbs
2022-01-05T18:33:11.282+0000 E QUERY [js] uncaught exception: Error: listDatabases failed:{
"operationTime" : Timestamp(1641407590, 1),
"ok" : 0,
"errmsg" : "not master and slaveOk=false",
"code" : 13435,
"codeName" : "NotMasterNoSlaveOk",
"$clusterTime" : {
"clusterTime" : Timestamp(1641407590, 1),
"signature" : {
"hash" : BinData(0,"...="),
"keyId" : NumberLong("...")
}
}
} :
_getErrorWithCode#src/mongo/shell/utils.js:25:13
Mongo.prototype.getDBs/<#src/mongo/shell/mongo.js:135:19
Mongo.prototype.getDBs#src/mongo/shell/mongo.js:87:12
shellHelper.show#src/mongo/shell/utils.js:906:13
shellHelper#src/mongo/shell/utils.js:790:15
#(shellhelp2):1:1
rs0:SECONDARY>
Any ideas what could be wrong ?
Thanks,
Jack
Following is the screenshot How I got that failure.
You need to execute:
rs.slaveOk()
From the SECONDARY to allow show dbs after ...

I am trying to deploy two config server as replicaset using rs.initiate method but i am getting this error with my second config server while deploy

"ok" : 0,
"errmsg" : "replSetInitiate quorum check failed because not all proposed set members responded affirmatively: 172.31.10.124:27019 failed with Error connecting to 172.31.10.124:27019 :: caused by :: Connection refused",
"code" : 74,
"codeName" : "NodeNotFound",
"$gleStats" : {
"lastOpTime" : Timestamp(0, 0),
"electionId" : ObjectId("000000000000000000000000")
},
"lastCommittedOpTime" : Timestamp(0, 0)
}

mongodb giving error not master with replication not initalized

Installed a fresh instance of mongodb 3.6 on Ubuntu 16.x
While creating user mongo is giving error as Error: couldn't add user: not master
also same error with show dbs
{
"ok" : 0,
"errmsg" : "not authorized on admin to execute command { listDatabases: 1.0, lsid: { id: UUID(\"f9e0590a4-b20a-b21b9eecf627\") }, $db: \"admin\" }",
"code" : 13,
"codeName" : "Unauthorized"
}
Replication is not enabled
{
"info" : "run rs.initiate(...) if not yet done for the set",
"ok" : 0,
"errmsg" : "no replset config has been received",
"code" : 94,
"codeName" : "NotYetInitialized"
}
Why this mongo instance is behaving like slave when its not configured to do so.
I have added hosts entries for other slave instances but not initialised them yet.

Aggregations work in standalone but not in sharded cluster

I'm currently trying the aggregations with MongoDB using the json found here : http://media.mongodb.org/zips.json
So, I imported it thousands of time and then I tried this command :
db.CO_villes.aggregate({$group:{_id:"$state",population:{$sum:"$pop"}}})
And I got this error :
2019-04-24T13:49:19.579+0000 E QUERY [js] Error: command failed: {
"ok" : 0,
"errmsg" : "unrecognized field 'mergeByPBRT'",
"code" : 9,
"codeName" : "FailedToParse",
"operationTime" : Timestamp(1556113758, 2),
"$clusterTime" : {
"clusterTime" : Timestamp(1556113758, 2),
"signature" : {
"hash" : BinData(0,"AAAAAAAAAAAAAAAAAAAAAAAAAAA="),
"keyId" : NumberLong(0)
}
}
} : aggregate failed :
I have a sharded cluster with 3 MongoDB instances.
I can face this issue too when I try to get the indexes with "Compass".
I tried to export the data and to remove the id field using the "sed" command (because my Ids were not all with "ObjectID")and to import it but I still face this issue.
I solved my issue by creating a 3.6 cluster instead of a 4.0.6. So I think this is a bug related to the new versions of MongoDB.

Our config version of 1 is no larger than the version on torvm-core20.xyz.com:27019, which is 1

I was trying SSL enabled MongoDB 3.7.9 replica sets. below is the code
I ran this command on abc.xyz.com:27019
> rs.initiate({ _id: "rs0", configsvr: true, members: [{ _id : 0, host : "pqr.xyz.com:27019" }, { _id : 1, host : "abc.xyz.com:27019" }]});
{
"ok" : 0,
"errmsg" : "Our config version of 1 is no larger than the version on pqr.xyz.com:27019, which is 1",
"code" : 103,
"codeName" : "NewReplicaSetConfigurationIncompatible",
"$gleStats" : {
"lastOpTime" : Timestamp(0, 0),
"electionId" : ObjectId("000000000000000000000000")
},
"$clusterTime" : {
"clusterTime" : Timestamp(1536753816, 1),
"signature" : {
"hash" : BinData(0,"AAAAAAAAAAAAAAAAAAAAAAAAAAA="),
"keyId" : NumberLong(0)
}
},
"lastCommittedOpTime" : Timestamp(0, 0)
}
I did not find any hint on internet. Can someone guide me over this. I am not able to see the relica set created, Ideally it shouls have created.
This error is saying that you are trying to initialize a new replica set, but the node at pqr.xyz.com:27019 is already a member of replica set configuration with the same _id. This error message is to avoid mismatching of RS configs by using the version value. See the code for more details.