nosql - 对于prod环境升级mongodb数据结构有没有什么best practice
高洛峰
高洛峰 2017-04-21 10:57:11
0
2
829

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

高洛峰
高洛峰

拥有18年软件开发和IT教学经验。曾任多家上市公司技术总监、架构师、项目经理、高级软件工程师等职务。 网络人气名人讲师,...

reply all(2)
洪涛

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.

阿神

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.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template