Migrating from MongoDB 2.4 (RHSCL-1.2) to MongoDB 2.6 (RHSCL-2.0)
MongoDB is a high-performance, open source, schema-free document-oriented database. Red Hat Software Collections (RHSCL) 1.2 contains version 2.4 of MongoDB in the mongodb24 Software Collection. RHSCL 2.0 contains MongoDB 2.6 in the rh-mongodb26 Collection. See these notes to upgrade to rh-mongodb26.
General changes in rh-mongodb26
- Rename of service files
/etc/rc.d/init.d/mongodb24-mongodbrenamed to/etc/rc.d/init.d/rh-mongodb26-mongod/etc/rc.d/init.d/mongodb24-mongodb-shardrenamed to/etc/rc.d/init.d/rh-mongodb26-mongos
- Rename of configuration and sysconfig files:
- mongod uses
/etc/opt/rh/rh-mongodb26/mongod.confand/etc/opt/rh/rh-mongodb26/sysconfig/mongod - mongos uses
/etc/opt/rh/rh-mongodb26/mongos.confand/etc/opt/rh/rh-mongodb26/sysconfig/mongos
- mongod uses
- New location of log files:
- mongod writes log to
/var/opt/rh/rh-mongodb26/log/mongodb/mongod.log - mongos writes log to
/var/opt/rh/rh-mongodb26/log/mongodb/mongos.log
- mongod writes log to
- Changed the default mongos port from 27019 to 27017
- New package: rh-mongodb26-mongodb-test. This package contains the MongoDB testsuite. For more information about usage, install this package and read
/opt/rh/rh-mongodb26/root/usr/share/mongodb-test/README.
Compatibility Changes in MongoDB 2.6
In order to migrate from mongodb24 to rh-mongodb26 you need to pay attention to some minor compatibility changes in MongoDB 2.6:
- Index Changes
- Write Method Acknowledgements
- db.collection.aggregate() Change
- Write Concern Validation
- Security Changes
- The MongoDB 2.6 authorization model changes how MongoDB stores and manages user privilege information.
- The SSL certificate validation now checks the Common Name (CN) and the Subject Alternative Name (SAN) fields to ensure that either the CN or one of the SAN entries matches the hostname of the server. As a result, if you currently use SSL and neither the CN nor any of the SAN entries of your current SSL certificates match the hostnames, upgrading to version 2.6 will cause the SSL connections to fail.
- 2dsphere Index Version 2
- Log Messages
- Package Configuration Changes
- Remove Method Signature Change
- Update Operator Syntax Validation
- Updates Enforce Field Name Restrictions
- Query and Sort Changes
- Replica Set/Sharded Cluster Validation
- Time Format Changes
For complete information about changes, see Content from docs.mongodb.org is not included.Content from docs.mongodb.org is not included.http://docs.mongodb.org/master/release-notes/2.6-compatibility/.
Authentication Changes in MongoDB 2.6
MongoDB 2.6 authorization model introduces changes in the way MongoDB stores and manages user privilege information:
- MongoDB 2.6 requires at least one user in the admin database with the userAdminAnyDatabase role. Make sure that this user exists before you upgrade.
- You will not be able to create or modify users or create user-defined roles in MongoDB versions that use previous authorization models.
For details on authentication changes, see Content from docs.mongodb.org is not included.Content from docs.mongodb.org is not included.http://docs.mongodb.org/manual/release-notes/2.6-upgrade-authorization/.
Upgrading from mongodb24 to rh-mongodb26
Downgrade Limitations
Once upgraded to MongoDB 2.6, you cannot downgrade to any version earlier than MongoDB 2.4. If you created text or 2dsphere indexes while running 2.6, you can downgrade only to MongoDB 2.4.10 or later versions.
Before migrating from mongodb24 to rh-mongodb26, back up all your data, including any MongoDB databases, which are by default stored in the /opt/rh/mongodb24/root/var/lib/mongodb/ directory.
Steps to upgrade:
-
Install the mongodb server from rh-mongodb26 Software Collection.
~] # yum install rh-mongodb26 -
Stop the mongodb24 server.
~] # service mongodb24-mongodb stop -
Copy your data into the new location.
~] # cp -a /opt/rh/mongodb24/root/var/lib/mongodb/* /var/opt/rh/rh-mongodb26/lib/mongodb -
Change the dbpath variable in the
/opt/rh/mongodb24/root/etc/mongodb.conffile to /var/opt/rh/rh-mongodb26/lib/mongodb/ -
Start the mongodb24 server.
~] # service mongodb24-mongodb start -
Intstall the mongo shell from the rh-mongodb26 Software Collection.
~] # yum install rh-mongodb26-mongodb -
Connect the mongo shell from the rh-mongodb26 Collection to your mongodb24 server (for example, running on localhost ; port: 27017) .
~] $ scl enable rh-mongodb26 'mongo --host localhost --port 27017 admin' -
In the mongo shell, run the the Content from docs.mongodb.org is not included.db.upgradeCheckAllDBs() function to check your data set for compatibility.
> db.upgradeCheckAllDBs() -
Resolve all issues identified by db.upgradeCheckAllDBs() and compatibility issues mentioned above that affect your application.
-
Stop the mongodb24 server.
~] # service mongodb24-mongodb stop -
Make the mongodb24 Software Collection runnable after the upgrade by chaning dbpath back to the previous value (
/opt/rh/mongodb24/root/var/lib/mongodb/by default) in the/opt/rh/mongodb24/root/etc/mongodb.conffile. -
Configure the rh-mongodb26-mongod daemon in the
/etc/opt/rh/rh-mongodb26/mongod.conffile. -
Start the mongodb server from the rh-mongodb26 Collection.
~] # service rh-mongodb26-mongod start -
Upgrade the authorization model as described in Content from docs.mongodb.org is not included.Content from docs.mongodb.org is not included.http://docs.mongodb.org/manual/release-notes/2.6-upgrade-authorization/. Note that it is recommended to run your MongoDB deployment for a day or two before you upgrade the user authorization model because downgrades are more difficult after the user authorization model has been upgraded. Before you upgrade the authorization model, you will not be able to create or modify users or to use user-defined roles.
For ore information about upgrading, see Content from docs.mongodb.org is not included.Content from docs.mongodb.org is not included.http://docs.mongodb.org/manual/release-notes/2.6-upgrade/.
For information about upgrading a Replica Set, see Content from docs.mongodb.org is not included.Content from docs.mongodb.org is not included.http://docs.mongodb.org/manual/release-notes/2.6-upgrade/#upgrade-a-replica-set-to-2-6.
For information about upgrading a Sharded Cluster, see Content from docs.mongodb.org is not included.Content from docs.mongodb.org is not included.http://docs.mongodb.org/manual/release-notes/2.6-upgrade/#upgrade-a-sharded-cluster-to-2-6.