MongoDB 3.0 server with 2.4 clients

Updated at by

In a mixed Centos 6 and 7 env there will be Mongo 2.4 and 3.0 libs on the loose. On a 3.0 server auhentication schema defaults to 5 thus users won't have 2.4 compatible hashes for their accounts.

use admin
db.createUser( { user: "root", pwd: "hurdur", roles: [ { role: "root", db: "admin" } ]});

User will only have a SCRAM-SHA-1 hash

db.system.users.find()
{ "_id" : "admin.root", "user" : "root", "db" : "admin", "credentials" : { "SCRAM-SHA-1" : { "iterationCount" : 10000, "salt" : "PfklfexGq3K4UnvHwOmUHA==", "storedKey" : "ASnhCtTRBk4YB8HOJtTzlEkO4mA=", "serverKey" : "3CeM6JZlO000td9j7IL4M5MeLPY=" } }, "roles" : [ { "role" : "root", "db" : "admin" } ] }

2.4 client connection will die with authentication failure message instead of unsupported auth mechanism...

Mon Jul  6 00:00:00.000 User Assertion: 18:{ ok: 0.0, errmsg: "auth failed", code: 18 }
Mon Jul  6 00:00:00.000 Error: 18 { ok: 0.0, errmsg: "auth failed", code: 18 } at src/mongo/shell/db.js:228

To downgrade authSchema to version 3 (MONGODB-CR), disable auth for the server in /etc/mongod.conf

auth = false

Restart server

systemctl restart mongod.service

Downgrade authSchema

use admin
var schema = db.system.version.findOne({"_id" : "authSchema"})
schema.currentVersion = 3
db.system.version.save(schema)

Recreate user(s)

use admin
db.dropUser('root')
db.createUser( { user: "root", pwd: "hurdur", roles: [ { role: "root", db: "admin" } ]});

db.system.users.find()
{ "_id" : "admin.root", "user" : "root", "db" : "admin", "credentials" : { "MONGODB-CR" : "42d9476e02e75a2509bc5a28c0654636" }, "roles" : [ { "role" : "root", "db" : "admin" } ] }

Enable auth in /etc/mongod.conf and restart mongod.


Leave a comment