[SERVER-7748] mongodump/mongorestore can't authenticate with replica set host string Created: 23/Nov/12  Updated: 10/Dec/14  Resolved: 26/Mar/13

Status: Closed
Project: Core Server
Component/s: Tools
Affects Version/s: 2.0.8
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Gianfranco Palumbo Assignee: Unassigned
Resolution: Won't Fix Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: File tool_replset_auth.js    
Issue Links:
Related
Operating System: ALL
Steps To Reproduce:

mongod 2.0.7 ReplicaSet with --auth and --keyFile

Participants:

 Description   

In 2.0.8, mongodump/restore are unable to connect to auth enabled replica sets using the replicaSet format connection string, e.g., "replTest/localhost:31000,localhost:31001"

This can be worked around by connecting directly to one of the members.

> db.auth('super','pass')
> rs.status()
{
	"set" : "myapp",
	"date" : ISODate("2012-11-23T16:05:35Z"),
	"myState" : 1,
	"members" : [
		{
			"_id" : 0,
			"name" : "Gianfranco-10gen.local:40001",
			"health" : 1,
			"state" : 2,
			"stateStr" : "SECONDARY",
			"uptime" : 2630,
			"optime" : Timestamp(1353684410000, 1),
			"optimeDate" : ISODate("2012-11-23T15:26:50Z"),
			"lastHeartbeat" : ISODate("2012-11-23T16:05:34Z"),
			"pingMs" : 0
		},
		{
			"_id" : 1,
			"name" : "Gianfranco-10gen.local:40002",
			"health" : 1,
			"state" : 1,
			"stateStr" : "PRIMARY",
			"optime" : Timestamp(1353684410000, 1),
			"optimeDate" : ISODate("2012-11-23T15:26:50Z"),
			"self" : true
		},
		{
			"_id" : 2,
			"name" : "Gianfranco-10gen.local:40003",
			"health" : 1,
			"state" : 7,
			"stateStr" : "ARBITER",
			"uptime" : 2622,
			"optime" : Timestamp(0, 0),
			"optimeDate" : ISODate("1970-01-01T00:00:00Z"),
			"lastHeartbeat" : ISODate("2012-11-23T16:05:34Z"),
			"pingMs" : 0
		}
	],
	"ok" : 1
}
> use admin
> show users
{
	"_id" : ObjectId("50af93cd91fd68039a8d635a"),
	"user" : "mod",
	"readOnly" : true,
	"pwd" : "1f6fcc8d0acedbf19216156f244f9f77"
}
{
	"_id" : ObjectId("50af93d691fd68039a8d635b"),
	"user" : "super",
	"readOnly" : false,
	"pwd" : "bd42eafe6f7aa5c8f8fd874f1364085b"
}
 
> db.auth('localadmin','pass')
> use test
> show users
{
	"_id" : ObjectId("50af938991fd68039a8d6358"),
	"user" : "localadmin",
	"readOnly" : false,
	"pwd" : "07a52d0f3417ec013a63523f303c7b08"
}
{
	"_id" : ObjectId("50af93a891fd68039a8d6359"),
	"user" : "localreadonly",
	"readOnly" : true,
	"pwd" : "1b51f54683554baf8e6019f2e484bfbc"
}

$ mongodump --version
mongodump version 2.0.7

$ mongodump -d test -c test -u localadmin -p pass -h myapp/Gianfranco-10gen.local:40001,Gianfranco-10gen.local:40002 --out testdump

Fri Nov 23 16:10:18 starting new replica set monitor for replica set myapp with seed of Gianfranco-10gen.local:40001,Gianfranco-10gen.local:40002
Fri Nov 23 16:10:18 successfully connected to seed Gianfranco-10gen.local:40001 for replica set myapp
Fri Nov 23 16:10:18 changing hosts to { 0: "Gianfranco-10gen.local:40001", 1: "Gianfranco-10gen.local:40002" } from myapp/
Fri Nov 23 16:10:18 trying to add new host Gianfranco-10gen.local:40001 to replica set myapp
Fri Nov 23 16:10:18 successfully connected to new host Gianfranco-10gen.local:40001 in replica set myapp
Fri Nov 23 16:10:18 trying to add new host Gianfranco-10gen.local:40002 to replica set myapp
Fri Nov 23 16:10:18 successfully connected to new host Gianfranco-10gen.local:40002 in replica set myapp
Fri Nov 23 16:10:18 replica set monitor for replica set myapp started, address is myapp/Gianfranco-10gen.local:40001,Gianfranco-10gen.local:40002
Fri Nov 23 16:10:18 [ReplicaSetMonitorWatcher] starting
connected to: myapp/Gianfranco-10gen.local:40001,Gianfranco-10gen.local:40002
DATABASE: test	 to 	testdump/test
assertion: 13106 nextSafe(): { $err: "unauthorized db:test lock type:-1 client:10.7.100.14", code: 10057 }

This happens with any of the other 3 accounts

$ mongodump --version
mongodump version 2.2.1

$ mongodump -d test -c test -u localadmin -p pass -h myapp/Gianfranco-10gen.local:40001,Gianfranco-10gen.local:40002 --out testdump

Fri Nov 23 16:15:33 starting new replica set monitor for replica set myapp with seed of Gianfranco-10gen.local:40001,Gianfranco-10gen.local:40002,Gianfranco-10gen.local:40003
Fri Nov 23 16:15:33 successfully connected to seed Gianfranco-10gen.local:40001 for replica set myapp
Fri Nov 23 16:15:33 changing hosts to { 0: "Gianfranco-10gen.local:40001", 1: "Gianfranco-10gen.local:40002" } from myapp/
Fri Nov 23 16:15:33 trying to add new host Gianfranco-10gen.local:40001 to replica set myapp
Fri Nov 23 16:15:33 successfully connected to new host Gianfranco-10gen.local:40001 in replica set myapp
Fri Nov 23 16:15:33 trying to add new host Gianfranco-10gen.local:40002 to replica set myapp
Fri Nov 23 16:15:33 successfully connected to new host Gianfranco-10gen.local:40002 in replica set myapp
Fri Nov 23 16:15:33 successfully connected to seed Gianfranco-10gen.local:40003 for replica set myapp
Fri Nov 23 16:15:33 Primary for replica set myapp changed to Gianfranco-10gen.local:40002
Fri Nov 23 16:15:33 replica set monitor for replica set myapp started, address is myapp/Gianfranco-10gen.local:40001,Gianfranco-10gen.local:40002
Fri Nov 23 16:15:33 [ReplicaSetMonitorWatcher] starting
connected to: myapp/Gianfranco-10gen.local:40001,Gianfranco-10gen.local:40002,Gianfranco-10gen.local:40003
Fri Nov 23 16:15:33 DATABASE: test	 to 	testdump/test
Fri Nov 23 16:15:33 	test.test to testdump/test/test.bson
Fri Nov 23 16:15:33 doing snapshot query
Fri Nov 23 16:15:33 		 1004 objects
Fri Nov 23 16:15:33 	Metadata for test.test to testdump/test/test.metadata.json
Logstream::get called in uninitialized state
Fri Nov 23 16:15:33 deleting replica set monitor for: myapp/Gianfranco-10gen.local:40001,Gianfranco-10gen.local:40002



 Comments   
Comment by Daniel Pasette (Inactive) [ 30/Dec/12 ]

attaching a jstest.

Comment by Gianfranco Palumbo [ 30/Nov/12 ]

This seems to have been fixed in 2.3.1

Comment by Manish [ 24/Nov/12 ]

Hi,

Thanks,for responding,Is it possible to perform mongodump with replication in version 2.2.0.

Before implementing it to my development server,I tried to test it locally in windows platform but a pop message is coming showing mongodump.exe has stopped working.

I think mongodump with replication is not supporting in version 2.2.0 ? Please suggest the perfect solution.

Thanks
Manish

Generated at Thu Feb 08 03:15:29 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.