Skip to content

Commit

Permalink
Add MySQL Version 8.4.2 (#37)
Browse files Browse the repository at this point in the history
* add MySQL 8.4.2 version

Signed-off-by: Ashraful Haque Tani <[email protected]>
  • Loading branch information
AshrafulHaqueToni authored Sep 24, 2024
1 parent b798394 commit f5a9b2c
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 23 deletions.
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
9 changes: 9 additions & 0 deletions scripts/directory-exist.sh
Original file line number Diff line number Diff line change
@@ -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
33 changes: 14 additions & 19 deletions scripts/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion scripts/run_innodb.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ mkdir -p /etc/mysql/conf.d/
cat >>/etc/mysql/my.cnf <<EOL
!includedir /etc/mysql/conf.d/
[mysqld]
default_authentication_plugin=mysql_native_password
mysql_native_password=ON
#loose-group_replication_ip_whitelist = "${whitelist}"
loose-group_replication_ip_allowlist = "${whitelist}"
EOL
Expand Down
6 changes: 3 additions & 3 deletions scripts/run_semi_sync.sh
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ function install_clone_plugin() {
log "INFO" "Clone plugin is not installed. Installing the plugin..."
retry 120 ${mysql} -e "INSTALL PLUGIN clone SONAME 'mysql_clone.so';"
reading_first_time=1
retry 120 ${mysql} -e "reset master;"
retry 120 ${mysql} -e "RESET BINARY LOGS AND GTIDS;"
log "INFO" "Clone plugin successfully installed"
else
log "INFO" "Already clone plugin is installed"
Expand All @@ -90,8 +90,8 @@ function install_semiSync_plugin() {
out=$(${mysql} -N -e 'SHOW PLUGINS;' | grep semisync)
if [[ -z "$out" ]]; then
log "INFO" "semisync plugin is not installed. Installing the plugin..."
retry 120 ${mysql} -e "INSTALL PLUGIN rpl_semi_sync_master SONAME 'semisync_master.so';"
retry 120 ${mysql} -e "INSTALL PLUGIN rpl_semi_sync_slave SONAME 'semisync_slave.so';"
retry 120 ${mysql} -e "INSTALL PLUGIN rpl_semi_sync_source SONAME 'semisync_source.so';"
retry 120 ${mysql} -e "INSTALL PLUGIN rpl_semi_sync_replica SONAME 'semisync_replica.so';"
reading_first_time=1
log "INFO" "semi_sync plugin successfully installed"
else
Expand Down

0 comments on commit f5a9b2c

Please sign in to comment.