Page tree

Welcome to FreeSoftwareServers Confluence Wiki

Skip to end of metadata
Go to start of metadata

Notes:

  • Import data to sql1 before starting replication
  • After you setup the cluster, make sure to fill on other IP on master for gcom://, it is empty JUST for setup, but if you don't fill it in, it won't work properly during failover
  • Use the command "service mysql start" to start cluster
  • If only 2 nodes, setup GARBD

Start Master 1st:

cat << 'ELO' >master_mariadb_galera_centos.sh
#!/bin/bash
 
#Dynamic Variables
hostip=10.1.8.251
hostname=sql1.domain.com
clustername=sql_cluster
 
#OtherNodes
sql2=10.1.8.255
sql3=10.1.10.255
 
#Galera Configurations
cat << EOL >input.txt
wsrep_on=ON
wsrep_provider=/usr/lib64/galera/libgalera_smm.so
#After starting cluster, comment out line w/o IP's and uncommnt line w/ IP's.
#Only Blank GComm during inital setup!
#wsrep_cluster_address="gcomm://$hostip,$sql2,$sql3"
wsrep_cluster_address='gcomm://'
wsrep_cluster_name="$clustername"
wsrep_node_address="$hostip"
wsrep_node_name="$hostname"
wsrep_sst_method=rsync
binlog_format=row
default_storage_engine=InnoDB
innodb_autoinc_lock_mode=2
bind-address=0.0.0.0
EOL
 
#Edit server.cnf
sed -i '/galera/r input.txt' /etc/my.cnf.d/server.cnf
 
service mysql stop
galera_new_cluster
service mysql status

echo "Make sure to edit /etc/my.cnf.d/server.cfg!"

ELO
chmod +x master_mariadb_galera_centos.sh
./master_mariadb_galera_centos.sh

Slave:

cat << 'ELO' >slave_mariadb_galera_centos.sh
#!/bin/bash
 
#Dynamic Variables
hostip=10.1.8.252
hostname=sql2.domain.com
 
#Static Variables
masterip=10.1.8.251
sql3=10.10.10.255
clustername=sql_cluster
 
#Galera Configurations
cat << EOL >input.txt
wsrep_on=ON
wsrep_provider=/usr/lib64/galera/libgalera_smm.so
wsrep_cluster_address="gcomm://$masterip,$hostip,$sql3"
wsrep_cluster_name="$clustername"
wsrep_node_address="$hostip"
wsrep_node_name="$hostname"
wsrep_sst_method=rsync
binlog_format=row
default_storage_engine=InnoDB
innodb_autoinc_lock_mode=2
bind-address=0.0.0.0
EOL
 
#Edit server.cnf
sed -i '/galera/r input.txt' /etc/my.cnf.d/server.cnf
 
service mysql restart
service mysql status

ELO
chmod +x slave_mariadb_galera_centos.sh
./slave_mariadb_galera_centos.sh
  • No labels

1 Comment