5

I have mongodb 2.4 database with some indexing. Now I want to upgrade that version to 3.0. I searched on google but did not find any firm answer. I tried installing 3.0 but then it gives me error of index. Does anybody have idea about this?

Answer:

I am able to upgrade the DB. Below are the steps : 1. Install mongodb 2.6 2. Update the index of admin collection db.getSiblingDB("admin").runCommand({authSchemaUpgrade: 1 }); 3. Install mongodb 3.0

  • What's the specific error you are getting? – Stennie Mar 15 '15 at 23:04
4

Upgrade Requirements To upgrade an existing MongoDB deployment to 3.0, you must be running 2.6. If you’re running a version of MongoDB before 2.6, you must upgrade to 2.6 before upgrading to 3.0. See Upgrade MongoDB to 2.6 for the procedure to upgrade from 2.4 to 2.6. Once upgraded to MongoDB 2.6, you cannot downgrade to any version earlier than MongoDB 2.4.

http://docs.mongodb.org/manual/release-notes/2.6-upgrade/

One of the most important thing to remember after you are on 2.6 if you are trying to use WiredTiger as your storage engine, you do need to take a mongodump by connecting into current mongodb version and then switch to mongodb 3.0 with a different db path,

IMP: You will not be able to use existing DB path as previous storage on mmapv1

Command to use: mongod --storageEngine wiredTiger --dbpath

mongodump and mongorestore can operate against a running mongod process, and used to take a backup and restore the backup respectively.

http://docs.mongodb.org/manual/reference/configuration-options/

storage.engine
Default: mmapv1

New in version 3.0.0.

Specifies the storage engine for the mongod database. 
Valid options include mmapv1 and wiredTiger.

If you attempt to start a mongod with a storage.dbPath 
that contains data files produced by a storage engine other 
than the one specified by storage.engine, 
mongod will refuse to start.
1

tl;dr

Your data may be corrupted. An update to 2.6 prior to an update to 3.0 is mandatory. See below for details.

The problem

You have a problem. Reading the release notes before fiddling with and updating any software is best practise, with MongoDB's release notes being no exception.

If you had read them and the linked upgrade guide, you would have noticed that the process would have been to update to 2.6 prior to installing to 3.0

What most likely happened is that mongod assumed the data being in the format of 2.6 and converted it accordingly, which would result in corrupted data.

There is a slight chance however that the data still can be converted.

The solution (maybe)

There are two scenarios here. In case you don't have a backup, we need to try to work with the current data. It may work out or not.

The other case in which you do have a backup itself offers two scenarios: either with a backup created with mongodump or with a filesystem backup. In case you have a backup, it is basically guaranteed that the data can be restored.

... without a backup

  1. Make a copy of the data directory. Just in case.
  2. Uninstall MongoDB completely.
  3. Install MongoDB 2.4
  4. Start mongod. Try to access your data. If you can access your data, consider yourself lucky. ;) If you can't, the next steps propably won't help, but they won't do harm either, since it can't get worse any more.
  5. Stop mongod
  6. Read and understand the upgrade guide to MongoDB 2.6
  7. Follow it to the letter
  8. Read and understand the upgrade guide to MongoDB 3.0
  9. Follow it to the letter
  10. Congrats, lucky you!

... with a backup

  1. Uninstall MongoDB
  2. Delete the contents of the data directory
  3. Install MongoDB 2.4
  4. Restore the backup
  5. Read and understand the upgrade guide to MongoDB 2.6
  6. Follow it to the letter
  7. Read and understand the upgrade guide to MongoDB 3.0
  8. Follow it to the letter
  9. Congrats for making a backup, saved your neck! ;)
  • I tried with installing 2.6 and then 3.0 but it is not showing my database at all. Am i missing something? – hectk Mar 16 '15 at 13:39
  • Seems like your data files are corrupted, then. I hope we are not talking of production data... – Markus W Mahlberg Mar 16 '15 at 16:16
  • Yes it is prod data but it is totally working fin on mongo 2.6. – hectk Mar 17 '15 at 3:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.