From 4fdbd25ddd13ff46577ba4e037659d100471feb6 Mon Sep 17 00:00:00 2001 From: Bryan Joshua Pedini Date: Sat, 30 Sep 2023 15:01:04 +0200 Subject: [PATCH] percona xtradb cluster deployment --- .gitignore | 2 ++ bootstrap.sh | 8 ++++++++ docker-compose.yml | 19 +++++++++++++++++++ example.custom.cnf | 15 +++++++++++++++ example.env | 5 +++++ example.mysqld.cnf | 3 +++ 6 files changed, 52 insertions(+) create mode 100644 .gitignore create mode 100755 bootstrap.sh create mode 100644 docker-compose.yml create mode 100644 example.custom.cnf create mode 100644 example.env create mode 100644 example.mysqld.cnf diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..fb58dee --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +.env +data diff --git a/bootstrap.sh b/bootstrap.sh new file mode 100755 index 0000000..8444737 --- /dev/null +++ b/bootstrap.sh @@ -0,0 +1,8 @@ +#!/usr/bin/env bash + +read -p "\$DATA directory: " DATA_DIRECTORY +REALDIR=$(readlink -f "${DATA_DIRECTORY}") +mkdir -p "${DATA_DIRECTORY}" +mkdir "${DATA_DIRECTORY}/conf" "${DATA_DIRECTORY}/cert" "${DATA_DIRECTORY}/mysql" +chown 1001:1001 "${DATA_DIRECTORY}/cert" "${DATA_DIRECTORY}/mysql" +docker run --rm -v "${REALDIR}"/cert:/cert percona/percona-xtradb-cluster:8.0 mysql_ssl_rsa_setup -d /cert diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..08ec416 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,19 @@ +--- +services: + percona: + image: percona/percona-xtradb-cluster:${PERCONA_VERSION} + restart: unless-stopped + environment: + - CLUSTER_NAME=${PERCONA_CLUSTER_NAME} + - MYSQL_ROOT_PASSWORD=${PERCONA_ROOT_PASSWORD} + hostname: ${PERCONA_HOSTNAME} + ports: + - 3306:3306/tcp + - 4444:4444/tcp + - 4567:4567/tcp + - 4567:4567/udp + - 4568:4568/tcp + volumes: + - ${PERCONA_DATA}/cert:/cert + - ${PERCONA_DATA}/config:/etc/percona-xtradb-cluster.conf.d + - ${PERCONA_DATA}/mysql:/var/lib/mysql diff --git a/example.custom.cnf b/example.custom.cnf new file mode 100644 index 0000000..615126c --- /dev/null +++ b/example.custom.cnf @@ -0,0 +1,15 @@ +[mysqld] +ssl-ca = /cert/ca.pem +ssl-cert = /cert/server-cert.pem +ssl-key = /cert/server-key.pem + +[client] +ssl-ca = /cert/ca.pem +ssl-cert = /cert/client-cert.pem +ssl-key = /cert/client-key.pem + +[sst] +encrypt = 4 +ssl-ca = /cert/ca.pem +ssl-cert = /cert/server-cert.pem +ssl-key = /cert/server-key.pem diff --git a/example.env b/example.env new file mode 100644 index 0000000..14f6024 --- /dev/null +++ b/example.env @@ -0,0 +1,5 @@ +PERCONA_VERSION=8.0 +PERCONA_DATA=./data +PERCONA_HOSTNAME=pcx +PERCONA_CLUSTER_NAME=percona +PERCONA_ROOT_PASSWORD=r00t diff --git a/example.mysqld.cnf b/example.mysqld.cnf new file mode 100644 index 0000000..1442d5a --- /dev/null +++ b/example.mysqld.cnf @@ -0,0 +1,3 @@ +wsrep_provider=/usr/lib/galera4/libgalera_smm.so +wsrep_cluster_name=percona +wsrep_cluster_address=gcomm://192.168.10.11,192.168.10.12,192.168.10.13