Optimize mysql script incompatibility issues.

This commit is contained in:
pader 2022-09-29 17:26:45 +08:00
parent 59d04f037b
commit 6cc4352394
11 changed files with 85 additions and 32 deletions

View File

@ -5,4 +5,5 @@ MYSQL_SERVICE_HOST=mysql
MYSQL_SERVICE_DB_NAME=nacos_devtest
MYSQL_SERVICE_PORT=3306
MYSQL_SERVICE_USER=nacos
MYSQL_SERVICE_PASSWORD=nacos
MYSQL_SERVICE_PASSWORD=nacos
MYSQL_SERVICE_DB_PARAM=characterEncoding=utf8&connectTimeout=1000&socketTimeout=3000&autoReconnect=true&useSSL=false&allowPublicKeyRetrieval=true

3
env/nacos-ip.env vendored
View File

@ -4,4 +4,5 @@ MYSQL_SERVICE_HOST=mysql
MYSQL_SERVICE_DB_NAME=nacos_devtest
MYSQL_SERVICE_PORT=3306
MYSQL_SERVICE_USER=nacos
MYSQL_SERVICE_PASSWORD=nacos
MYSQL_SERVICE_PASSWORD=nacos
MYSQL_SERVICE_DB_PARAM=characterEncoding=utf8&connectTimeout=1000&socketTimeout=3000&autoReconnect=true&useSSL=false&allowPublicKeyRetrieval=true

View File

@ -6,4 +6,4 @@ MYSQL_SERVICE_DB_NAME=nacos_devtest
MYSQL_SERVICE_PORT=3306
MYSQL_SERVICE_USER=nacos
MYSQL_SERVICE_PASSWORD=nacos
MYSQL_SERVICE_DB_PARAM=characterEncoding=utf8&connectTimeout=1000&socketTimeout=3000&autoReconnect=true&useSSL=false
MYSQL_SERVICE_DB_PARAM=characterEncoding=utf8&connectTimeout=1000&socketTimeout=3000&autoReconnect=true&useSSL=false&allowPublicKeyRetrieval=true

View File

@ -6,7 +6,6 @@ services:
image: nacos/nacos-server:${NACOS_VERSION}
volumes:
- ./cluster-logs/nacos1:/home/nacos/logs
- ./init.d/custom.properties:/home/nacos/init.d/custom.properties
ports:
- "8848:8848"
- "9848:9848"
@ -21,7 +20,6 @@ services:
container_name: nacos2
volumes:
- ./cluster-logs/nacos2:/home/nacos/logs
- ./init.d/custom.properties:/home/nacos/init.d/custom.properties
ports:
- "8849:8848"
- "9849:9848"
@ -34,7 +32,6 @@ services:
container_name: nacos3
volumes:
- ./cluster-logs/nacos3:/home/nacos/logs
- ./init.d/custom.properties:/home/nacos/init.d/custom.properties
ports:
- "8850:8848"
- "9850:9848"

View File

@ -1,4 +1,4 @@
version: "3"
version: "3.8"
services:
nacos1:
hostname: nacos1
@ -6,7 +6,6 @@ services:
image: nacos/nacos-server:${NACOS_VERSION}
volumes:
- ./cluster-logs/nacos1:/home/nacos/logs
- ./init.d/custom.properties:/home/nacos/init.d/custom.properties
ports:
- "8848:8848"
- "9848:9848"
@ -15,7 +14,8 @@ services:
- ../env/nacos-hostname.env
restart: always
depends_on:
- mysql
mysql:
condition: service_healthy
nacos2:
hostname: nacos2
@ -23,7 +23,6 @@ services:
container_name: nacos2
volumes:
- ./cluster-logs/nacos2:/home/nacos/logs
- ./init.d/custom.properties:/home/nacos/init.d/custom.properties
ports:
- "8849:8848"
- "9849:9848"
@ -31,14 +30,14 @@ services:
- ../env/nacos-hostname.env
restart: always
depends_on:
- mysql
mysql:
condition: service_healthy
nacos3:
hostname: nacos3
image: nacos/nacos-server:${NACOS_VERSION}
container_name: nacos3
volumes:
- ./cluster-logs/nacos3:/home/nacos/logs
- ./init.d/custom.properties:/home/nacos/init.d/custom.properties
ports:
- "8850:8848"
- "9850:9848"
@ -46,14 +45,25 @@ services:
- ../env/nacos-hostname.env
restart: always
depends_on:
- mysql
mysql:
condition: service_healthy
mysql:
container_name: mysql
image: nacos/nacos-mysql:5.7
build:
context: .
dockerfile: ./image/mysql/5.7/Dockerfile
tags:
- "example/mysql:5.7"
image: example/mysql:5.7
env_file:
- ../env/mysql.env
volumes:
- ./mysql:/var/lib/mysql
ports:
- "3306:3306"
healthcheck:
test: [ "CMD", "mysqladmin" ,"ping", "-h", "localhost" ]
interval: 5s
timeout: 10s
retries: 10

View File

@ -1,4 +1,4 @@
version: "2"
version: "3.8"
services:
nacos1:
image: nacos/nacos-server:${NACOS_VERSION}
@ -16,7 +16,8 @@ services:
- ../env/nacos-ip.env
restart: on-failure
depends_on:
- mysql
mysql:
condition: service_healthy
nacos2:
image: nacos/nacos-server:${NACOS_VERSION}
@ -33,7 +34,8 @@ services:
- ../env/nacos-ip.env
restart: always
depends_on:
- mysql
mysql:
condition: service_healthy
nacos3:
image: nacos/nacos-server:${NACOS_VERSION}
container_name: nacos3
@ -49,10 +51,16 @@ services:
- ../env/nacos-ip.env
restart: always
depends_on:
- mysql
mysql:
condition: service_healthy
mysql:
container_name: mysql
image: nacos/nacos-mysql:5.7
build:
context: .
dockerfile: ./image/mysql/5.7/Dockerfile
tags:
- "example/mysql:5.7"
image: example/mysql:5.7
networks:
nacos_net:
ipv4_address: 172.16.238.13
@ -62,6 +70,11 @@ services:
- ./mysql:/var/lib/mysql
ports:
- "3306:3306"
healthcheck:
test: [ "CMD", "mysqladmin" ,"ping", "-h", "localhost" ]
interval: 5s
timeout: 10s
retries: 10
networks:
nacos_net:
driver: bridge

View File

@ -0,0 +1,5 @@
FROM mysql:5.7.39
ADD https://raw.githubusercontent.com/alibaba/nacos/develop/distribution/conf/mysql-schema.sql /docker-entrypoint-initdb.d/nacos-mysql.sql
RUN chown -R mysql:mysql /docker-entrypoint-initdb.d/nacos-mysql.sql
EXPOSE 3306
CMD ["mysqld", "--character-set-server=utf8mb4", "--collation-server=utf8mb4_unicode_ci"]

View File

@ -0,0 +1,5 @@
FROM mysql:8.0.30
ADD https://raw.githubusercontent.com/alibaba/nacos/develop/distribution/conf/mysql-schema.sql /docker-entrypoint-initdb.d/nacos-mysql.sql
RUN chown -R mysql:mysql /docker-entrypoint-initdb.d/nacos-mysql.sql
EXPOSE 3306
CMD ["mysqld", "--character-set-server=utf8mb4", "--collation-server=utf8mb4_unicode_ci"]

View File

@ -4,14 +4,13 @@ services:
image: nacos/nacos-server:${NACOS_VERSION}
container_name: nacos-standalone
environment:
- PREFER_HOST_MODE=hostname
- MODE=standalone
- PREFER_HOST_MODE=hostname
- MODE=standalone
volumes:
- ./standalone-logs/:/home/nacos/logs
- ./init.d/custom.properties:/home/nacos/init.d/custom.properties
- ./standalone-logs/:/home/nacos/logs
ports:
- "8848:8848"
- "9848:9848"
- "8848:8848"
- "9848:9848"
prometheus:
container_name: prometheus
image: prom/prometheus:latest

View File

@ -1,4 +1,4 @@
version: "2"
version: "3.8"
services:
nacos:
image: nacos/nacos-server:${NACOS_VERSION}
@ -13,17 +13,29 @@ services:
- "9848:9848"
- "9555:9555"
depends_on:
- mysql
mysql:
condition: service_healthy
restart: on-failure
mysql:
container_name: mysql
image: nacos/nacos-mysql:5.7
build:
context: .
dockerfile: ./image/mysql/5.7/Dockerfile
tags:
- "example/mysql:5.7"
image: example/mysql:5.7
env_file:
- ../env/mysql.env
volumes:
- ./mysql:/var/lib/mysql
ports:
- "3306:3306"
healthcheck:
test: [ "CMD", "mysqladmin" ,"ping", "-h", "localhost" ]
interval: 5s
timeout: 10s
retries: 10
# prometheus:
# container_name: prometheus
# image: prom/prometheus:latest

View File

@ -1,4 +1,4 @@
version: "2"
version: "3.8"
services:
nacos:
image: nacos/nacos-server:${NACOS_VERSION}
@ -7,22 +7,32 @@ services:
- ../env/nacos-standlone-mysql.env
volumes:
- ./standalone-logs/:/home/nacos/logs
- ./init.d/custom.properties:/home/nacos/init.d/custom.properties
ports:
- "8848:8848"
- "9848:9848"
- "9555:9555"
depends_on:
- mysql
mysql:
condition: service_healthy
restart: always
mysql:
container_name: mysql
image: nacos/nacos-mysql:8.0.16
build:
context: .
dockerfile: ./image/mysql/8/Dockerfile
tags:
- "example/mysql:8.0.30"
image: example/mysql:8.0.30
env_file:
- ../env/mysql.env
volumes:
- ./mysql:/var/lib/mysql
ports:
- "3306:3306"
healthcheck:
test: [ "CMD", "mysqladmin" ,"ping", "-h", "localhost" ]
interval: 5s
timeout: 10s
retries: 10