Run these on all servers
# apt-get install python-software-properties
# apt-key adv --recv-keys --keyserver keyserver.ubuntu.com 0xcbcb082a1bb943db
# add-apt-repository 'deb http://mirror3.layerjet.com/mariadb/repo/5.5/debian wheezy main'
# apt-get updateRun these on all servers
# apt-get install -y rsync galera mariadb-galera-serverThe following configuration file has to be distributed on all nodes.
We use a separate configuration file /etc/mysql/conf.d/galera.cnf with the following settings:
[mysqld]
#mysql settings
binlog_format=ROW
default-storage-engine=innodb
innodb_autoinc_lock_mode=2
query_cache_size=0
query_cache_type=0
bind-address=0.0.0.0
#galera settings
wsrep_provider=/usr/lib/galera/libgalera_smm.so
wsrep_cluster_name="my_wsrep_cluster"
wsrep_cluster_address="gcomm://192.168.3.19,192.168.3.20,192.168.3.21"
wsrep_sst_method=rsync
wsrep_node_address="192.168.3.21"
wsrep_node_name="galera3"
wsrep_cluster_address = list of all ip addresses in this cluster.
wsrep_node_address and wsrep_node_name is the local ip address and node name on each node.
First, stop mysql service on all servers
node01# service mysql stop
node02# service mysql stop
node03# service mysql stopThen, initialize the replication on node 1
node01# service mysql start --wsrep-new-clusterCopy the /etc/mysql/debian.cnf on node1 to all nodes.
node01# scp /etc/mysql/debian.cnf root@node02:/etc/mysql/debian.cnf
node01# scp /etc/mysql/debian.cnf root@node03:/etc/mysql/debian.cnfTo have a look and see if everything really worked we’ll check the cluster size status query. Run on node1.
SELECT VARIABLE_VALUE as "cluster size"
FROM INFORMATION_SCHEMA.GLOBAL_STATUS
WHERE VARIABLE_NAME="wsrep_cluster_size"Run the query using mysql cli. For now, the cluster size is 1.
Because currently only node1 active.
Go to node2 and node3, then fire up the mysql service
node2# service mysql start
node3# service mysql startFor now, the MariaDB + Galera is already set up and running.
re-run the query using mysql cli. Now the cluster size is 3, indicating
that all servers are successfully added into cluster