[英]Docker multiple MySQL containers with persistence
I am trying to setup two MySQL containers and one data-only container for persisting MySQL data using Docker Compose. 我正在尝试使用Docker Compose设置两个MySQL容器和一个仅用于数据的容器来保存MySQL数据。
Here is docker-compose.yml: 这是docker-compose.yml:
db1:
image: mysql
volumes_from:
- data
environment:
- MYSQL_ROOT_PASSWORD=password
db2:
image: mysql
volumes_from:
- data
environment:
- MYSQL_ROOT_PASSWORD=password
data:
image: mysql
volumes:
- /var/lib/mysql
entrypoint: /bin/echo
However, both mysql daemons have conflict, because they need a separate data directory: 但是,两个mysql守护进程都有冲突,因为它们需要一个单独的数据目录:
[Note] InnoDB: Check that you do not already have another mysqld process using the same InnoDB data or log files.
[ERROR] InnoDB: Unable to lock ./ibdata1 error: 11
Consequently, I have two questions: 因此,我有两个问题:
As far as I know, the MySQL daemon would request an exclusive lock on the data files. 据我所知,MySQL守护进程会请求对数据文件进行独占锁定。 This lock would then prevent the second instance from spinning up, which might explain the error you're seeing.
这个锁会阻止第二个实例旋转,这可能解释了你所看到的错误。
Perhaps try doing a master slave rig where you have two different volumes, but the slave (db2) is tied to db1? 也许尝试做一个主奴隶装备,你有两个不同的卷,但奴隶(db2)绑定到db1?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.