This article describes how to install and configure PerconaDB xtraDB cluster on Ubuntu 14.04 LTS The installation procedure is same for both the machines.
Installation
Here in this exercise we are going to build a cluster of 2 machines. Let us assume that the 2 machines are having the following IP:
- 10.10.10.76
- 10.10.10.77
Ubuntu 14.04 has PerconaDB version 5.5 in the repository. If we have to install version 5.6, we would need to setup the additional repository. This can be done by the following commands.
apt-key adv --keyserver keys.gnupg.net --recv-keys 1C4CBDCDCD2EFD2A
Add the following lines in the file /etc/apt/sources.list
deb http://repo.percona.com/apt trusty main
We can run the following to load the new package list.
apt-get update
Let us upgrade all the packages as well.
apt-get upgrade
Now let us install PerconaDB. If we want to install to PerconaDB 5.5, we must run the following command (The above repository addition procedure is not required for installing 5.5 version).
apt-get install percona-xtradb-cluster-server-5.5
If we want to install to PerconaDB 5.6, we must run the following command.
apt-get install percona-xtradb-cluster-server-5.6
Configuration on the first node
We need to edit the file /etc/mysql/my.cnf so the following lines look like this
[mysqld] .... binlog_format = ROW wsrep_cluster_name = PXC wsrep_cluster_address = gcomm://10.10.10.76,10.10.10.77 wsrep_node_address = 10.10.10.76 wsrep_provider = /usr/lib/libgalera_smm.so wsrep_sst_method = rsync innodb_locks_unsafe_for_binlog = 1 innodb_autoinc_lock_mode = 2 default_storage_engine=InnoDB
Once this is done let us now bootstrap the first machine. Let us assume that 10.10.10.76 is the first machine.
/etc/init.d/mysql bootstrap-pxc
Verification
Let us check if the cluster is initialized by using the following steps:
mysql -u root -p mysql> show status like 'wsrep%'; +----------------------------+--------------------------------------+ | Variable_name | Value | +----------------------------+--------------------------------------+ | wsrep_local_state_uuid | e6b8ae47-2bce-11e5-9176-c2eb48accfcd | | wsrep_protocol_version | 4 | | wsrep_last_committed | 0 | | wsrep_replicated | 0 | | wsrep_replicated_bytes | 0 | | wsrep_received | 2 | | wsrep_received_bytes | 133 | | wsrep_local_commits | 0 | | wsrep_local_cert_failures | 0 | | wsrep_local_replays | 0 | | wsrep_local_send_queue | 0 | | wsrep_local_send_queue_avg | 0.000000 | | wsrep_local_recv_queue | 0 | | wsrep_local_recv_queue_avg | 0.000000 | | wsrep_flow_control_paused | 0.000000 | | wsrep_flow_control_sent | 0 | | wsrep_flow_control_recv | 0 | | wsrep_cert_deps_distance | 0.000000 | | wsrep_apply_oooe | 0.000000 | | wsrep_apply_oool | 0.000000 | | wsrep_apply_window | 0.000000 | | wsrep_commit_oooe | 0.000000 | | wsrep_commit_oool | 0.000000 | | wsrep_commit_window | 0.000000 | | wsrep_local_state | 4 | | wsrep_local_state_comment | Synced | | wsrep_cert_index_size | 0 | | wsrep_causal_reads | 0 | | wsrep_incoming_addresses | 10.10.10.76:3306 | | wsrep_cluster_conf_id | 1 | | wsrep_cluster_size | 1 | | wsrep_cluster_state_uuid | e6b8ae47-2bce-11e5-9176-c2eb48accfcd | | wsrep_cluster_status | Primary | | wsrep_connected | ON | | wsrep_local_bf_aborts | 0 | | wsrep_local_index | 0 | | wsrep_provider_name | Galera | | wsrep_provider_vendor | Codership Oy <info@codership.com> | | wsrep_provider_version | 2.8(r165) | | wsrep_ready | ON | +----------------------------+--------------------------------------+ 40 rows in set (0.00 sec)
Configuration on the first node
We need to edit the file /etc/mysql/my.cnf so the following lines look like this
[mysqld] .... binlog_format = ROW wsrep_cluster_name = PXC wsrep_cluster_address = gcomm://10.10.10.76,10.10.10.77 wsrep_node_address = 10.10.10.77 wsrep_provider = /usr/lib/libgalera_smm.so wsrep_sst_method = rsync innodb_locks_unsafe_for_binlog = 1 innodb_autoinc_lock_mode = 2 default_storage_engine=InnoDB
Second node initialization
Now let us add the second machine to this cluster by running the following command in the second node (10.10.10.77)
service mysql start
Verification
Let us check whether the new machine is added to the cluster by using the following steps:
mysql -uroot -p mysql> show status like 'wsrep%'; +----------------------------+--------------------------------------+ | Variable_name | Value | +----------------------------+--------------------------------------+ | wsrep_local_state_uuid | e6b8ae47-2bce-11e5-9176-c2eb48accfcd | | wsrep_protocol_version | 4 | | wsrep_last_committed | 0 | | wsrep_replicated | 0 | | wsrep_replicated_bytes | 0 | | wsrep_received | 6 | | wsrep_received_bytes | 382 | | wsrep_local_commits | 0 | | wsrep_local_cert_failures | 0 | | wsrep_local_replays | 0 | | wsrep_local_send_queue | 0 | | wsrep_local_send_queue_avg | 0.000000 | | wsrep_local_recv_queue | 0 | | wsrep_local_recv_queue_avg | 0.000000 | | wsrep_flow_control_paused | 0.000000 | | wsrep_flow_control_sent | 0 | | wsrep_flow_control_recv | 0 | | wsrep_cert_deps_distance | 0.000000 | | wsrep_apply_oooe | 0.000000 | | wsrep_apply_oool | 0.000000 | | wsrep_apply_window | 0.000000 | | wsrep_commit_oooe | 0.000000 | | wsrep_commit_oool | 0.000000 | | wsrep_commit_window | 0.000000 | | wsrep_local_state | 4 | | wsrep_local_state_comment | Synced | | wsrep_cert_index_size | 0 | | wsrep_causal_reads | 0 | | wsrep_incoming_addresses | 10.10.10.77:3306,10.10.10.76:3306 | | wsrep_cluster_conf_id | 2 | | wsrep_cluster_size | 2 | | wsrep_cluster_state_uuid | e6b8ae47-2bce-11e5-9176-c2eb48accfcd | | wsrep_cluster_status | Primary | | wsrep_connected | ON | | wsrep_local_bf_aborts | 0 | | wsrep_local_index | 1 | | wsrep_provider_name | Galera | | wsrep_provider_vendor | Codership Oy <info@codership.com> | | wsrep_provider_version | 2.8(r165) | | wsrep_ready | ON | +----------------------------+--------------------------------------+ 40 rows in set (0.00 sec)