One: Problem description
Today, when doing a full-database recovery, error:
[root@ser6-52 mytest]# mongorestore-u superuser-p 123--authenticationdatabase admin/backup/mongodb/full_bak_201507 021651.bak/
Connected to:127.0.0.1
2015-07-02t17:45:45.297+0800 going into namespace [admin.system.version]
Restoring to Admin.system.version without dropping. Restored data would be inserted without raising errors; Check your server log
1 objects found
2015-07-02t17:45:45.298+0800 Creating index: {key: {_id:1}, Name: "_id_", ns: "Admin.system.version"}
Error Creating Index Admin.system.version:13 ERR: "Not authorized to create index on Admin.system.version"
Aborted (core dumped)
Two: Cause of error
The user lacks restore permissions
--I thought Root was the biggest privilege, and I didn't think it would be due to a lack of restore permissions. Oh, really.
Three: Solutions
Empowerment:
> Db.grantrolestouser ("Superuser", [{role: "Restore", DB: "admin"}]);
--Try to restore again:
[root@ser6-52 ~]# mongorestore-u superuser-p 123456--authenticationdatabase admin/backup/mongodb/full_bak_20150702 1651.bak/
Connected to:127.0.0.1
2015-07-03t09:30:20.275+0800 going into namespace [admin.system.version]
Restoring to Admin.system.version without dropping. Restored data would be inserted without raising errors; Check your server log
1 objects found
2015-07-03t09:30:20.276+0800 Creating index: {key: {_id:1}, Name: "_id_", ns: "Admin.system.version"}
2015-07-03t09:30:20.277+0800/backup/mongodb/full_bak_201507021651.bak/admin/system.users.bson
2015-07-03t09:30:20.277+0800 going into namespace [admin.system.users]
Restoring to Admin.system.users without dropping. Restored data would be inserted without raising errors; Check your server log
2 objects found
2015-07-03t09:30:20.282+0800 Creating index: {key: {_id:1}, Name: "_id_", ns: "Admin.system.users"}
2015-07-03t09:30:20.282+0800 Creating index: {unique:true, key: {user:1, db:1}, Name: "User_1_db_1", NS: "Admin.sys Tem.users "}
2015-07-03t09:30:20.285+0800/backup/mongodb/full_bak_201507021651.bak/mytest/d.bson
2015-07-03t09:30:20.285+0800 going into namespace [MYTEST.D]
Objects found
2015-07-03t09:30:20.286+0800 Creating index: {key: {_id:1}, Name: "_id_", ns: "MYTEST.D"}
2015-07-03t09:30:20.288+0800/backup/mongodb/full_bak_201507021651.bak/mytest/c.bson
2015-07-03t09:30:20.288+0800 going into namespace [mytest.c]
Restoring to mytest.c without dropping. Restored data would be inserted without raising errors; Check your server log
Objects found
2015-07-03t09:30:20.295+0800 Creating index: {key: {_id:1}, Name: "_id_", ns: "Mytest.c"}
--Role Permissions Please refer to: MongoDB User rights operation