From 954e4331fd0df89b8f9d5acc5601cc506c405bbf Mon Sep 17 00:00:00 2001 From: koh <33595434+dungnt11@users.noreply.github.com> Date: Mon, 3 Mar 2025 16:39:36 +0700 Subject: [PATCH] =?UTF-8?q?T=E1=BB=91i=20=C6=B0u=20h=C3=B3a=20c=E1=BA=A5u?= =?UTF-8?q?=20h=C3=ACnh=20MySQL=20trong=20docker-compose.dev.yml?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Nâng cấp MySQL image lên phiên bản 8.0 - Thêm các tùy chọn cấu hình chi tiết cho hiệu suất và bảo mật - Cập nhật healthcheck và các tham số kết nối - Thêm volume khởi tạo và cấu hình character set - Điều chỉnh các tham số hiệu suất MySQL --- docker-compose.dev.yml | 27 +++++++++++++++++++++++---- logs/app.log | 2 ++ 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/docker-compose.dev.yml b/docker-compose.dev.yml index c51cfee..aa7b100 100644 --- a/docker-compose.dev.yml +++ b/docker-compose.dev.yml @@ -32,7 +32,7 @@ services: networks: - blueprint mysql_bp: - image: mysql:latest + image: mysql:8.0 platform: linux/arm64 restart: unless-stopped environment: @@ -40,16 +40,35 @@ services: MYSQL_USER: ${BLUEPRINT_DB_USERNAME} MYSQL_PASSWORD: ${BLUEPRINT_DB_PASSWORD} MYSQL_ROOT_PASSWORD: ${BLUEPRINT_DB_ROOT_PASSWORD} + MYSQL_ALLOW_EMPTY_PASSWORD: "no" ports: - - "${BLUEPRINT_DB_PORT}:3306" + - "3306:3306" volumes: - mysql_volume_bp:/var/lib/mysql + - ./mysql/init:/docker-entrypoint-initdb.d + command: > + --default-authentication-plugin=mysql_native_password + --character-set-server=utf8mb4 + --collation-server=utf8mb4_unicode_ci + --skip-name-resolve + --explicit_defaults_for_timestamp=1 + --max_connections=1000 + --innodb_buffer_pool_size=256M + --innodb_log_buffer_size=16M + --innodb_log_file_size=256M + --innodb_write_io_threads=8 + --innodb_read_io_threads=8 + --innodb_thread_concurrency=0 + --innodb_flush_log_at_trx_commit=2 + --innodb_flush_method=O_DIRECT + --innodb_file_per_table=1 + --bind-address=0.0.0.0 healthcheck: - test: ["CMD", "mysqladmin", "ping", "-h", "localhost", "-u", "${BLUEPRINT_DB_USERNAME}", "--password=${BLUEPRINT_DB_PASSWORD}", "--silent"] + test: ["CMD", "mysqladmin", "ping", "-h", "localhost", "-u", "root", "-p${BLUEPRINT_DB_ROOT_PASSWORD}", "--connect-timeout=5"] interval: 10s timeout: 5s retries: 5 - start_period: 40s + start_period: 180s networks: - blueprint diff --git a/logs/app.log b/logs/app.log index e7e2984..a4339dd 100644 --- a/logs/app.log +++ b/logs/app.log @@ -121,3 +121,5 @@ {"level":"INFO","time":"2025-03-03T07:00:37.818Z","caller":"initialize/run.go:63","msg":"Server đang chạy trên cổng 8080"} {"level":"INFO","time":"2025-03-03T07:01:19.523Z","caller":"initialize/mysql.go:31","msg":"Initializing MySQL Successfully"} {"level":"INFO","time":"2025-03-03T07:01:19.524Z","caller":"initialize/run.go:63","msg":"Server đang chạy trên cổng 8080"} +{"level":"INFO","time":"2025-03-03T09:36:38.123Z","caller":"initialize/mysql.go:31","msg":"Initializing MySQL Successfully"} +{"level":"INFO","time":"2025-03-03T09:36:38.127Z","caller":"initialize/run.go:63","msg":"Server đang chạy trên cổng 8080"}