Is there any best practice for upgrading mongodb data structure for prod environment

  mongodb, question

At present, there are some tools that can easily upgrade the structure of the online database. For example, rails written by ruby and doctrine written by php have migration. I wonder if mongodb has any convenient method to upgrade the structure of the database.

MongoDB upgrade database is relatively convenient, such as non-special version update, basically do not have to stop service.

1. If your data structure changes, MongoDB’s Schemaļ¼free mechanism enables you to avoid migration.

2. If you want to use the new features in the new version, you really have to migrate the data. A more common method is through its Replication mechanism. You can look at the official release notes of the corresponding version, and usually you will write whether Replication can be used for upgrade. if not, it may be because the new version has already been changed in the replication protocol. Then you may have to stop the service to do the migration.

3. Before stopping the service migration, you can also migrate the current data through mongodump and mongorestore, then stop the service and then migrate the incremental data, usually without stopping the service for too long.