Page tree

Welcome to FreeSoftwareServers Confluence Wiki

Skip to end of metadata
Go to start of metadata

I followed this, then just made my own crazy scripts from it once it worked.

https://www.digitalocean.com/community/tutorials/how-to-configure-a-galera-cluster-with-mariadb-10-1-on-ubuntu-16-04-servers

This example is a 2 node setup.

Master = sql1.domain.com = 192.168.1.51

Slave = sql2.domain.com = 192.168.1.52

Master Setup:

 

cat << 'ELO' >master_mariadb_galera_debian.sh
#!/bin/bash

#Dynamic Variables
hostip=192.168.1.51
hostname=sql1.domain.com

#Static Variables
masterip=192.168.1.51
slaveip=192.168.1.52
clustername=sql_cluster

#Install MariaDB
apt-get install -y software-properties-common
apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0xF1656F24C74CD1D8
add-apt-repository 'deb [arch=amd64,i386,ppc64el] http://mirrors.accretive-networks.net/mariadb/repo/10.1/ubuntu xenial main'
apt update
apt install -y mariadb-server
service mysql status | grep Version
systemctl start mysql
systemctl stop mysql

#Configure Galera Cluster
cat << EOL >/etc/mysql/conf.d/galera.cnf
[mysqld]
binlog_format=ROW
default-storage-engine=innodb
innodb_autoinc_lock_mode=2
bind-address=0.0.0.0

# Galera Provider Configuration
wsrep_on=ON
wsrep_provider=/usr/lib/galera/libgalera_smm.so

# Galera Cluster Configuration
wsrep_cluster_name="$clustername"
wsrep_cluster_address="gcomm://$masterip,$slaveip"

# Galera Synchronization Configuration
wsrep_sst_method=rsync

# Galera Node Configuration
wsrep_node_address="$hostip"
wsrep_node_name="$hostname"
EOL
ELO
chmod +x master_mariadb_galera_debian.sh
./master_mariadb_galera_debian.sh

Slave Setup:

cat << 'ELO' >slave_mariadb_galera_debian.sh
#!/bin/bash

#Dynamic Variables
hostip=192.168.1.52
hostname=sql2.domain.com

#Static Variables
masterip=192.168.1.51
slaveip=192.168.1.52
clustername=sql_cluster

#Install MariaDB
apt-get install -y software-properties-common
apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0xF1656F24C74CD1D8
add-apt-repository 'deb [arch=amd64,i386,ppc64el] http://mirrors.accretive-networks.net/mariadb/repo/10.1/ubuntu xenial main'
apt update
apt install -y mariadb-server
service mysql status | grep Version
systemctl start mysql
systemctl stop mysql

#Configure Galera Cluster
cat << EOL >/etc/mysql/conf.d/galera.cnf
[mysqld]
binlog_format=ROW
default-storage-engine=innodb
innodb_autoinc_lock_mode=2
bind-address=0.0.0.0

# Galera Provider Configuration
wsrep_on=ON
wsrep_provider=/usr/lib/galera/libgalera_smm.so

# Galera Cluster Configuration
wsrep_cluster_name="$clustername"
wsrep_cluster_address="gcomm://$masterip,$slaveip"

# Galera Synchronization Configuration
wsrep_sst_method=rsync

# Galera Node Configuration
wsrep_node_address="$hostip"
wsrep_node_name="$hostname"
EOL
ELO
chmod +x slave_mariadb_galera_debian.sh
./slave_mariadb_galera_debian.sh

Start Master and get Start_Slave.sh

cat << 'ELO'>start_master.sh
galera_new_cluster

mysql -u root -p -e "SHOW STATUS LIKE 'wsrep_cluster_size'"

echo 
echo "Run this on all Slaves"
echo "Ignore the line that says not to touch this file~!"
echo ""
echo "cat << 'LOE' >start_slave.sh"
echo "cat << 'EOL' >/etc/mysql/debian.cnf"
cat /etc/mysql/debian.cnf
echo EOL
echo "systemctl start mysql"
echo "mysql -u root -p -e \"SHOW STATUS LIKE 'wsrep_cluster_size'\""
echo LOE
echo chmod +x start_slave.sh
echo ./start_slave.sh
ELO
chmod +x start_master.sh
./start_master.sh
  • No labels

1 Comment