search

Home  >  Q&A  >  body text

nosql - 对于prod环境升级mongodb数据结构有没有什么best practice

目前有一些工具可以很方便的升级线上的数据库的结构,比如ruby写的rails以及php的doctrine都有migration,不知道mongodb有没有很方便升级库结构的方法。

高洛峰高洛峰2799 days ago834

reply all(2)I'll reply

  • PHP中文网

    PHP中文网2017-04-21 10:59:11

    It is relatively convenient to upgrade the MongoDB database. Unless there is a special version update, there is basically no need to stop the service.

    1. If your data structure changes, MongoDB’s Schema-free mechanism allows 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 way is through its Replication mechanism. You can take a look at the official release notes of the corresponding version. It usually states whether Replication can be used during upgrades. If it cannot be used, it may be because this new version has changes in the Replicastion protocol. Then you may have to stop the service to do the migration.

    3. Before stopping the service for migration, you can also migrate the current data through mongodump and mongorestore, then stop the service and then migrate the incremental data. Usually the service will not be stopped for too long.

    reply
    0
  • 阿神

    阿神2017-04-21 10:59:11

    No, you can only make the agreement in the program yourself.

    This is also the biggest problem with this type of document-oriented database. We have to be careful when developing it, because we can only maintain one database structure on the client side, in case a developer inserts more or less fields. , the server is acceptable.

    What’s even more distressing is that sometimes the client is not unique, so we have to maintain the same data structure on different clients, which brings great inconvenience to the upgrade of the data structure. Document-oriented design was originally intended to liberate the dependence on data structures, but it did not solve the arbitrariness caused by the lack of data structure conventions.

    reply
    0
  • Cancelreply