保持本地 MySQL 数据库与实时数据库同步(MySQL 复制?)

发布于 2024-09-05 06:32:13 字数 201 浏览 4 评论 0原文

我目前有一个大型生产数据库(7GB+),测试我的开发分支所需的大部分数据都需要是最新的。

我想创建一个本地数据库,这样我就可以实现 CI 服务器并将开发数据库与生产数据库分开,但是对于这种大小的数据库,我如何确保它始终同步?

我考虑过复制,但是如果连接到本地服务器或我更改了数据库结构怎么办,这将如何影响复制?

谢谢,

加文

I have a large production database at the moment (7GB+), much of the data I require to test my development branches needs to be up to date.

I would like to create a local DB so I can implement a CI server and have the development DB separate to the production DB, however with a DB of this size how do I ensure it's always in sync?

I have thought about replication, but what if the connection is down to my local server or I have changed the DB structure how will this effect the replication?

Thanks,

Gavin

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

一世旳自豪 2024-09-12 06:32:13

考虑到您可能在开发过程中在投入生产之前很久就对表进行更改,您打算如何使开发数据库与生产保持同步?

是的,这就是问题的一部分,我
不知道是否有可能做到
给定的模式可能会改变
相当多..

很难有任何自动同步不会消除您的开发更改或导致您的开发更改出现问题。

因此,我建议您仅在需要时手动恢复生产备份。设置一个作业来完成工作,然后根据需要运行它(不要将其放在时间表中)。尽可能长时间地使用当前数据进行必要的开发。当您需要刷新时,请确保您已实施/保存所有开发更改到文件,然后将备份恢复到开发。如果您已“发布”到生产环境,然后再恢复。您需要确定什么最有效。但是,请确保恢复时不会丢失任何开发更改!

如果您需要拥有最新的本地版本来支持和调试生产问题,请设置“支持”数据库并使用复制。不要在那里做开发工作,有一个专门的开发数据库。

how do you plan to keep a development database in sync with production, considering that you may make table changes in development long before they get into production?

yeah that's part of the problem, I
don't know if its even possible to do
that given the schema could change
quite a bit..

It will be very difficult to have any automatic synchronization that will not wipe out your or cause problems with your development changes.

So, I recommend that you restore a production backup manually and only when you need to. Set up a job to do the work, and just run it as necessary (don't put it on a schedule). Develop as necessary using the current data as long as you can. When you need a refresh, make sure you have implemented/saved to files all of your development changes, and then restore a backup to development. If you have make "releases" to production, then restore after that. You'll need to determine what works best. However, just make sure you don't lose any development changes when restoring!

If you need to have a local version that is up to date for support and debugging production problems, set up a "Support" database and use replication. Don't do develop work there, have a dedicated development database.

栀梦 2024-09-12 06:32:13

考虑将整个数据库以 SQL 语句(架构和实际数据)的形式转储到文本文件,然后将它们置于某个跟踪更改的版本控制系统下。

Consider dumping the whole database to text files in form of sql statements (schema and actual data) and then putting them under some version control system that will track changes.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文