MySQL数据库远程备份
我们的 Java 服务器应用程序将数据记录到 SQL 数据库,该数据库可能位于也可能不在同一台计算机上。目前我们使用 MS SQL Server,现在正在移植到 MySQL。用户在我们的应用程序服务器上配置数据库备份参数,例如运行备份的时间,并且应用程序服务器在适当的时间通过存储过程执行 SQL Server 的 BACKUP DATABASE 命令。它每天进行增量备份,每周进行完整备份。
MySQL 缺乏一个等效的功能来告诉数据库从客户端连接进行自我备份。我们正在考虑的选项是:
- 创建一个 UDF 来 shell 到 mysqldump(或复制数据库文件),它可以通过存储过程从我们的应用程序服务器调用。本质上,我们将实现 MySQL 的备份数据库版本。
- 创建一个在 MySQL 机器上运行的服务,该服务可以从应用服务器获取备份设置并在本地运行 mysqldump(或文件复制)。
- 创建一个备份存储过程来模拟 mysqldump,例如为每个表显示创建表并选择 INTO OUTFILE。
设置 cron 作业、Perl 脚本、第三方应用程序或其他在数据中心有效的技巧不是首选;这是一个收缩包装,需要非常坚固且不需手动操作。
数据库大小的范围约为 10MB 到 10GB。
我知道增量部分的二进制日志。我认为如果我们决定使用它们,通用解决方案也可能适用于它们。
这一切都在 Windows 2003 32 位或 2008R2 64 位、MySQL 5.1 上进行。
UDF 选项对我来说似乎是最好的。 UDF存储库(http://www.mysqludf.org/)有mysqludf_sys,这可能是我们所有的需要,但我想我应该征求意见,因为经过广泛的谷歌搜索后,似乎其他人并没有得出相同的结论,或者也许我们的需求只是不寻常。我们的应用程序是 MySQL 中唯一的东西,所以我不担心其他用户可以访问我们的 UDF。
我忽略了任何解决方案吗?有以这种方式使用 UDF 的经验吗?
谢谢, 埃里克
Our Java server application logs data to a SQL database, which may or may not be on the same machine. Currently we use MS SQL Server, and we're now porting to MySQL. A user configures database backup parameters on our app server, e.g. time of day to run a backup, and the app server executes SQL Server's BACKUP DATABASE command at the appropriate time, via a sproc. It does incremental backups daily and full backups weekly.
MySQL lacks an equivalent feature to tell the database from a client connection to back itself up. Options we're considering are:
- Create a UDF to shell out to mysqldump (or copy database files), which can be called from our app server via a sproc. Essentially we'd be implementing a version of BACKUP DATABASE for MySQL.
- Create a service to run on the MySQL box that can get the backup settings from the app server and run mysqldump (or file copy) locally.
- Create a backup sproc to mimic mysqldump, e.g. SHOW CREATE TABLES and SELECT INTO OUTFILE for each table.
Setting up a cron job, Perl script, third-party app or other tricks that'd work great in a data center aren't preferred; this is a shrink-wrap package that needs to be pretty robust and hands off.
Database sizes can range from roughly 10MB to 10GB.
I'm aware of the binary logs for the incremental piece. I figure the general solution will probably apply to them as well, if we decide to use them.
This is all on Windows 2003 32-bit or 2008R2 64-bit, MySQL 5.1.
The UDF option seems the best to me. The UDF Repository (http://www.mysqludf.org/) has mysqludf_sys, which may be all we need, but I thought I'd ask for opinions since after extensive googling it doesn't seem like others have reached the same conclusion, or maybe our needs are just out of the ordinary. Our app is the only thing in MySQL, so I'm not worried about other users having access to our UDF.
Any solutions I'm overlooking? Any experience with using UDFs in such a way?
Thanks,
Eric
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
由于这个原因和其他原因,我们决定将应用程序与数据库并置,因此这个问题变得毫无意义。
For this an other reasons we decided to collocate our application with the database, so this problem became moot.