From 3717ec69b9597670d19a3b335c8e9cb9a737c8bb Mon Sep 17 00:00:00 2001 From: Abneet Wats Date: Sun, 4 Apr 2021 01:54:59 +0530 Subject: [PATCH] Adds functionality of phpmyadmin with fix for mysql-shell restart and waiting of mysql-routers fix #1 Add health check for more consistent invocation of dependent services --- innodb-cluster/.gitignore | 1 + innodb-cluster/dbwebapp.env | 5 --- innodb-cluster/docker-compose.yml | 62 ++++++++++++++++++++++--------- innodb-cluster/phpmyadmin.env | 5 +++ innodb-cluster/scripts/db.sql | 6 +-- 5 files changed, 53 insertions(+), 26 deletions(-) create mode 100644 innodb-cluster/.gitignore delete mode 100644 innodb-cluster/dbwebapp.env create mode 100644 innodb-cluster/phpmyadmin.env diff --git a/innodb-cluster/.gitignore b/innodb-cluster/.gitignore new file mode 100644 index 0000000..28f7038 --- /dev/null +++ b/innodb-cluster/.gitignore @@ -0,0 +1 @@ +docker-compose.yml.bak.old diff --git a/innodb-cluster/dbwebapp.env b/innodb-cluster/dbwebapp.env deleted file mode 100644 index 8ac2761..0000000 --- a/innodb-cluster/dbwebapp.env +++ /dev/null @@ -1,5 +0,0 @@ -DBUSER=dbwebapp -DBPASS=dbwebapp -DBNAME=dbwebappdb -DBHOST=mysql-router -DBPORT=6446 diff --git a/innodb-cluster/docker-compose.yml b/innodb-cluster/docker-compose.yml index a3ef5f1..f634cdb 100644 --- a/innodb-cluster/docker-compose.yml +++ b/innodb-cluster/docker-compose.yml @@ -3,51 +3,77 @@ services: mysql-server-1: env_file: - mysql-server.env - image: mysql/mysql-server:8.0.12 + image: mysql/mysql-server:8.0.13 ports: - "3301:3306" command: ["mysqld","--server_id=1","--binlog_checksum=NONE","--gtid_mode=ON","--enforce_gtid_consistency=ON","--log_bin","--log_slave_updates=ON","--master_info_repository=TABLE","--relay_log_info_repository=TABLE","--transaction_write_set_extraction=XXHASH64","--user=mysql","--skip-host-cache","--skip-name-resolve", "--default_authentication_plugin=mysql_native_password"] + healthcheck: + test: "exit 0" + mysql-server-2: env_file: - mysql-server.env - image: mysql/mysql-server:8.0.12 + image: mysql/mysql-server:8.0.13 command: ["mysqld","--server_id=2","--binlog_checksum=NONE","--gtid_mode=ON","--enforce_gtid_consistency=ON","--log_bin","--log_slave_updates=ON","--master_info_repository=TABLE","--relay_log_info_repository=TABLE","--transaction_write_set_extraction=XXHASH64","--user=mysql","--skip-host-cache","--skip-name-resolve", "--default_authentication_plugin=mysql_native_password"] ports: - "3302:3306" + healthcheck: + test: "exit 0" + mysql-server-3: env_file: - mysql-server.env - image: mysql/mysql-server:8.0.12 + image: mysql/mysql-server:8.0.13 command: ["mysqld","--server_id=3","--binlog_checksum=NONE","--gtid_mode=ON","--enforce_gtid_consistency=ON","--log_bin","--log_slave_updates=ON","--master_info_repository=TABLE","--relay_log_info_repository=TABLE","--transaction_write_set_extraction=XXHASH64","--user=mysql","--skip-host-cache","--skip-name-resolve", "--default_authentication_plugin=mysql_native_password"] ports: - "3303:3306" + healthcheck: + test: "exit 0" + mysql-shell: env_file: - mysql-shell.env - image: neumayer/mysql-shell-batch + image: bkandasa/mysql-shell-batch volumes: - ./scripts/:/scripts/ depends_on: - - mysql-server-1 - - mysql-server-2 - - mysql-server-3 + mysql-server-1: + condition: service_healthy + mysql-server-2: + condition: service_healthy + mysql-server-3: + condition: service_healthy + healthcheck: + test: "exit 0" + restart: on-failure + mysql-router: env_file: - mysql-router.env - image: mysql/mysql-router:8.0 + image: mysql/mysql-router:8.0.13 ports: - "6446:6446" depends_on: - - mysql-server-1 - - mysql-server-2 - - mysql-server-3 - - mysql-shell + mysql-server-1: + condition: service_healthy + mysql-server-2: + condition: service_healthy + mysql-server-3: + condition: service_healthy + mysql-shell: + condition: service_healthy restart: on-failure - dbwebapp: - env_file: - - dbwebapp.env - image: neumayer/dbwebapp - ports: - - "8080:8080" + phpmyadmin: + image: phpmyadmin + container_name: msr-phpmyadmin depends_on: - mysql-router + ports: + - 8181:80 + env_file: + - phpmyadmin.env + environment: + PMA_HOST: mysql-router + PMA_PORT: 6446 + MYSQL_USERNAME: root + MYSQL_ROOT_PASSWORD: mysql diff --git a/innodb-cluster/phpmyadmin.env b/innodb-cluster/phpmyadmin.env new file mode 100644 index 0000000..756c250 --- /dev/null +++ b/innodb-cluster/phpmyadmin.env @@ -0,0 +1,5 @@ +DBUSER=abneet +DBPASS='Admin123$' +DBNAME=test +DBHOST=mysql-router +DBPORT=6446 diff --git a/innodb-cluster/scripts/db.sql b/innodb-cluster/scripts/db.sql index 13755a2..2ead1cd 100644 --- a/innodb-cluster/scripts/db.sql +++ b/innodb-cluster/scripts/db.sql @@ -1,3 +1,3 @@ -CREATE DATABASE dbwebappdb; -CREATE USER 'dbwebapp'@'%' IDENTIFIED BY 'dbwebapp'; -GRANT ALL PRIVILEGES ON dbwebappdb.* TO 'dbwebapp'@'%'; +CREATE DATABASE abneet; +CREATE USER 'abneet'@'%' IDENTIFIED BY 'Admin123$'; +GRANT ALL PRIVILEGES ON *.* TO 'abneet'@'%';