SlideShare a Scribd company logo
1
Galera Cluster For MySQL
Alexey Yurchenko, Codership Oy
Percona Live MySQL User Conference and Expo, 2012
2
Follow the tutorial
Using Percona XtraDB Cluster RPMs, at Amazon
EC2
Datacenters:
us-west-1
us-east-1
eu-west-1
(look for galera_tutorial_* images)
3
Agenda
1. Introduction (30-45 min)
a. Galera architecture overview
b.Important terms and concepts
2. Migration from stock MySQL replication (30 min)
3. LAN cluster setup (30 min)
a. Node configuration
b.Joining the cluster, state transfer
c. Executing SQL load
4. Node failure and recovery under load (30 min)
a. Planned restart
b.Hard crash
c. Split-brain
5. WAN replication (30 min)
6. Troubleshooting
7. Q&A
4
What Is Galera Cluster for MySQL?
MySQL
server ✕ N
Galera
Cluster
for
MySQL
=
5
What is Galera Cluster for MySQL
Each node is fully representative of the cluster:
1. No single point of failure
2. Synchronous...............
3. 99.9% transparency
●
No data loss
●
No slave lag
●
No master failover
●
Full multi-master
6
What Is Galera Cluster for MySQL?
MySQL
Galera
Cluster
for
MySQLMySQL
MySQL
MySQL
7
What Is Galera Cluster for MySQL?
Galera
Cluster
for
MySQL
MySQL
server
Server
as a
part of
the
cluster
8
Migrating from MySQL master-slave
to Galera
9
What will happen 1
Master Slave
MySQL
master-slave replication
Clients
We start with regular MySQL master-slave
10
What will happen 2
Master
Slave /
G. node1
MySQL
master-slave replication
Clients
Upgrade MySQL slave to Galera node
Single node
Galera cluster
11
What will happen 3
Master
Slave /
G. node1
MySQL
master-slave replication
Clients
Add a second Galera node using state
snapshot transfer (SST) 2-node
Galera cluster
G. node2
12
What will happen 4
Master
Slave /
G. node1
Clients
Failover client connections to Galera cluster
and stop master-slave. 2-node
Galera cluster
G. node2
13
What will happen 5
Master /
G. node3
Slave /
G. node1
Clients
Upgrade MySQL master to Galera and join to
cluster using incremental state transfer (IST)
3-node Galera cluster
G. node2
14
Converting slave to Galera node
1. Stop the slave: slave> STOP SLAVE;
2. Upgrade the software:
slave# rpm -e MySQL-server
slave# rpm -Uvh percona-xtrabackup-2.0.0-*.rpm 
Percona-XtraDB-Cluster-galera-2.0-*.rpm 
Percona-XtraDB-Cluster-server-5.5.20-23.4*.rpm
3. Configure wsrep options in my.cnf
4. Add log_slave_updates=1 to my.cnf
Remove read_only = 1 from my.cnf
5. Restart the server.
6. Start the slave: slave> START SLAVE;
15
Sample my.cnf for slave after upgrade
[mysqld]
wsrep_cluster_address=/usr/lib64/libgalera_smm.so
wsrep_node_address=gcomm:// # NOTE: This must be changed to peer address ASAP!
wsrep_node_name=node1
wsrep_provider='/usr/lib64/galera/libgalera_smm.so'
wsrep_provider_options='gcache.size=1G;socket.ssl_key=my_key;socket.ssl_cert=my_cert'
wsrep_slave_threads=16
wsrep_sst_method=xtrabackup
wsrep_sst_auth=root:
innodb_buffer_pool_size=1G
innodb_log_file_size=256M
innodb_autoinc_lock_mode=2
innodb_flush_log_at_trx_commit=0
innodb_doublewrite=0
innodb_file_per_table=1
binlog_format=ROW
datadir=/var/lib/mysql
log-bin = mysql-bin
server-id = 2
relay-log = mysql-relay-bin
#read-only = 1
log-slave-updates = 1
16
Important wsrep variables 1
wsrep_provider:
A path to wsrep provider library.
17
Important wsrep variables 2
wsrep_cluster_address:
Where to connect to cluster. Has a URI form:
'gcomm://another_node_address?opt1=val1&opt2=val2'
But normally just
'gcomm://another_node_address'
A special form to start a new cluster:
'gcomm://'
!!! Danger !!! Never leave it in my.cnf !!!
18
Important wsrep variables 3
wsrep_node_address:
An optional address of the node. A short-cut
way to configure listen addresses for
replication and state transfers.
By default it will be initialized to the first
network interface returned by ifconfig. This
however is unreliable. For best results it must
be initialized explicitly.
19
Important wsrep variables 4
wsrep_node_name:
An optional name for the node. It will be used
in logging and to identify the desired donor
for state transfer.
By default it will be initialized to hostname,
but that may turn out to be not unique (it does
not have to) or unwieldy.
20
Important wsrep variables 5
wsrep_provider_options:
Semicolon-separated list of options specific to
provider. Some useful Galera options:
gcache.size – a size of the permanent
transaction on-disk cache.
socket.ssl_key, socket.ssl_cert – SSL key and
certificate files.
21
Important wsrep variables 6
wsrep_slave_threads:
How many threads to launch for parallel
applying.
> 1 requires certain InnoDB settings. Applying
of STATEMENT-based events is always
serialized.
22
Important wsrep variables 7
wsrep_sst_method:
Base package contains scripts for mysqldump,
rsync and xtrabackup based state snapshot
transfers. Own scripts can be crafted (handy for
backup). Default is mysqldump. It also requires
setting wsrep_sst_auth to MySQL root
user:password pair.
23
Status of Galera Replication
wsrep_ready
wsrep_cluster_status
wsrep_connected
Wait for node to sync with
cluster
No
Non-Primary
Primary
Network partitioning!
wsrep_local_state_uuid
wsrep_last_committed
Yes
Yes
No: reconnect
24
Starting a 2nd
Galera node
1. Install Percona RPMs. No need to configure
initial database, it will be brought by SST.
2. Edit my.cnf. Set wsrep_cluster_address to
slave node IP.
3. Start mysqld:
node2# service mysql start
4. Update my.cnf on slave:
set wsrep_cluster_address to 2nd
node IP.
25
Important Concepts 1
Application State:
For Galera application state is a set of data that
application decides to replicate. By default it is a
whole of MySQL databases (i.e. every node is a
complete replica of another).
Application state is identified by a Global Transation
ID.
26
Important Concepts 1
Global Transaction ID (GTID):
f7720ae0-6f9b-11e1-0800-598d1b386dce:13989753562f7720ae0-6f9b-11e1-0800-598d1b386dce 32520198989
CLUSTER/HISTORY/STATE
UUID
TRX/STATE
SEQNO
27
Important Concepts 1
Initial State:
f7720ae0-6f9b-11e1-0800-598d1b386dce:0
Undefined State:
00000000-0000-0000-0000-000000000000:-1
28
Important Concepts 1
State Snapshot Transfer (SST):
A transfer of a consistent snapshot of a node
state corresponding to a certain GTID in order to
initialize the state of a newly joining cluster node
from an already initialized node (donor).
29
Performance of Galera replication
wsrep_flow_control_paused: what fraction of the
time replication was paused.
wsrep_flow_control_sent: how many times this
node paused replication.
wsrep_local_recv_queue_avg: average length of
slave trx queue – a sign of slave side bottleneck.
wsrep_cert_deps_distance: how many transactions
can be applied in parallel.
wsrep_local_send_queue_avg: a sign of network
bottleneck.
30
Failover to Galera cluster
1. Briefly pause the load.
2. Make sure slave caught up with the master:
master> SHOW MASTER STATUSG
slave> SHOW SLAVE STATUSG
3. Take note of GTID on slave:
slave> SHOW STATUS LIKE 'wsrep_%';
4. Set binary log format to ROW on slave:
slave> SET GLOBAL binlog_format=ROW;
5. Direct the load to slave and the 2nd
Galera node.
31
Make former master a Galera node
1. Upgrade software.
2. Configure my.cnf.
Set wsrep_cluster_address to any of Galera
nodes' names.
3. Copy/forge grastate.dat file. Set state
information to the GTID we noted previous
page.
4. Start mysqld.
32
Important Concepts 2
Incremental State Transfer (IST):
Catch up with the cluster by replaying
missing transactions. Requires
➔
known initial node state;
➔
enough transactions cached at the donor.
33
Important Concepts 3
Node Failure:
For Galera node a peer crash is indistinguishable from
network failure. Hence node is considered failed when it
no longer can be communicated with. Communication is
verified by receiving messages or keepalives.
evs.inactive_timeout sets the timeout after which node
is considered inactive (dead).
evs.suspect_timeout sets the timeout after which the
node can be pronounced dead if everyone else agrees.
34
Galera WAN Replication
Currently Galera has no notion of a local or
remote node – it works as long as TCP works.
May need tuning to be more tolerant to
network hiccups – Galera (wsrep provider)
options:
evs.keepalive_period = PT3S;
evs.inactive_check_period = PT10S;
evs.suspect_timeout = PT30S;
evs.inactive_timeout = PT1M;
evs.consensus_timeout = PT1M
35
Important Concepts 4
Primary Component (PC):
PC
PC PC
36
Important Concepts 5
Split-brain:
PC
?
DC1
DC2
37
Galera Arbitrator
DC1 DC2
garbd
38
Galera Arbitrator
DC1 DC2
garbd
X
39
Galera Arbitrator
DC1 DC2
garbd
+
X
40
Galera Arbitrator
DC1 DC2
garbd
X
relay
41
Backup, backup, backup
Just backup one of the nodes. But backup
without GTID is not that useful - backup with
GTID:
1) xtrabackup:
node# innobackupex --galera-info
creates xtrabackup_galera_info in the datadir
2) Custom backup with arbitrator:
node# garbd … --donor node1 --sst custom
calls wsrep_sst_custom on node1.

More Related Content

PDF
Percona XtraDB 集群安装与配置
PDF
Percona XtraDB 集群内部
PDF
Advanced Percona XtraDB Cluster in a nutshell... la suite
PDF
Advanced percona xtra db cluster in a nutshell... la suite plsc2016
PDF
Percon XtraDB Cluster in a nutshell
PDF
LXC on Ganeti
ODP
Plmce2k15 15 tips galera cluster
PPTX
How to Troubleshoot OpenStack Without Losing Sleep
Percona XtraDB 集群安装与配置
Percona XtraDB 集群内部
Advanced Percona XtraDB Cluster in a nutshell... la suite
Advanced percona xtra db cluster in a nutshell... la suite plsc2016
Percon XtraDB Cluster in a nutshell
LXC on Ganeti
Plmce2k15 15 tips galera cluster
How to Troubleshoot OpenStack Without Losing Sleep

What's hot (20)

PDF
Мастер-класс "Логическая репликация и Avito" / Константин Евтеев, Михаил Тюр...
PPTX
Query logging with proxysql
PDF
Fosdem 2014 - MySQL & Friends Devroom: 15 tips galera cluster
PDF
MySQL replication & cluster
PPTX
Troubleshooting containerized triple o deployment
PDF
Multimaster
PDF
GitLab PostgresMortem: Lessons Learned
PDF
1 m+ qps on mysql galera cluster
PDF
MySQL async message subscription platform
PDF
Anatomy of neutron from the eagle eyes of troubelshoorters
PDF
Training Slides: Advanced 302: Performing Schema Changes in a Multi-Site/Mult...
PDF
Training Slides: Basics 105: Backup, Recovery and Provisioning Within Tungste...
PPTX
My sql failover test using orchestrator
PDF
PostgreSQL Streaming Replication Cheatsheet
PPTX
Streaming Replication Made Easy in v9.3
PDF
Oracle cluster installation with grid and nfs
PDF
Sdnds tw-meetup-2
PDF
Corosync and Pacemaker
ODP
MySQL 101 PHPTek 2017
PDF
Ceph issue 해결 사례
Мастер-класс "Логическая репликация и Avito" / Константин Евтеев, Михаил Тюр...
Query logging with proxysql
Fosdem 2014 - MySQL & Friends Devroom: 15 tips galera cluster
MySQL replication & cluster
Troubleshooting containerized triple o deployment
Multimaster
GitLab PostgresMortem: Lessons Learned
1 m+ qps on mysql galera cluster
MySQL async message subscription platform
Anatomy of neutron from the eagle eyes of troubelshoorters
Training Slides: Advanced 302: Performing Schema Changes in a Multi-Site/Mult...
Training Slides: Basics 105: Backup, Recovery and Provisioning Within Tungste...
My sql failover test using orchestrator
PostgreSQL Streaming Replication Cheatsheet
Streaming Replication Made Easy in v9.3
Oracle cluster installation with grid and nfs
Sdnds tw-meetup-2
Corosync and Pacemaker
MySQL 101 PHPTek 2017
Ceph issue 해결 사례
Ad

Similar to MySQL Galera 集群 (20)

PDF
Percona XtraDB 集群文档
PDF
Percona Cluster Installation with High Availability
PDF
MariaDB Auto-Clustering, Vertical and Horizontal Scaling within Jelastic PaaS
PDF
Container Orchestration from Theory to Practice
PDF
Container orchestration from theory to practice
ODP
Using Galera Cluster to Power Geo-distributed Applications on the WAN
PDF
Highly Available Load Balanced Galera MySql Cluster
PDF
Plny12 galera-cluster-best-practices
PDF
FOSDEM 2012: MySQL synchronous replication in practice with Galera
ODP
Nagios Conference 2014 - Troy Lea - Monitoring VMware Virtualization Using vMA
PPT
Galera Cluster Best Practices for DBA's and DevOps Part 1
PDF
How to understand Galera Cluster - 2013
PDF
Webinar slides: Introducing Galera 3.0 - Now supporting MySQL 5.6
PPT
MySQL Cluster Basics
PPTX
Neutron DVR
PPTX
My SQL Portal Database (Cluster)
PPTX
RAC-Installing your First Cluster and Database
PDF
MySQL Live Migration - Common Scenarios
PPT
Galera webinar migration to galera cluster from my sql async replication
Percona XtraDB 集群文档
Percona Cluster Installation with High Availability
MariaDB Auto-Clustering, Vertical and Horizontal Scaling within Jelastic PaaS
Container Orchestration from Theory to Practice
Container orchestration from theory to practice
Using Galera Cluster to Power Geo-distributed Applications on the WAN
Highly Available Load Balanced Galera MySql Cluster
Plny12 galera-cluster-best-practices
FOSDEM 2012: MySQL synchronous replication in practice with Galera
Nagios Conference 2014 - Troy Lea - Monitoring VMware Virtualization Using vMA
Galera Cluster Best Practices for DBA's and DevOps Part 1
How to understand Galera Cluster - 2013
Webinar slides: Introducing Galera 3.0 - Now supporting MySQL 5.6
MySQL Cluster Basics
Neutron DVR
My SQL Portal Database (Cluster)
RAC-Installing your First Cluster and Database
MySQL Live Migration - Common Scenarios
Galera webinar migration to galera cluster from my sql async replication
Ad

More from YUCHENG HU (20)

PDF
Confluencewiki 使用空间
PDF
PDF
Presta shop 1.6 如何安装简体中文语言文件
PDF
Logback 介绍
PDF
Presta shop 1.6 详细安装指南
PDF
Presta shop 1.6 的安装环境
PDF
Presta shop 1.6 如何安装简体中文语言文件
PDF
Presta shop 1.6 图文安装教程
PDF
V tiger 5.4.0 图文安装教程
PDF
Confluence 回顾(retrospectives) 蓝图 cwikiossez
PDF
Confluence 会议记录(meeting notes)蓝图 cwikiossez
PDF
VTIGER - 销售机会 - CWIKIOSSEZ
PDF
Confluence 使用一个模板新建一个页面 cwikiossez
PDF
Confluence 使用模板
PDF
Cwikiossez confluence 订阅页面更新邮件通知
PDF
Cwikiossez confluence 关注页面 博客页面和空间
PDF
My sql università di enna a.a. 2005-06
PDF
My sql would you like transactions
PDF
MySQL 指南
PDF
MySQL 简要介绍
Confluencewiki 使用空间
Presta shop 1.6 如何安装简体中文语言文件
Logback 介绍
Presta shop 1.6 详细安装指南
Presta shop 1.6 的安装环境
Presta shop 1.6 如何安装简体中文语言文件
Presta shop 1.6 图文安装教程
V tiger 5.4.0 图文安装教程
Confluence 回顾(retrospectives) 蓝图 cwikiossez
Confluence 会议记录(meeting notes)蓝图 cwikiossez
VTIGER - 销售机会 - CWIKIOSSEZ
Confluence 使用一个模板新建一个页面 cwikiossez
Confluence 使用模板
Cwikiossez confluence 订阅页面更新邮件通知
Cwikiossez confluence 关注页面 博客页面和空间
My sql università di enna a.a. 2005-06
My sql would you like transactions
MySQL 指南
MySQL 简要介绍

Recently uploaded (20)

PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PPTX
Big Data Technologies - Introduction.pptx
PPTX
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
PPTX
Cloud computing and distributed systems.
PDF
Electronic commerce courselecture one. Pdf
PDF
Approach and Philosophy of On baking technology
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PPT
Teaching material agriculture food technology
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PDF
CIFDAQ's Market Insight: SEC Turns Pro Crypto
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
DOCX
The AUB Centre for AI in Media Proposal.docx
PPTX
MYSQL Presentation for SQL database connectivity
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
Big Data Technologies - Introduction.pptx
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
Cloud computing and distributed systems.
Electronic commerce courselecture one. Pdf
Approach and Philosophy of On baking technology
Reach Out and Touch Someone: Haptics and Empathic Computing
The Rise and Fall of 3GPP – Time for a Sabbatical?
Teaching material agriculture food technology
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
Digital-Transformation-Roadmap-for-Companies.pptx
Dropbox Q2 2025 Financial Results & Investor Presentation
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
NewMind AI Weekly Chronicles - August'25 Week I
CIFDAQ's Market Insight: SEC Turns Pro Crypto
Per capita expenditure prediction using model stacking based on satellite ima...
The AUB Centre for AI in Media Proposal.docx
MYSQL Presentation for SQL database connectivity
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
Agricultural_Statistics_at_a_Glance_2022_0.pdf

MySQL Galera 集群

  • 1. 1 Galera Cluster For MySQL Alexey Yurchenko, Codership Oy Percona Live MySQL User Conference and Expo, 2012
  • 2. 2 Follow the tutorial Using Percona XtraDB Cluster RPMs, at Amazon EC2 Datacenters: us-west-1 us-east-1 eu-west-1 (look for galera_tutorial_* images)
  • 3. 3 Agenda 1. Introduction (30-45 min) a. Galera architecture overview b.Important terms and concepts 2. Migration from stock MySQL replication (30 min) 3. LAN cluster setup (30 min) a. Node configuration b.Joining the cluster, state transfer c. Executing SQL load 4. Node failure and recovery under load (30 min) a. Planned restart b.Hard crash c. Split-brain 5. WAN replication (30 min) 6. Troubleshooting 7. Q&A
  • 4. 4 What Is Galera Cluster for MySQL? MySQL server ✕ N Galera Cluster for MySQL =
  • 5. 5 What is Galera Cluster for MySQL Each node is fully representative of the cluster: 1. No single point of failure 2. Synchronous............... 3. 99.9% transparency ● No data loss ● No slave lag ● No master failover ● Full multi-master
  • 6. 6 What Is Galera Cluster for MySQL? MySQL Galera Cluster for MySQLMySQL MySQL MySQL
  • 7. 7 What Is Galera Cluster for MySQL? Galera Cluster for MySQL MySQL server Server as a part of the cluster
  • 8. 8 Migrating from MySQL master-slave to Galera
  • 9. 9 What will happen 1 Master Slave MySQL master-slave replication Clients We start with regular MySQL master-slave
  • 10. 10 What will happen 2 Master Slave / G. node1 MySQL master-slave replication Clients Upgrade MySQL slave to Galera node Single node Galera cluster
  • 11. 11 What will happen 3 Master Slave / G. node1 MySQL master-slave replication Clients Add a second Galera node using state snapshot transfer (SST) 2-node Galera cluster G. node2
  • 12. 12 What will happen 4 Master Slave / G. node1 Clients Failover client connections to Galera cluster and stop master-slave. 2-node Galera cluster G. node2
  • 13. 13 What will happen 5 Master / G. node3 Slave / G. node1 Clients Upgrade MySQL master to Galera and join to cluster using incremental state transfer (IST) 3-node Galera cluster G. node2
  • 14. 14 Converting slave to Galera node 1. Stop the slave: slave> STOP SLAVE; 2. Upgrade the software: slave# rpm -e MySQL-server slave# rpm -Uvh percona-xtrabackup-2.0.0-*.rpm Percona-XtraDB-Cluster-galera-2.0-*.rpm Percona-XtraDB-Cluster-server-5.5.20-23.4*.rpm 3. Configure wsrep options in my.cnf 4. Add log_slave_updates=1 to my.cnf Remove read_only = 1 from my.cnf 5. Restart the server. 6. Start the slave: slave> START SLAVE;
  • 15. 15 Sample my.cnf for slave after upgrade [mysqld] wsrep_cluster_address=/usr/lib64/libgalera_smm.so wsrep_node_address=gcomm:// # NOTE: This must be changed to peer address ASAP! wsrep_node_name=node1 wsrep_provider='/usr/lib64/galera/libgalera_smm.so' wsrep_provider_options='gcache.size=1G;socket.ssl_key=my_key;socket.ssl_cert=my_cert' wsrep_slave_threads=16 wsrep_sst_method=xtrabackup wsrep_sst_auth=root: innodb_buffer_pool_size=1G innodb_log_file_size=256M innodb_autoinc_lock_mode=2 innodb_flush_log_at_trx_commit=0 innodb_doublewrite=0 innodb_file_per_table=1 binlog_format=ROW datadir=/var/lib/mysql log-bin = mysql-bin server-id = 2 relay-log = mysql-relay-bin #read-only = 1 log-slave-updates = 1
  • 16. 16 Important wsrep variables 1 wsrep_provider: A path to wsrep provider library.
  • 17. 17 Important wsrep variables 2 wsrep_cluster_address: Where to connect to cluster. Has a URI form: 'gcomm://another_node_address?opt1=val1&opt2=val2' But normally just 'gcomm://another_node_address' A special form to start a new cluster: 'gcomm://' !!! Danger !!! Never leave it in my.cnf !!!
  • 18. 18 Important wsrep variables 3 wsrep_node_address: An optional address of the node. A short-cut way to configure listen addresses for replication and state transfers. By default it will be initialized to the first network interface returned by ifconfig. This however is unreliable. For best results it must be initialized explicitly.
  • 19. 19 Important wsrep variables 4 wsrep_node_name: An optional name for the node. It will be used in logging and to identify the desired donor for state transfer. By default it will be initialized to hostname, but that may turn out to be not unique (it does not have to) or unwieldy.
  • 20. 20 Important wsrep variables 5 wsrep_provider_options: Semicolon-separated list of options specific to provider. Some useful Galera options: gcache.size – a size of the permanent transaction on-disk cache. socket.ssl_key, socket.ssl_cert – SSL key and certificate files.
  • 21. 21 Important wsrep variables 6 wsrep_slave_threads: How many threads to launch for parallel applying. > 1 requires certain InnoDB settings. Applying of STATEMENT-based events is always serialized.
  • 22. 22 Important wsrep variables 7 wsrep_sst_method: Base package contains scripts for mysqldump, rsync and xtrabackup based state snapshot transfers. Own scripts can be crafted (handy for backup). Default is mysqldump. It also requires setting wsrep_sst_auth to MySQL root user:password pair.
  • 23. 23 Status of Galera Replication wsrep_ready wsrep_cluster_status wsrep_connected Wait for node to sync with cluster No Non-Primary Primary Network partitioning! wsrep_local_state_uuid wsrep_last_committed Yes Yes No: reconnect
  • 24. 24 Starting a 2nd Galera node 1. Install Percona RPMs. No need to configure initial database, it will be brought by SST. 2. Edit my.cnf. Set wsrep_cluster_address to slave node IP. 3. Start mysqld: node2# service mysql start 4. Update my.cnf on slave: set wsrep_cluster_address to 2nd node IP.
  • 25. 25 Important Concepts 1 Application State: For Galera application state is a set of data that application decides to replicate. By default it is a whole of MySQL databases (i.e. every node is a complete replica of another). Application state is identified by a Global Transation ID.
  • 26. 26 Important Concepts 1 Global Transaction ID (GTID): f7720ae0-6f9b-11e1-0800-598d1b386dce:13989753562f7720ae0-6f9b-11e1-0800-598d1b386dce 32520198989 CLUSTER/HISTORY/STATE UUID TRX/STATE SEQNO
  • 27. 27 Important Concepts 1 Initial State: f7720ae0-6f9b-11e1-0800-598d1b386dce:0 Undefined State: 00000000-0000-0000-0000-000000000000:-1
  • 28. 28 Important Concepts 1 State Snapshot Transfer (SST): A transfer of a consistent snapshot of a node state corresponding to a certain GTID in order to initialize the state of a newly joining cluster node from an already initialized node (donor).
  • 29. 29 Performance of Galera replication wsrep_flow_control_paused: what fraction of the time replication was paused. wsrep_flow_control_sent: how many times this node paused replication. wsrep_local_recv_queue_avg: average length of slave trx queue – a sign of slave side bottleneck. wsrep_cert_deps_distance: how many transactions can be applied in parallel. wsrep_local_send_queue_avg: a sign of network bottleneck.
  • 30. 30 Failover to Galera cluster 1. Briefly pause the load. 2. Make sure slave caught up with the master: master> SHOW MASTER STATUSG slave> SHOW SLAVE STATUSG 3. Take note of GTID on slave: slave> SHOW STATUS LIKE 'wsrep_%'; 4. Set binary log format to ROW on slave: slave> SET GLOBAL binlog_format=ROW; 5. Direct the load to slave and the 2nd Galera node.
  • 31. 31 Make former master a Galera node 1. Upgrade software. 2. Configure my.cnf. Set wsrep_cluster_address to any of Galera nodes' names. 3. Copy/forge grastate.dat file. Set state information to the GTID we noted previous page. 4. Start mysqld.
  • 32. 32 Important Concepts 2 Incremental State Transfer (IST): Catch up with the cluster by replaying missing transactions. Requires ➔ known initial node state; ➔ enough transactions cached at the donor.
  • 33. 33 Important Concepts 3 Node Failure: For Galera node a peer crash is indistinguishable from network failure. Hence node is considered failed when it no longer can be communicated with. Communication is verified by receiving messages or keepalives. evs.inactive_timeout sets the timeout after which node is considered inactive (dead). evs.suspect_timeout sets the timeout after which the node can be pronounced dead if everyone else agrees.
  • 34. 34 Galera WAN Replication Currently Galera has no notion of a local or remote node – it works as long as TCP works. May need tuning to be more tolerant to network hiccups – Galera (wsrep provider) options: evs.keepalive_period = PT3S; evs.inactive_check_period = PT10S; evs.suspect_timeout = PT30S; evs.inactive_timeout = PT1M; evs.consensus_timeout = PT1M
  • 35. 35 Important Concepts 4 Primary Component (PC): PC PC PC
  • 41. 41 Backup, backup, backup Just backup one of the nodes. But backup without GTID is not that useful - backup with GTID: 1) xtrabackup: node# innobackupex --galera-info creates xtrabackup_galera_info in the datadir 2) Custom backup with arbitrator: node# garbd … --donor node1 --sst custom calls wsrep_sst_custom on node1.