diff --git a/content/post/rancher-k3s-with-galera.md b/content/post/rancher-k3s-with-galera.md index 176bbfc..65de240 100644 --- a/content/post/rancher-k3s-with-galera.md +++ b/content/post/rancher-k3s-with-galera.md @@ -40,7 +40,7 @@ sudo apt-key adv --fetch-keys 'https://mariadb.org/mariadb_release_signing_key.a sudo add-apt-repository 'deb [arch=amd64,arm64,ppc64el] http://ftp.hosteurope.de/mirror/mariadb.org/repo/10.4/ubuntu bionic main' sudo apt update -sudo apt install mariadb-server mariadb-client +sudo apt install mariadb-server mariadb-client mariadb-backup ``` ##### Secure MariaDB on each Node @@ -128,22 +128,26 @@ sudo systemctl stop mariadb Liste on all Interfaces (if you want configure it to listen only on a specific address): ```bash +sudo sed -i 's/max_connections\t\t= 100/max_connections\t\t= 1000/g' /etc/mysql/my.cnf sudo sed -i 's/bind-address\t\t= 127.0.0.1/#bind-address\t\t= 127.0.0.1/g' /etc/mysql/my.cnf ``` Enable Galera, Paste the following into /etc/mysql/mariadb.conf.d/99-cluster.cnf -``` +```conf [galera] -wsrep_on = on +wsrep_on = on wsrep_provider = /usr/lib/galera/libgalera_smm.so wsrep_cluster_address = gcomm://10.128.1.17,10.128.1.18,10.128.1.19 -wsrep_cluster_name = k3s_cluster_0 +wsrep_cluster_name = k3s_cluster_0 +wsrep_provider_options="gcache.size = 512M" +wsrep_sst_method = mariabackup +wsrep_sst_auth = root:SuperSecretRootPassword -default_storage_engine = InnoDB -innodb_autoinc_lock_mode = 2 -innodb_doublewrite = 1 +default_storage_engine = InnoDB +innodb_autoinc_lock_mode = 2 +innodb_doublewrite = 1 binlog_format = ROW ``` @@ -156,7 +160,7 @@ Some tuning if you use this Galera cluster for other purposes sudo nano /etc/mysql/mariadb.conf.d/98-tuning.cnf ``` -``` +```conf [mysqld] key_buffer_size=256M thread_stack=192K @@ -182,6 +186,12 @@ One **one** node run `sudo galera_new_cluster` One the other 2 nodes run: `sudo systemctl start mariadb.service` +##### Check the MariaDB Galera Cluster + +```bash +mysql -u root -p -e "SELECT * FROM information_schema.global_status WHERE variable_name IN ('WSREP_CLUSTER_STATUS','WSREP_LOCAL_STATE_COMMENT','WSREP_CLUSTER_SIZE','WSREP_EVS_REPL_LATENCY','WSREP_EVS_DELAYED','WSREP_READY');" +``` + ##### Create the k3s Database One one node run: