From f5a9b2ccdb450f8e630e4b8971e615a1a79aebf3 Mon Sep 17 00:00:00 2001 From: Ashraful Haque Tani <48568933+AshrafulHaqueToni@users.noreply.github.com> Date: Tue, 24 Sep 2024 18:53:32 +0600 Subject: [PATCH] Add MySQL Version 8.4.2 (#37) * add MySQL 8.4.2 version Signed-off-by: Ashraful Haque Tani --- Dockerfile | 1 + scripts/directory-exist.sh | 9 +++++++++ scripts/run.sh | 33 ++++++++++++++------------------- scripts/run_innodb.sh | 2 +- scripts/run_semi_sync.sh | 6 +++--- 5 files changed, 28 insertions(+), 23 deletions(-) create mode 100644 scripts/directory-exist.sh diff --git a/Dockerfile b/Dockerfile index 91e1d6b..dfeb90f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -18,6 +18,7 @@ LABEL org.opencontainers.image.source https://github.com/kubedb/mysql-init-docke RUN apk add --no-cache bash COPY scripts /tmp/scripts +RUN chmod +x /tmp/scripts/*.sh COPY init-script /init-script COPY --from=0 /tini /tmp/scripts/tini diff --git a/scripts/directory-exist.sh b/scripts/directory-exist.sh new file mode 100644 index 0000000..7a5ace0 --- /dev/null +++ b/scripts/directory-exist.sh @@ -0,0 +1,9 @@ +#!/usr/bin/env bash + +file="/var/lib/mysql/join-in-cluster" + +if [ -e "$file" ]; then + echo -n "Not Empty" +else + echo -n "Empty" +fi \ No newline at end of file diff --git a/scripts/run.sh b/scripts/run.sh index b7957b8..76f0086 100755 --- a/scripts/run.sh +++ b/scripts/run.sh @@ -270,28 +270,23 @@ function wait_for_primary() { cluster_size=${#members_id[@]} local is_primary_found=0 - for member_id in ${members_id[*]}; do - for i in {60..0}; do - primary_member_id=$(${mysql} -N -e "SHOW STATUS WHERE Variable_name = 'group_replication_primary_member';" | awk '{print $2}') - log "INFO" "Attempt $i: Trying to find primary member........................" - if [[ -n "$primary_member_id" ]]; then - is_primary_found=1 - primary_host=$(${mysql} -N -e "SELECT MEMBER_HOST FROM performance_schema.replication_group_members WHERE MEMBER_ID = '${primary_member_id}';" | awk '{print $1}') - # calculate data size of the primary node. - # https://forums.mysql.com/read.php?108,201578,201578 - primary_db_size=$(${mysql_header} --host=$primary_host -N -e 'select round(sum( data_length + index_length) / 1024 / 1024) "size in mb" from information_schema.tables;') - log "INFO" "Primary found. Primary host: $primary_host, database size: $primary_db_size" - break - fi - - echo -n . - sleep 1 - done - if [[ "$is_primary_found" == "1" ]]; then + for i in {20..0}; do + primary_member_id=$(${mysql} -N -e "SELECT MEMBER_ID FROM performance_schema.replication_group_members WHERE MEMBER_STATE = 'ONLINE' and MEMBER_ROLE = 'PRIMARY';" | awk '{print $2}') + log "INFO" "Attempt $i: Trying to find primary member........................" + if [[ -n "$primary_member_id" ]]; then + log "INFO" "Found the primary" + is_primary_found=1 + primary_host=$(${mysql} -N -e "SELECT MEMBER_HOST FROM performance_schema.replication_group_members WHERE MEMBER_ID = '${primary_member_id}';" | awk '{print $1}') + # calculate data size of the primary node. + # https://forums.mysql.com/read.php?108,201578,201578 + primary_db_size=$(${mysql_header} --host=$primary_host -N -e 'select round(sum( data_length + index_length) / 1024 / 1024) "size in mb" from information_schema.tables;') + log "INFO" "Primary found. Primary host: $primary_host, database size: $primary_db_size" break fi + echo -n . + sleep 1 done if [[ "$is_primary_found" == "1" ]]; then @@ -542,7 +537,7 @@ while true; do if [[ $desired_func == "join_in_cluster" ]]; then check_member_list_updated "${member_hosts[*]}" - wait_for_primary "${member_hosts[*]}" + # wait_for_primary "${member_hosts[*]}" set_valid_donors join_into_cluster fi diff --git a/scripts/run_innodb.sh b/scripts/run_innodb.sh index b986f05..1de07bf 100755 --- a/scripts/run_innodb.sh +++ b/scripts/run_innodb.sh @@ -38,7 +38,7 @@ mkdir -p /etc/mysql/conf.d/ cat >>/etc/mysql/my.cnf <