将数据库dockerize(容器化)是否有意义?[英] Does it make sense to dockerize (containerize) databases?

本文是小编为大家收集整理的关于将数据库dockerize(容器化)是否有意义?的处理/解决方法,可以参考本文帮助大家快速定位并解决问题,中文翻译不准确的可切换到English标签页查看源文。

问题描述

我可以理解Dockerization无状态服务的背后的BENFIT,例如Web服务器,应用程序服务器,负载平衡器等...如果您在一组机器上运行这些服务,则很容易以低点移动这些容器高架.我不明白的是集装数据库背后的目的?数据库连接到特定硬盘中持续存在的数据量.由于状态,实际移动数据库容器并不容易,而且效率不高.那么谁能看到为什么数据库完全有用?

推荐答案

"所以任何人都可以看到为什么数据库根本可以有用吗?"

好的问题Keeto.容器化数据库的主要原因之一是,您可以为整个应用程序,不仅仅是无状态零件,跨越,登台和生产而具有相同的一致环境.一致的环境是Docker的承诺之一,但是当您的数据库生活在此模型之外时,在您的测试中无法解释一个很大的差异.另外,通过容忍数据库以及应用程序的其余部分,您更有可能在托管提供商之间移动整个应用程序(例如,从AWS到Google Compute).例如,如果您使用Amazon RDS,即使您可以将网络节点移至​​Google,也无法移动数据库,这意味着您在很大程度上依赖云提供商.

容器化数据服务的另一个原因是性能.服务提供商尤其如此(所有数据库作为服务产品 - 例如 Rackspace Cloud数据库 - 在容器中运行),因为容器允许您提供服务保证,而使用虚拟化不可能,并且每个物理计算机运行一个数据库在经济上不可行.很可能您没有运行托管服务的数据库,但是如果您在裸机上运行并想将容器用于过程隔离,而不是VM,则此类比是有道理的.由于众所周知的I/O在VM中运行DB时,您将获得更好的数据库性能.

我并不是说您应该容忍数据库,但这是有意义的一些原因.

全面披露,我为clusterhq工作,这是马克·奥康纳(Mark O'Connor)在答案中提到的新项目.我们有一个名为Flocker的OpenSource项目,它使迁移数据库及其之间的数量变得更加容易,因此我上面提到的好处并没有完全超过您在问题中提出的负面因素.

其他推荐答案

不确定我会同意您对效率的评论...与本地安装相比,下载和运行数据库容器要容易得多. Docker文档描述了如何在状态容器及其数据之间实现干净的逻辑分离:

但是...您是正确的,除非有一些机制也可以将数据移植到周围.

一个明显的解决方案是在所有可能运行数据库的主机上安装共享存储量.

以下文章讨论了一种非常创新的解决方案,其中使用类似Bittorrent的客户端来复制主机之间的数据容器.

最后,一个名为Flocker的新项目正在尝试通过管理状态容器及其相关的ZFS卷来解决此问题:

  • https://github.com/clusterhq/flocker

其他推荐答案

这是一个很好的线程,SQL Server克隆的最新进度将为使用克隆的容器使用其他功能.这解决了大型数据集的一些工作问题问题.全面披露,我在Windocks工作,我们已经使用具有集成数据库克隆的SQL Server容器发布了2.0.

本文地址:https://www.itbaoku.cn/post/597507.html

问题描述

I can understand the benfits behind dockerizing stateless services, such as web servers, appservers, load balancers, etc... If you are running these services on a cluster of machines, it is very easy to move these containers around with low overhead. What I don't understand though is the purpose behind containerizing databases? databases are connected to a data volume that is persistent in a specific hard disk. Because of state, it is not easy, and not efficient to actually move the database container around. So can anyone see why dockerizing a database can be useful at all?

推荐答案

"So can anyone see why dockerizing a database can be useful at all?"

Good question Keeto. One of the main reasons for containerizing your databases is so that you can have the same consistent environment for your entire app, not just the stateless parts, across dev, staging and production. A consistent environment is one of the promises of docker, but when your database lives outside this model, there is a big difference that can't be accounted for in your testing. Also, by containerizing your database as well as the rest of your app, you are more likely to be able to move your entire app between hosting providers (say from AWS to Google Compute). If you use Amazon RDS, for example, even if you can move your web nodes to Google, you won't be able to move your database, meaning that you are heavily dependent on your cloud provider.

Another reason for containerizing data services is performance. This is particularly true for service providers (all the database as a service offerings- e.g. rackspace cloud databases- run in containers), because containers allow you to provide service guarantees that aren't possible using virtualization, and running one database per physical machine is not financially viable. Chances are you aren't running a databases hosting service, but this analogy makes similar sense if you are running on bare metal and want to use containers for process isolation, instead of VMs. You'll get better performance for your databases because of the well-known i/o hit you take when running a db in a VM.

I'm not saying that you should containerize your database, but these are some of the reasons why it would make sense.

Full disclosure, I work for clusterhq, that new project that Mark O'connor mentioned in his answer. We have an opensource project called Flocker that makes it much easier to migrate databases and their volumes between hosts so that the benefits I mentioned above aren't completely outweighed by the negatives that you raised in your question.

其他推荐答案

Not sure I'd agree with your comment on efficiency... It's a lot easier to download and run a database container, compared to installing it natively. The docker documentation describes how to implement a clean logical separation between a stateful container and its data:

But... you are correct that a stateful container would be tied to it's host server, unless there is some mechanism to port the data around as well.

One obvious solution is to mount a shared storage volume on all the hosts that might be running your database.

The following article discusses a very innovative solution where a a bittorrent-like client is used to replicate a data container between hosts.

Finally a new project called flocker is attempting to solve this problem by managing both the stateful containers and their associated ZFS volumes:

其他推荐答案

This is a good thread, and recent progress in SQL Server cloning would add additional capabilities to use of Containers with clones. This addresses some of the problems of workign with large data sets. Full disclosure, I work for Windocks, where we've released 2.0 with SQL Server containers with integrated database cloning.