我很难将mongodb从版本2.0.6更新到当前的2.4。请帮忙
下面是我得到的日志文件:
Tue May 14 08:02:03.339 [initandlisten] MongoDB starting : pid=1906 port=27017 dbpath=/mnt2/var/lib/mongodb/ 64-bit host=ip-10-131-65-73
Tue May 14 08:02:03.339 [initandlisten] db version v2.4.3
Tue May 14 08:02:03.339 [initandlisten] git version: fe1743177a5ea03e91e0052fb5e2cb2945f6d95f
Tue May 14 08:02:03.340 [initandlisten] build info: Linux ip-10-2-29-40 2.6.21.7-2.ec2.v1.2.fc8xen #1 SMP Fri Nov 20 17:48:28 EST 2009 x86_64 BOOST_LIB_VERSION=1_49
Tue May 14 08:02:03.340 [initandlisten] allocator: tcmalloc
Tue May 14 08:02:03.340 [initandlisten] options: { dbpath: "/mnt2/var/lib/mongodb/" }
Tue May 14 08:02:03.347 [initandlisten] journal dir=/mnt2/var/lib/mongodb/journal
Tue May 14 08:02:03.347 [initandlisten] recover : no journal files present, no recovery needed
Tue May 14 08:02:03.554 [initandlisten] build index backendtemp.system.users { user: 1, userSource: 1 }
Tue May 14 08:02:03.557 [initandlisten] Duplicate key exception while trying to build unique index on backendtemp.system.users. You most likely have user documents with duplicate "user" fields. To resolve this, start up with a version of MongoDB prior to 2.4, drop the duplicate user documents, then start up again with the current version.
Tue May 14 08:02:03.557 [initandlisten] exception in initAndListen: 11000 E11000 duplicate key error index: backendtemp.system.users.$user_1_userSource_1 dup key: { : "ad", : null }, terminating
Tue May 14 08:02:03.557 dbexit:
Tue May 14 08:02:03.557 [initandlisten] shutdown: going to close listening sockets...
Tue May 14 08:02:03.557 [initandlisten] shutdown: going to flush diaglog...
Tue May 14 08:02:03.557 [initandlisten] shutdown: going to close sockets...
Tue May 14 08:02:03.558 [initandlisten] shutdown: waiting for fs preallocator...
Tue May 14 08:02:03.558 [initandlisten] shutdown: lock for final commit...
Tue May 14 08:02:03.558 [initandlisten] shutdown: final commit...
Tue May 14 08:02:03.572 [initandlisten] shutdown: closing all files...
Tue May 14 08:02:03.573 [initandlisten] closeAllFiles() finished
Tue May 14 08:02:03.573 [initandlisten] journalCleanup...
Tue May 14 08:02:03.573 [initandlisten] removeJournalFiles
Tue May 14 08:02:03.575 [initandlisten] shutdown: removing fs lock...
Tue May 14 08:02:03.575 dbexit: really exiting now
答案 0 :(得分:3)
在2.4版本中,MongoDB引入了基于角色的访问控制,每个数据库需要uniqueness of the user in user privilege documents。以前版本的MongoDB没有此要求,因此您的数据库可能在system.users中有重复的用户条目。
你可以:
答案 1 :(得分:1)
关于此的小脚本馅饼( ubuntu ):
注意:替换CAPS 由您发送...
sudo apt-get install mongodb-10gen=2.2.7
< - 减少版本,可能要求2.2.7是最新的2.4之前(截至2014年5月)mongo
进行连接 CONFIG_SERVER_HOST:CONFIG_SERVER_PORT /admin
#< - 连接到mongo配置服务器,
db.system.users.find().sort({_id:1})
< - 将显示按ID排序的管理员用户,就像按时间按升序排序,因为它是bson。db.system.users.remove({_id : ObjectId('
ID_TO_BE_REMOVED ')})
< - 删除罪魁祸首,谨慎使用。如果您不确定,请先创建另一个管理员用户进行备份。sudo apt-get install mongodb-10gen
< - 将升级回最新的2.4.X.不是它不会升级到2.6(这是好的,因为你想确保2.4首先工作)因为它是一个不同的apt-get包2.6(mongodb-org)。HTH
答案 2 :(得分:0)
如果你不能或不会降级mongodb,你也可以使用mongodump
然后使用mongorestore
。您将丢失每个mongo用户,但会恢复您的数据。
mongodump --dbpath OLD_DB_PATH -d DATABASENAME -o /tmp/dumps
mongorestore --dbpath NEW_DB_PATH -d DATABASENAME /tmp/dumps/DATABASENAME/
dbpath
选项已被删除,强制您在dbpath上运行mongod来运行这些命令,这将无法正常工作,这正是无效的现在...... mongod --dbpath NEW_DB_PATH --repair