Percona Cluster

Modified: 26 Sep 2019 21:20 UTC

The Joyent Percona Cluster image is a SmartOS base64 image preconfigured with Percona Cluster, an active/active high availability and high scalability open source solution for MySQL® clustering.



Overview

Percona Cluster comes pre-installed and tuned according to your VM size under user 'mysql' as the SMF service svc:/pkgsrc/percona:default. By default Percona Cluster is already set up and initialized as a cluster.

Directory layout

Directory/File Description
/opt/local/bin Holds Percona Cluster server binaries
/var/mysql Percona Cluster data directory
/var/log/mysql Percona Cluster log directory
/opt/local/etc/my.cnf Percona Cluster configuration file

Services layout

SMF Service Description
svc:/pkgsrc/percona:default Percona Cluster Service

Starting Percona Cluster

By default Percona comes enabled. You can disable, restart the service with:

# svcadm disable pkgsrc/percona

or restart:

# svcadm restart pkgsrc/percona

To check the status of the service:

# svcs pkgsrc/percona
online         May_12   svc:/pkgsrc/percona:default

Percona Cluster configuration

The Percona Cluster instance comes provisioned as an already initialiazed cluster and ready to accept other nodes listening on the private IP by default. The cluster settings can be found under the 'Cluster settings' header in the /opt/local/etc/my.cnf file.

In the sections below we're going to use the node mapping for examples.

IP Address Description
192.168.0.1 Node #1 - First node, bootstrapped
192.168.0.2 Node #2 - Second node
192.168.0.3 Node #3 - Third node

Bootstrapping

Bootstrapping is a few different parts broken down into sections below. Because Percona Cluster comes already bootstrapped there is no need to perform the first step 'Initial Bootstrap' or 'Creating SST User'; Only the remaining steps after.

Initial bootstrap

Since Percona Cluster comes initialized and bootstrapped as a ready to go cluster you do not need to bootstrap your cluster. This section is for those who don't already have this part done or want to know how. After bootstrapping you can start with the next section 'Setting wsrep_cluster_address'.

To bootstrap a Percona Cluster all that is needed is a start of mysqld with --wsrep_cluster_address=gcomm://

This can be done just by running the Percona start script with the 'bootstrap' option or setting wsrep_cluster_address to "gcomm://" in your /opt/local/etc/my.cnf file.

/opt/local/lib/svc/method/mysqld bootstrap

This tells the server there is no existing cluster to connect to it and it will create a new history UUID.

Creating SST user

For the cluster to be able to perform data transfer using Xtrabackup a user needs to be setup with proper privileges. This user only needs to be created on the first node. When other nodes connect to the cluster this user will be transferred over when the data syncs.

# mysql -uroot -p$(mdata-get mysql_pw)
mysql> GRANT RELOAD,LOCK TABLES,REPLICATION CLIENT on *.* to 'sstuser'@'localhost' identified by 'password';
mysql> flush privileges;

If you are starting with a fresh Percona Cluster image there is no need to perform this step. It is already done for you on provision.

Setting wsrep_cluster_address

After all nodes have been added to the cluster the wsrep_cluster_address setting needs to be changed in your /opt/local/etc/my.cnf to point to each node shown below. This should be done on all nodes.

wsrep_cluster_address=gcomm://192.168.0.1,192.168.0.2,192.168.0.3

Adding nodes

To add additional nodes all that is needed is a provision of a new instance and configuration of the settings to point it to the first node.

Each node should have the same settings below.

Setting Description Example
wsrep_cluster_address Cluster connection URL gcomm://192.168.0.1,192.168.0.2,192.168.0.3
wsrep_cluster_name Name of the cluster clustername1
wsrep_sst_auth Authentication for the SST user user:password

When the cluster is started with the settings above it will connect to the cluster and start syncing data over. After it is done syncing you will be able to add any data to any node and it immediately transfer over.

To add a node using sdc-createmachine you can provision the instance with special metadata that will configure the instance on provision to your existing cluster. Below is an example of this.

# sdc-createmachine --image="bfdacd56-b7a3-11e4-8070-fb32c76d612e" --name="clusternode2" --package="Medium 2GB" --metadata="percona_wsrep_sst_auth_username=sst-fb507cde2229" --metadata="percona_wsrep_sst_auth_password=59404f5fg89ad1fc" --metadata="percona_wsrep_cluster_address=gcomm://192.168.0.1" --metadata="percona_wsrep_cluster_name=cz427cdfg177"

Percona Cluster status

To check the status of the Percona Cluster on any node:

mysql> show status like 'wsrep%';
+----------------------------+--------------------------------------+
| Variable_name              | Value                                |
+----------------------------+--------------------------------------+
| wsrep_local_state_uuid     | c2883338-834d-11e2-0800-03c9c68e41ec |
...
| wsrep_local_state          | 4                                    |
| wsrep_local_state_comment  | Synced                               |
...
| wsrep_cluster_size         | 1                                    |
| wsrep_cluster_status       | Primary                              |
| wsrep_connected            | ON                                   |
...
| wsrep_ready                | ON                                   |
+----------------------------+--------------------------------------+

Metadata keys

With the Percona Cluster image are metadata keys that can be pre-defined during provision to provide additional customization to the instance.

Metadata Key Description
mysql_password MySQL password to be set
mysql_server_id MySQL server id
percona_wsrep_sst_auth_username Percona SST authentication user
percona_wsrep_sst_auth_password Percona SST authentication password
percona_wsrep_cluster_address Percona Cluster connection URL
percona_wsrep_cluster_name Percona Cluster name
percona_wsrep_node_name Percona Cluster node name

Below is an example of provisioning a Percona Cluster instance and joining it to another cluster.

# sdc-createmachine --image="bfdacd56-b7a3-11e4-8070-fb32c76d612e" --name="clusternode2" --package="Medium 2GB" --metadata="percona_wsrep_sst_auth_username=sst-fb507cde2229" --metadata="percona_wsrep_sst_auth_password=59404f5fg89ad1fc" --metadata="percona_wsrep_cluster_address=gcomm://192.168.0.1" --metadata="percona_wsrep_cluster_name=cz427cdfg177"

Version 15.x.x

15.1.1

Name percona-cluster
Description A SmartOS 64-bit image pre-configured and optimized as a Percona Cluster 5.6.21 server.
UUID 9fcdaebe-0a16-11e5-bf17-a7b991b324d2
Based on base-64 15.1.1
Pkgsrc 2015Q1
What's new in this image
Software included in this image

Software installed as pkgsrc packages:

bzip2-1.0.6nb1
curl-7.42.0
db4-4.8.30
dtracetools-0.7
gcc47-libs-4.7.4nb1
gtar-base-1.28nb1
htop-1.0.1
nodejs-0.12.4
openssl-1.0.2a
percona-cluster-5.6.21nb3
percona56-cluster-1.2
percona56-cluster-galera-25.3.9
percona56-cluster-xtrabackup-2.2.8
perl-5.20.2
pkgin-0.8.0
postfix-2.11.4
python27-2.7.9nb1
quickbackup-percona-3.5nb20140212
smtools-20150312
sqlite3-3.8.10
sudo-1.7.10p9
wget-1.16.3
zoneinit-1.6.8

Software installed as npm packages:

json@9.0.3
manta@1.5.1
smartdc@7.3.1

Version 14.x.x

14.4.0

Name percona-cluster
Description A SmartOS 64-bit image pre-configured and optimized as a Percona Cluster 5.6.21 server.
UUID 143b7f8c-d2f5-11e4-8457-b7e1d2aef782
Based on base-64-lts
Pkgsrc 2014Q4
What's new in this image
Software included in this image

Software installed as pkgsrc packages:

bzip2-1.0.6nb1
curl-7.39.0nb1
db4-4.8.30
dtracetools-0.7
gcc47-libs-4.7.3nb7
gtar-base-1.28
htop-1.0.1
nodejs-0.12.0
openssl-1.0.1k
percona-cluster-5.6.21nb2
percona56-cluster-1.2
percona56-cluster-galera-25.3.9
percona56-cluster-xtrabackup-2.2.8
perl-5.20.1
pkgin-0.7.0
postfix-2.11.3
python27-2.7.9
quickbackup-percona-3.5nb20140212
smtools-20150226
sqlite3-3.8.7.4
sudo-1.7.10p9
wget-1.16.1
zoneinit-1.6.8

Software installed as npm packages:

json@9.0.3
manta@1.5.1
smartdc@7.3.1

14.3.0

Name percona-cluster
Description A SmartOS 64-bit image pre-configured and optimized as a Percona Cluster 5.6.21 server.
UUID bfdacd56-b7a3-11e4-8070-fb32c76d612e
Based on base64 14.3.0
Pkgsrc 2014Q3
What's new in this image
Software included in this image

Software installed as pkgsrc packages:

bzip2-1.0.6nb1
curl-7.38.0
db4-4.8.30
dtracetools-0.7
gcc47-libs-4.7.3nb7
gtar-base-1.28
htop-1.0.1
nodejs-0.12.0
openssl-1.0.1j
percona-cluster-5.6.21nb2
percona56-cluster-1.2
percona56-cluster-galera-25.3.5
percona56-cluster-xtrabackup-2.2.8
perl-5.20.0nb2
pkgin-0.6.4nb7
postfix-2.11.1nb1
python27-2.7.8nb1
quickbackup-percona-3.5nb20140212
smtools-20141209
sqlite3-3.8.6
sudo-1.7.10p8
wget-1.16
zoneinit-1.6.8

Software installed as npm packages:

json@9.0.3
manta@1.4.6
smartdc@7.3.0