Considerations and Compatibility If you upgrade to MongoDB 2.4, and then need to run MongoDB 2.2 with the same data files, consider the following limitations. 

• If you use a hashed index as the shard key index, which is only possible under 2.4 you will not be able to query data in this sharded collection. Furthermore, a 2.2 mongos cannot properly route an insert operation for a collections sharded using a hashed index for the shard key index: any data that you insert using a 2.2 mongos , will not arrive on the correct shard and will not be reachable by future queries. 

• If you never create an 2dsphere or text index, you can move between a 2.4 and 2.2 mongod for a given data set; however, after you create the first 2dsphere or text index with a 2.4 mongod you will need to run a 2.2 mongod with the --upgrade option and drop any 2dsphere or text index. 

## Upgrade and Downgrade Procedures 

Basic Downgrade and Upgrade Except as described below, moving between 2.2 and 2.4 is a drop-in replacement: 

• stop the existing mongod , using the --shutdown option as follows: 

mongod --dbpath /var/mongod/data --shutdown 

Replace /var/mongod/data with your MongoDB dbPath . 

• start the new mongod processes with the same dbPath setting, for example: 

mongod --dbpath /var/mongod/data 

Replace /var/mongod/data with your MongoDB dbPath . 

Downgrade to 2.2 After Creating a 2dsphere or text Index If you have created 2dsphere or text in- dexes while running a 2.4 mongod instance, you can downgrade at any time, by starting the 2.2 mongod with the --upgrade option as follows: 

mongod --dbpath /var/mongod/data/ --upgrade 

Then, you will need to drop any existing 2dsphere or text indexes using db.collection.dropIndex() , for example: 

db.records.dropIndex( { loc: "2dsphere" } ) db.records.dropIndex( "records_text" ) 

Warning: --upgrade will run repairDatabase on any database where you have created a 2dsphere or text index, which will rebuild all indexes. 

Troubleshooting Upgrade/Downgrade Operations If you do not use --upgrade , when you attempt to start a 2.2 mongod and you have created a 2dsphere or text index, mongod will return the following message: 

'need to upgrade database index_plugin_upgrade with pdfile version 4.6, new version: 4.5 Not 

While running 2.4, to check the data file version of a MongoDB database, use the following operation in the shell: 

db.getSiblingDB('<databasename>').stats().dataFileVersion 

