What is it Percona Cluster?
Percona XtraDB Cluster is an active/active high availability and high scalability open source solution for MySQL® clustering. It integrates Percona Server and Percona XtraBackup with the Galera library of MySQL high availability solutions in a single package which enables you to create a cost-effective MySQL high availability cluster
The Cluster we will be created on these nodes:
To retrieve Percona Cluster packages you have to add a key:
$ apt-key adv --keyserver keys.gnupg.net --recv-keys 1C4CBDCDCD2EFD2A
Add this to /etc/apt/sources.list in end of file:
deb http://repo.percona.com/apt precise main deb-src http://repo.percona.com/apt precise main
First we need update and upgrade the ubuntu nodes, we need the same libraries on two or more nodes:
$sudo apt-get update
and may be:
$sudo apt-get upgrade
$sudo apt-get dist-upgrade
$sudo reboot
$apt-cache search percona|grep full
percona-xtradb-cluster-full-55- Percona XtraDB Cluster with Galera percona-xtradb-cluster-full-56- Percona XtraDB Cluster with Galera
Lets install 56
$sudo apt-get install percona-xtradb-cluster-full-56
-----------------
After rebooting stop mysql, if it started:
sudo /etc/init.d/mysql stop
Edit file my.cnf, if not exist, create it:
-------------
------
save it and try start mysql:
$sudo service mysql start
then check status:
$mysql -u root -ppasswd@ -e "show status like 'wsrep%';"
+------------------------------+--------------------------------------+
| Variable_name | Value |
+------------------------------+--------------------------------------+
| wsrep_local_state_uuid | b299724b-2ec5-11e4-baf7-4211948c6a81 |
...
| wsrep_local_state_comment | Synced |
| wsrep_cert_index_size | 0 |
| wsrep_causal_reads | 0 |
| wsrep_cert_interval | 0.000000 |
| wsrep_incoming_addresses |10.185.0.20:3306 |
...
| wsrep_cluster_state_uuid | b299724b-2ec5-11e4-baf7-4211948c6a81 |
| 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 <[email protected]> |
| wsrep_provider_version | 3.6(r3a949e6) |
| wsrep_ready | ON |
+------------------------------+--------------------------------------+
If it looks good.
Go to the second node
you have to do the same operations:
install percona (see above)
update & upgrade & dist-upgrade
file my.cnf is the same except:
#wsrep_cluster_address=gcomm:// #should be comment
wsrep_cluster_address=gcomm://10.185.0.20,10.185.0.42 #uncomment it
save it and try to start mysql:
$sudo service mysql start
if there are not any errors, you can check the status of the connection :
$mysql -u root -ppasswd@ -e "show status like 'wsrep%';"
+------------------------------+--------------------------------------+
| Variable_name | Value |
+------------------------------+--------------------------------------+
| wsrep_local_state_uuid | b299724b-2ec5-11e4-baf7-4211948c6a81 |
| wsrep_protocol_version | 6 |
...
| wsrep_local_send_queue_avg | 0.000000 |
| wsrep_local_recv_queue | 0 |
| wsrep_local_recv_queue_avg | 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_cert_interval | 0.000000 |
| wsrep_incoming_addresses | 10.185.0.42:3306,10.185.0.20:3306 |
| wsrep_evs_repl_latency | 0/0/0/0/0 |
| wsrep_cluster_conf_id | 4 |
| wsrep_cluster_size | 2 |
| wsrep_cluster_state_uuid | b299724b-2ec5-11e4-baf7-4211948c6a81 |
| 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 <[email protected]> |
| wsrep_provider_version | 3.6(r3a949e6) |
| wsrep_ready | ON |
+------------------------------+--------------------------------------+
-----------
status
wsrep_cluster_state_uuid | b299724b-2ec5-11e4-baf7-4211948c6a81
should be the same in first node
and
wsrep_incoming_addresses | 10.185.0.42:3306,10.185.0.20:3306
now we have two nodes in cluster.
Cluster can accept connection in both IP addresses:
10.185.0.42:3306 or 10.185.0.20:3306
Now we can edit the config file in node1:
#wsrep_cluster_address=gcomm:// #should be comment
wsrep_cluster_address=gcomm://10.185.0.20,10.185.0.42 #uncomment it
$sudo service mysql stop
$sudo service mysql start
After that you can check status again
$mysql -u root -ppasswd@ -e "show status like 'wsrep%';"
should works!
Share on Twitter Share on Facebook
Comments
There are currently no comments
New Comment