0

実行しようとしている mariadb のインスタンスが 2 つあります (下位互換性のために 1 つ必要です)。両方の docker-compose.yml は次のとおりです。

  db:
    container_name: db
    image: mariadb:latest
    ports:
      - "3306:3306"
    networks:
      devel:
        ipv4_address: 172.19.0.105
    volumes:
      - "${DATA_DIR}/mariadb:/var/lib/mysql"
    environment:
      MYSQL_ALLOW_EMPTY_PASSWORD: 1
  db2:
    container_name: db2
    image: mariadb:10.2.37
    ports:
      - "3307:3306"
    networks:
      devel:
        ipv4_address: 172.19.0.106
    volumes:
      - "${DATA_DIR}/mariadb2:/var/lib/mysql"
    environment:
      MYSQL_ALLOW_EMPTY_PASSWORD: 1

最初の db というラベルの付いたものには問題なく接続できますが、2 番目のものでは次のエラーが発生します。

ERROR 2003 (HY000): Can't connect to MySQL server on '172.19.0.106' (111)

アクセスするために実行しようとしているコマンドは次のとおりです。

mysql --user=root --host=172.19.0.106 --port=3307

接続できない理由がわかりません。情報は正しいように見えますが、機能していないため、何が間違っていたのかわかりません。

また、${DATA_DIR}docker コンテナーを開始するコマンドの一部である変数であるため、誰かが疑問に思っている場合に備えて、そこにあるはずであり、正しいです。

更新: db2 の docker ログは次のとおりです。

2021-03-16 21:53:54+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 1:10.2.37+maria~bionic started.
2021-03-16 21:53:54+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql'
2021-03-16 21:53:54+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 1:10.2.37+maria~bionic started.
2021-03-16 21:53:55 140078898230976 [Note] mysqld (mysqld 10.2.37-MariaDB-1:10.2.37+maria~bionic) starting as process 1 ...
2021-03-16 21:53:55 140078898230976 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2021-03-16 21:53:55 140078898230976 [Note] InnoDB: Uses event mutexes
2021-03-16 21:53:55 140078898230976 [Note] InnoDB: Compressed tables use zlib 1.2.11
2021-03-16 21:53:55 140078898230976 [Note] InnoDB: Using Linux native AIO
2021-03-16 21:53:55 140078898230976 [Note] InnoDB: Number of pools: 1
2021-03-16 21:53:55 140078898230976 [Note] InnoDB: Using SSE2 crc32 instructions
2021-03-16 21:53:55 140078898230976 [Note] InnoDB: Initializing buffer pool, total size = 256M, instances = 1, chunk size = 128M
2021-03-16 21:53:55 140078898230976 [Note] InnoDB: Completed initialization of buffer pool
2021-03-16 21:53:55 140078171240192 [Note] InnoDB: If the mysqld execution user is authorized, page cleaner thread priority can be changed. See the man page of setpriority().
2021-03-16 21:53:55 140078898230976 [Warning] InnoDB: Failed to set O_DIRECT on file./ibdata1;OPEN: Invalid argument, ccontinuing anyway. O_DIRECT is known to result in 'Invalid argument' on Linux on tmpfs, see MySQL Bug#26662.
2021-03-16 21:53:55 140078898230976 [Note] InnoDB: Setting log file ./ib_logfile101 size to 50331648 bytes
2021-03-16 21:53:55 140078898230976 [Note] InnoDB: Setting log file ./ib_logfile1 size to 50331648 bytes
2021-03-16 21:53:55 140078898230976 [Note] InnoDB: Renaming log file ./ib_logfile101 to ./ib_logfile0
2021-03-16 21:53:55 140078898230976 [Note] InnoDB: New log files created, LSN=8280100
2021-03-16 21:53:55 140078898230976 [Note] InnoDB: Highest supported file format is Barracuda.
2021-03-16 21:53:55 140078898230976 [Note] InnoDB: 128 out of 128 rollback segments are active.
2021-03-16 21:53:55 140078898230976 [Note] InnoDB: Creating shared tablespace for temporary tables
2021-03-16 21:53:55 140078898230976 [Note] InnoDB: Setting file './ibtmp1' size to 12 MB. Physically writing the file full; Please wait ...
2021-03-16 21:53:55 140078898230976 [Note] InnoDB: File './ibtmp1' size is now 12 MB.
2021-03-16 21:53:55 140078898230976 [Note] InnoDB: Waiting for purge to start
2021-03-16 21:53:55 140078898230976 [Note] InnoDB: 5.7.33 started; log sequence number 8280588
2021-03-16 21:53:55 140077934044928 [Note] InnoDB: Loading buffer pool(s) from /var/lib/mysql/ib_buffer_pool
2021-03-16 21:53:55 140078898230976 [Note] Plugin 'FEEDBACK' is disabled.
2021-03-16 21:53:55 140078898230976 [Note] Server socket created on IP: '::'.
2021-03-16 21:53:55 140078898230976 [Warning] 'proxies_priv' entry '@% root@98c35665786d' ignored in --skip-name-resolve mode.
2021-03-16 21:53:55 140078898230976 [Note] Reading of all Master_info entries succeeded
2021-03-16 21:53:55 140078898230976 [Note] Added new Master_info '' to hash table
2021-03-16 21:53:55 140078898230976 [Note] mysqld: ready for connections.
Version: '10.2.37-MariaDB-1:10.2.37+maria~bionic'  socket: '/var/run/mysqld/mysqld.sock'  port: 3306  mariadb.org binary distribution
2021-03-16 21:53:56 140077934044928 [Note] InnoDB: Buffer pool(s) load completed at 210316 21:53:56
4

1 に答える 1