Skip to content

Install Percona XtraDB Cluster on CentOS 6.2

Percona XtraDB Cluster is a new high availability and high scalability solution for MySQL users. XtraDB Cluster integrates Percona Server with the Galera library of high availability solutions in a single product package. Percona XtraDB is an enhanced version of the InnoDB storage engine for MySQL and MariaDB. It has much faster performance than InnoDB and better scalability on modern hardware.

This tutorial is how to setup a 3-node XtraDB cluster, assuming you are running CentOS Linux 6.2 64-bit.

Install Percona’s CentOS 6 repositories:

# rpm -Uhv http://repo.percona.com/testing/centos/6/os/noarch/percona-testing-0.0-1.noarch.rpm
# rpm -Uhv http://www.percona.com/downloads/percona-release/percona-release-0.0-1.x86_64.rpm

Install Percona XtraDB Cluster packages:

# yum install Percona-XtraDB-Cluster-server Percona-XtraDB-Cluster-client

XtraDB Cluster requires a couple of TCP ports to operate. Easiest way:

# service iptables stop

If you want to open only specific ports, you need to open 3306, 4444, 4567, 4568 ports.

For example for 4567 port (substitute 10.0.0.1 by your IP):

# iptables -A INPUT -i eth0 -p tcp -m tcp --source 10.0.0.1/24 --dport 4567 -j ACCEPT

Now repeat on all XtraDB cluster nodes

Create /etc/my.cnf files

On the first XtraDB Cluster node (assume IP 10.0.0.10):

[mysqld]
datadir=/mnt/data
user=mysql

binlog_format=ROW

wsrep_provider=/usr/lib64/libgalera_smm.so

wsrep_cluster_address=gcomm://

wsrep_slave_threads=2
wsrep_cluster_name=trimethylxanthine
wsrep_sst_method=rsync
wsrep_node_name=node1

innodb_locks_unsafe_for_binlog=1
innodb_autoinc_lock_mode=2

On the second XtraDB Cluster node:

[mysqld]
datadir=/mnt/data
user=mysql

binlog_format=ROW

wsrep_provider=/usr/lib64/libgalera_smm.so

wsrep_cluster_address=gcomm://10.0.0.10

wsrep_slave_threads=2
wsrep_cluster_name=trimethylxanthine
wsrep_sst_method=rsync
wsrep_node_name=node2

innodb_locks_unsafe_for_binlog=1
innodb_autoinc_lock_mode=2

On the third XtraDB Cluster node:

[mysqld]
datadir=/mnt/data
user=mysql

binlog_format=ROW

wsrep_provider=/usr/lib64/libgalera_smm.so

wsrep_cluster_address=gcomm://10.0.0.10

wsrep_slave_threads=2
wsrep_cluster_name=trimethylxanthine
wsrep_sst_method=rsync
wsrep_node_name=node3

innodb_locks_unsafe_for_binlog=1
innodb_autoinc_lock_mode=2

Start mysqld on the first node:

# service mysql start

When all nodes are in SYNCED stage your cluster is ready!

Connect to database on any node and create database:

# mysql
> CREATE DATABASE how2centos_test;

The new database will be propagated to all nodes.