Galera Cluster Installation And Quick Start

Philip Stoev Codership Oy 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 and OpenStack distros

2

Galera Cluster variants

Galera Cluster for MySQL by Codership MariaDB calls Galera Percona calls Galera MariaDB Galera Cluster or Percona XtraDB Cluster MariaDB Enterprise Cluster MySQL

Percona MariaDB API m Server erge rge me API API

Coderhips’s Galera Replication plugin

3 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 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 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 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 -wsrep-shared-5.6 yum –y install galera-3 mysql-wsrep-5.6 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 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... " 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 | Monitoring

Traditional MySQL monitoring methods are used: • SHOW STATUS • SHOW PROCESSLIST • The MySQL error log – all Galera messages go there • Queries against INFORMATION_SCHEMA 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) 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 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 WHERE T.table_name = C.table_name AND T.table_schema = C.table_schema ) AND table_schema NOT IN ('mysql','information_schema','performance_schema'); Thank You

Downloads, documentation:

http://www.galeracluster.com

Discussion group: [email protected]