大网数据广告活动
服务器运维问答

How to perform data replication for DBs on multi-server Docker Container setup?

· 52CE 我爱测

For setting up Disaster Recovery topology using docker, is it possible to perform data replication from one server to another without using any orchestration layer (swarm/Kubernetes)? Any way to setup MySQL Master-Master or Maste…

问题原文

原帖链接 · Rakmo · CC BY-SA 4.0

For setting up Disaster Recovery topology using docker, is it possible to perform data replication from one server to another without using any orchestration layer (swarm/Kubernetes)? Any way to setup MySQL Master-Master or Master-Slave on 2 server setup?

What I do NOT want:

  1. Data replication using shared disk space
  2. No third party tool/software
  3. No Swarm or Kubernetes

I understand that for a proper Disaster Recovery system, the standby system is recommended to be in a totally different region, and it's acceptable that there is delay in data replication. What I want to know is will the both docker containers be able to communicate with each other properly? Is there anything that needs to be configured? Or will they just communicate normally as it would have been without docker?

已采纳解答

原帖链接 · Rick James · CC BY-SA 4.0

Two db servers, physically close to each other, will achieve the goal.

  • There will still be some lag from the Primary to the Replica, but probably less than 1ms.
  • The Replica won't start performing a replicated query until it has COMMITted on the Primary. (This is another mandatory lag.) As long as your writes affect only a small number of rows, this is also sub-millisecond or low-milliseconds.
  • If Master-Master, each is allowed to receive writes, and each is both a "master" and a "slave". However, I recommend only writing to one at a time; the other is simply a hot standby.
  • M-M is M-S already set up in both directions, hence allows for simplified failover.
  • Whether each db server is actually inside a Docker container should not matter.
  • But having two separate machines provides DR, whereas two Dockers in a single server does not protect against motherboard, disk, etc, failures.
  • The pieces for failover is part of the standard issue MySQL/MariaDB, but the performing a failover is still manual.
  • If one of the two machines fails, you need to take some non-trivial effort (and time) to rebuild the other machine.
  • Two machines in the same flood plain, earthquake fault, tornado alley, etc. -- For real DR, you need geographic separation. But that leads to latency between servers. Can't have everything!

See also Galera Cluster (shipped with MariaDB; or can be added to MySQL). With it, 3 "nodes", one per server, gives automatic failover and automatic repair.

As far as I know, Docker does not introduce any extra impediments. Maybe someone else will chime in. If there are multiple MySQL instances in multiple dockers, then there is an issue of getting the Port numbers separate.

PS. dba.stackoverflow.com is a better sight for MySQL/MariaDB questions.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2021-03-19)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。