出口运输码头容器的tarball是否安全? [英] Is it safe to export tarball of running docker container?
问题描述
一些简单的容器已经在生产服务器中运行。
目前我坚持如何进行容器备份。
假设我已经运行复杂的docker容器与主管+ apache + memcached + mysql里面hi加载(10k请求每秒)。
可以安全地使
docker export> backup.tar
或者我必须停止容器内的所有进程,只有在导出容器到tar文件之后才能停止。
如果以安全表示一致,那么导出的档案将是文件系统一致。
docker export
命令,作为任何其他经典的备份方法,都不会解决应用程序一致的问题。
Apache和Memcached不会是一个问题,因为他们不需要存储来维护任何状态。
但是,如果从 docker export
生成的映像运行容器,则以这种方式备份Mysql可能会使您的数据库以恢复模式重新启动。
特别是,如果在执行写入活动(insert,updates ..)时备份,
与任何其他文件系统级备份一样,您将会丢失一些事务。 / p>
如果您需要将Mysql备份的数据文件保持100%一致,并反映数据的确切状态,则必须:
- 在运行
停止Mysql之前,停靠整个容器
- 在运行导出命令之前,连接到Mysql的东西,并运行
具有读锁定的flush表;
。导出完成后,您必须运行unlock tables;
备份的数据文件(通常在/ var / lib / mysql下)将一致。 - 使用古典的Mysql备份工具(
mysqldump
...)
I am playing a couple of days with docker.io. It is awesome! Some simple containers already run in production servers.
At the moment I stuck in how to make container backup. Assume I have running complicated docker container with supervisor+apache+memcached+mysql inside under hi load (10k requests per second). Is it safe to make
docker export > backup.tar
Or I have to stop all processes inside container and only after that export container to tar file?
If by "safe" you mean "consistent", then the exported archive will be filesystem consistent.
The docker export
command, as any other classical backup method, won't solve the problem of being application consistent.
Apache and Memcached won't be an issue, since they don't need storage to maintain any kind of state.
But backuping Mysql this way will probably make your database restart in recovery mode, if you run a container from the image generated by docker export
.
In particular, if backuped when having to perform write activity (insert, updates..), as with any other filesystem-level backup, you will loose a few transactions.
If you need your Mysql backuped datafiles to be 100% consistent and to reflect the exact state of your data, you have to either:
- Stop Mysql before running
docker export
- Stop the whole container
- Have something connecting to Mysql before running the export command, and run
flush tables with read lock;
. When the export completes, you'd have to rununlock tables;
The backuped data files (generally under /var/lib/mysql) will be consistent. - Use the classical Mysql backup tools (
mysqldump
...)
这篇关于出口运输码头容器的tarball是否安全?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!