用于工作站开发/测试的 MySQL 数据库同步

发布于 2024-09-13 08:50:48 字数 318 浏览 2 评论 0原文

我需要生产数据库的本地副本,并且需要每隔几天刷新一次,因此测试和开发无法使用非常陈旧的数据。几天就好了。这是伪计划:

  1. 在生产服务器上编写一个脚本,对数据库进行 mysqldump + gzip。
  2. 添加一个 cron 进程,在非高峰时段每隔一天运行一次脚本。
  3. 在 rsync 的 gzip 转储工作站上编写一个脚本并将其加载。

有没有更好、更清洁或更安全的方法来做到这一点?

编辑:只是为了增加清晰度。我们仍然拥有已知的测试数据以及我们的测试库(测试驱动开发)。一旦这些测试通过,就可以接触到(更多)真实的东西了。

I need a local copy of our production database, and I need to refresh it every few days so testing and development is not working with terribly stale data. A few days old is just fine. Here is the pseudo plan:

  1. Write a script on the Production server that mysqldump's + gzip the database.
  2. Add a cron process to run the script every other day during non-peak hours.
  3. Write a script on the workstation that rsync's that gzipped dump and loads it up.

Is there any better, cleaner, or safer way of doing this?

EDIT: Just to add clarity. We still have in place Test Data that is known, along with our test library (test driven development). Once THOSE tests pass, its on to the (more) real stuff.

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

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

发布评论

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

评论(2

酒绊 2024-09-20 08:50:48

您可能希望考虑 MySQL 复制。这不是一件容易被忽视的事情,但可能正是您正在寻找的东西。更多信息在这里... http://dev.mysql。 com/doc/refman/5.0/en/replication-features.html(除了可以完成之外,我个人对此一无所知)。

You may wish to consider MySQL replication. It isn't a thing to be trifled with but may be what you are looking for. More information here... http://dev.mysql.com/doc/refman/5.0/en/replication-features.html (I don't personally know anything about it other than that it can be done).

伤感在游骋 2024-09-20 08:50:48

测试应该使用“已知”数据;不是生产数据。您应该有脚本将“测试”数据加载到系统中以实现此目的。测试/开发不必处理移动的数据目标。此外,如果您在生产中有任何敏感数据(不是每个人);您的开发/测试团队不应该访问它。

创建测试数据的一些建议:
1) Excel 电子表格,背后带有 VBA,用于创建针对数据库运行的 SQL
2)原始sql脚本
3) 以已知模式生成数据的数据创建程序。

Testing should be working with "known" data; not production data. You should have scripts to load "Test" data into the system to achieve this. Test/Dev shouldn't have to deal with a moving target of data. Besides, if you have any sensitive data in production (doesn't everyone"); your dev/test teams shouldn't have access to it.

Some suggestions for creating test data:
1) Excel spreadsheets with VBA behind them to create sql to run against the DB
2) Raw sql scripts
3) Data creation programs that generate data in a known pattern.

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