In this webinar, we will describe how to get started with Galera Cluster and build a functional multi-master cluster. First, will show how to easily install the required packages using the new preferred installation method – the dedicated Galera package repository. Then we will discuss the important Galera configuration settings and how to select values for them. Finally, we will demonstrate how to bootstrap a 3-node Galera installation with the right sequence of steps.
Once the nodes are up and running we will discuss how to monitor the health of the cluster and which status variables are important to watch.
Galera Cluster is trusted by thousands of users. Galera Cluster powers Percona XtraDB Cluster and MariaDB Enterprise Cluster. This is a webinar presented by Codership, the developers and experts of Galera Cluster.
2. 2
Codership
Established 2007 (Galera development started)
3 co-founder engineers:
Seppo Jaakola, CEO, Teemu Ollakka, CTO, Alex Yurchenko, architect
Team have developed three MySQL cluster software earlier.
Based on: http://www.dsn.jhu.edu/~yairamir/Yair_phd.pdf
http://www.inf.usi.ch/faculty/pedone/Paper/199x/These-2090-Pedone.pdf
Product: Galera Cluster for MySQL, open source
Thousands of users in e-commerce, telecom, gaming, insurance, betting healthcare,
media, marketing, advertising, travel, universities, software-as-service, Paas, Iaas, etc
Galera Cluster is included and will be included in Linux and OpenStack distros
3. 3
Galera Cluster variants
API
MySQL
Coderhips’s Galera Replication plugin
API
Percona
Server
API
MariaDB
merge
merge
Percona calls Galera
Percona XtraDB Cluster
Galera Cluster for MySQL by Codership
MariaDB calls Galera
MariaDB Galera Cluster or
MariaDB Enterprise Cluster
4. Agenda
• A very quick overview of Galera Cluster
• Adding the Galera package repository
• Installing packages
• Creating a configuration file
• Bootstrapping a 3-node cluster
• Monitoring
5. Galera Cluster Overview
Synchronous
– each transaction is immediately replicated on all nodes at commit
– no stale slaves
Multi-Master
– read from and write to any node
– automatic transaction conflict detection
Replication
– a copy of the entire dataset is available on all nodes
– new nodes can join automatically
For MySQL
– based on a modified version of MySQL (5.5, 5.6 with 5.7 coming up)
– InnoDB storage engine
6. And more …
• Recovers from node failures within seconds
• Data consistency protections
– avoids reading stale data
– prevents unsafe data modifications
• WAN support
– nodes can be on different continents
– end-to-end encryption
– optimized communication with least latency
7. Package Installation (CentOS, RHEL)
1. Remove existing MySQL server packages
2. Configure the Galera Cluster repository
Add a .repo file in /etc/yum.repos.d/:
[galera]
name = Galera
baseurl = http://releases.galeracluster.com/centos/7/x86_64
gpgkey = http://releases.galeracluster.com/GPG-KEY-galeracluster.com
gpgcheck = 1
(note distribution name and release number are specified)
1. Install Galera Cluster Packages
yum –y upgrade mysql-wsrep-shared-5.6
yum –y install galera-3 mysql-wsrep-5.6
8. Preparing the System
• Nodes should have identical hardware
• Firewall ports to open:
3306, 4567, 4568, 4444
• Disable SELinux
– a policy can be created and enabled later
9. The my.cnf Configuration File
• All Galera configuration is in my.cnf
• Keep the my.cnf files on all nodes identical
• InnoDB settings are important
optimize individual nodes as you normally would:
– InnoDB buffer size
– InnoDB log file size
• Galera-specific settings:
default_storage_engine=InnoDB
binlog_format=ROW
innodb_autoinc_lock_mode=2
wsrep_provider=/usr/lib64/galera-3/libgalera_smm.so
wsrep_cluster_address="gcomm://node1,node2,node3... "
10. Bootstrap
1. Start first node with –wsrep-new-cluster:
sudo service mysql start --wsrep-new-cluster
1. Confirm a single-node cluster:
SHOW STATUS LIKE 'wsrep_%'
| wsrep_cluster_status | Primary |
| wsrep_cluster_size | 1 |
1. Start all other nodes normally
sudo service mysql start
1. Confirm nodes have joined:
SHOW STATUS LIKE 'wsrep_%'
| wsrep_cluster_size | 3 |
11. Monitoring
Traditional MySQL monitoring methods are used:
• SHOW STATUS
• SHOW PROCESSLIST
• The MySQL error log
– all Galera messages go there
• Queries against INFORMATION_SCHEMA
12. SHOW STATUS
• Node health variables:
– wsrep_ready = ON
– wsrep_cluster_size
– wsrep_cluster_status = Primary
– wsrep_local_status = Synced
• Replication health variables:
– wsrep_flow_control_paused < 0.05
– wsrep_local_bf_aborts + wsrep_local_cert_failures
(do not forget periodic FLUSH STATUS)
13. SHOW PROCESSLIST
• Queries to watch out for:
– long “Query end” phase
• replication takes place during that phase
– long-running DDL
• under default settings may block cluster
14. INFORMATION_SCHEMA
• Avoid non-InnoDB tables:
SELECT TABLE_SCHEMA, TABLE_NAME
FROM INFORMATION_SCHEMA.TABLES
WHERE ENGINE != 'InnoDB'
AND TABLE_SCHEMA NOT IN ('mysql','performance_schema',
'information_schema');
• Avoid tables with no primary key:
SELECT T.TABLE_SCHEMA, T.TABLE_NAME
FROM information_schema.tables AS T
WHERE (table_schema, table_name)
NOT IN (SELECT table_schema, table_name
FROM information_schema.table_constraints AS C
WHERE T.table_name = C.table_name
AND T.table_schema = C.table_schema )
AND table_schema NOT IN
('mysql','information_schema','performance_schema');