Skip to content
This repository has been archived by the owner on Oct 18, 2023. It is now read-only.

Commit

Permalink
Lgvanboven proxysql (#65)
Browse files Browse the repository at this point in the history
* proxysql v2.3.2

* changes AWS Aurora

* Proxysql version upgrade

Co-authored-by: Lennard van Boven | Scienta
  • Loading branch information
Lgvboven committed Oct 11, 2022
1 parent 8b68656 commit 1628163
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 50 deletions.
2 changes: 1 addition & 1 deletion deploy/charts/proxysql-cluster/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: proxysql-cluster
version: 1.0.1
version: 2.0.0
description: Chart for ProxySQL Cluster
keywords:
- mysql
Expand Down
51 changes: 4 additions & 47 deletions docker/files/cli/commands/cluster.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ command_init() {

sleep 5

command_sync:checkOnline

touch /proxysql-ready
}

Expand Down Expand Up @@ -82,10 +80,10 @@ command_sync:default-hostgroup() {
FROM mysql_servers
WHERE hostgroup_id NOT IN (
SELECT reader_hostgroup
FROM mysql_replication_hostgroups
FROM mysql_aws_aurora_hostgroups
) OR hostgroup_id IN (
SELECT writer_hostgroup
FROM mysql_replication_hostgroups
FROM mysql_aws_aurora_hostgroups
)
");

Expand Down Expand Up @@ -143,10 +141,10 @@ command_sync:node() {
FROM mysql_servers
WHERE hostgroup_id NOT IN (
SELECT reader_hostgroup
FROM mysql_replication_hostgroups
FROM mysql_aws_aurora_hostgroups
) OR hostgroup_id IN (
SELECT writer_hostgroup
FROM mysql_replication_hostgroups
FROM mysql_aws_aurora_hostgroups
)
");

Expand Down Expand Up @@ -253,44 +251,3 @@ command_sync:cluster() {

sleep 1
}

commands_add "sync:checkOnline" "Check if all available servers are online"
command_sync:checkOnline() {

echo -e "\e[33m Check added MySQL servers \e[0m"

confTotal=$(
proxysql_execute_query "
SELECT COUNT (*) FROM mysql_servers;
";
)
echo -e "\e[33m The number of servers found is" $confTotal "in total \e[0m"

sleep 5

echo -e "\e[33m Check current state of all available servers \e[0m"

proxysql_execute_query "
SELECT hostgroup_id,hostname,status FROM mysql_servers;
" | while read hostgroup_id hostname status; do
# use $hostgroup_id and $status variables
echo "Checking - hostID: $hostgroup_id, hostname: $hostname, status: $status"
# when working with a service "status" as indicator isn't always right
if mysqladmin ping -u${MYSQL_ADMIN_USERNAME} -p${MYSQL_ADMIN_PASSWORD} -h$hostname; then
echo -e "\e[33m $hostname is operating normaly \e[0m"
else
echo -e "\e[33m $hostname is not active \e[0m"
foundTotal=$((foundTotal + 1))
echo -e "\e[33m Found:" $foundTotal " offline server(s), out of " $confTotal " server(s) total \e[0m"
if [ $foundTotal = $confTotal ]; then
# All servers are Offline
echo -e "\e[33m All servers are offline, this container is unhealthy. \e[0m"
# lets exit this container using liveness probe
rm -rf /proxysql-liveness
echo -e "\e[33m Liveness state updated to destroy this container. \e[0m"
fi
fi
done

sleep 1
}
2 changes: 1 addition & 1 deletion docker/files/cli/functions/proxysql.sh
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,4 @@ function proxysql_wait_for_servers() {

sleep ${SLEEP}

}
}
2 changes: 1 addition & 1 deletion docker/k8s-proxysql-cluster.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
FROM debian:stretch-slim
LABEL maintainer="Scienta <[email protected]>"

ENV PROXYSQL_VERSION "1.4.14"
ENV PROXYSQL_VERSION "2.4.4"

ENV PROXYSQL_SERVICE proxysql

Expand Down

0 comments on commit 1628163

Please sign in to comment.