First mysql docker containers restarting when a second mysql container is started

27 Views Asked by At

When trying to create a master slave configuration in docker-compose, whenever the second mysql container is started the already running container restarts.

Running containers individually works fine.

Here is the docker-compose configuration:

version: '3'

services:
  mysql_main:
    image: mysql:8.0.30
    container_name: "mysql_main"
    restart: unless-stopped
    platform: linux/amd64
    ports:
      - "33061:3306"
    volumes:
      - mysql_volume_main:/var/lib/mysql
      - ./docker/dev-mysql/master.cnf:/etc/my.cnf
    environment:
      MYSQL_USER: dev
      MYSQL_PASSWORD: dev
      MYSQL_DATABASE: dev
      MYSQL_ROOT_PASSWORD: root
  mysql_replica:
    image: mysql:8.0.30
    container_name: "mysql_replica"
    restart: unless-stopped
    platform: linux/amd64
    ports:
      - "33062:3306"
    volumes:
      - mysql_volume_replica:/var/lib/mysql
      - ./docker/dev-mysql/slave.cnf:/etc/my.cnf
    environment:
      MYSQL_USER: dev
      MYSQL_PASSWORD: dev
      MYSQL_DATABASE: dev
      MYSQL_ROOT_PASSWORD: root

.conf files have online one config line.

[mysqld]

innodb_use_native_aio = 0

This line was added to fix the following error which seems to be happening only when both containers are running but was not happening when the second container was commented out.

Linux Native AIO interface is not supported on this platform. Please check your OS documentation and install appropriate binary of InnoDB.

Container logs:

2024-03-16 22:11:52+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.30-1.el8 started.
2024-03-16T22:11:54.146339119Z 2024-03-16 22:11:54+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql'
2024-03-16T22:11:54.300943869Z 2024-03-16 22:11:54+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.30-1.el8 started.
2024-03-16T22:11:56.561033078Z 2024-03-16T22:11:56.517045Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.30) starting as process 1
2024-03-16T22:11:56.679395620Z 2024-03-16T22:11:56.676352Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2024-03-16T22:11:57.662321496Z 2024-03-16T22:11:57.662161Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
2024-03-16T22:11:58.383858579Z 2024-03-16T22:11:58.383726Z 0 [System] [MY-010229] [Server] Starting XA crash recovery...
2024-03-16T22:11:58.394157079Z 2024-03-16T22:11:58.393995Z 0 [System] [MY-010232] [Server] XA crash recovery finished.
2024-03-16T22:11:58.536953871Z 2024-03-16T22:11:58.536663Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed.
2024-03-16T22:11:58.537577746Z 2024-03-16T22:11:58.537510Z 0 [System] [MY-013602] [Server] Channel mysql_main configured to support TLS. Encrypted connections are now supported for this channel.
2024-03-16T22:11:58.543478371Z 2024-03-16T22:11:58.543325Z 0 [Warning] [MY-011810] [Server] Insecure configuration for --pid-file: Location '/var/lib/mysql' in the path is accessible to all OS users. Consider choosing a different directory.
2024-03-16T22:11:58.671792746Z 2024-03-16T22:11:58.671639Z 0 [System] [MY-011323] [Server] X Plugin ready for connections. Bind-address: '::' port: 33060, socket: /var/run/mysqld/mysqlx.sock
2024-03-16T22:11:58.675709038Z 2024-03-16T22:11:58.675596Z 0 [System] [MY-010931] [Server] /usr/sbin/mysqld: ready for connections. Version: '8.0.30'  socket: '/var/lib/mysql/mysql.sock'  port: 3306  MySQL Community Server - GPL.

Additional info: I am running docker on a Apple M1 chip device using colima.

0

There are 0 best solutions below