Setting up Percona cluster

From Wiki
Jump to: navigation, search

First published Tuesday 16 September, 2014 Setting up Percona cluster

Installing (for each node)[edit]

First order of business is to add the repo key:

sudo gpg --keyserver  "hkp://keys.gnupg.net" --recv-keys 1C4CBDCDCD2EFD2A

then add the repositories to e.g. /etc/apt/sources.list.d/percona.list

deb http://repo.percona.com/apt wheezy main
deb-src http://repo.percona.com/apt wheezy main

Then install the packages:

sudo apt-get update
sudo apt-get install percona-xtradb-cluster-55

Configuring Percona (for each node)[edit]

You can then configure Percona itself, in e.g. /etc/mysql/conf.d/00-galera.cnf

# vi:filetype=config
#
# This is the configuration file for Galera.
# Other configurations should go in a different config file!
#
# This is node 1.
#
# initial setup 2014-09-10 Douglas Gardner
 
[mysqld]                                                                             
binlog_format=ROW
default_storage_engine=InnoDB
innodb_autoinc_lock_mode=2
 
wsrep_cluster_address="gcomm://" # leave blank for now
wsrep_provider=/usr/lib/libgalera_smm.so
wsrep_node_address=192.168.1.1 # this should be the current IP
wsrep_cluster_name="cluster_1"
wsrep_sst_auth="sstuser:password"
wsrep_sst_method=xtrabackup-v2

You also need to edit my.cnf directly to get the server to listen where it's supposed to, instead of just localhost:

[mysql]
bind-address=192.168.1.1

and then need to create the SST user:

CREATE USER 'sstuser'@'localhost' IDENTIFIED BY 'password';
GRANT RELOAD, LOCK TABLES, REPLICATION CLIENT ON *.* TO 'sstuser'@'localhost';
FLUSH PRIVILEGES;

Bootstrapping[edit]

And thus, on the first node we can bootstrap the cluster.

sudo service mysql stop # probably not needed
sudo service mysql bootstrap-pxc

You should now be able to check that everything is running: hopefully wsrep_ready is ON.

SHOW STATUS LIKE 'wsrep%';

At this point your server should be listening on 3306 (for mysql) and 4567 (group communication).

You can then bring up the other nodes one by one:

sudo service mysql start

Checking it worked[edit]

You can run this to check whether things are working: wsgrep_cluster_conf_id should increment each time, and wsrep_cluster_size should tell you how many nodes are currently connected.

SHOW STATUS LIKE 'wsrep_cluster_%';