Galera replication
-
Upload
marian-marinov -
Category
Engineering
-
view
110 -
download
5
Transcript of Galera replication
GaleraGaleraMaster-MasterMaster-Master
ReplicationReplication
Marian HackMan Marinov <[email protected]>
What is the BinaryLog?
UPDATE t1 SET count=100 WHERE id=100UPDATE t1 SET count=100 WHERE id=100
CLIENTCLIENT
What is the BinaryLog?
UPDATE t1 SET count=100 WHERE id=100UPDATE t1 SET count=100 WHERE id=100
CLIENTCLIENT
What is the BinaryLog?
UPDATE t1 SET count=100 WHERE id=100UPDATE t1 SET count=100 WHERE id=100
CLIENTCLIENT
SUCCESS
What is the BinaryLog?
UPDATE t1 SET count=100 WHERE id=100UPDATE t1 SET count=100 WHERE id=100
CLIENTCLIENT
SUCCESS
Types of Replication
● STATEMENT● ROW● MIXED
● Master-Slave● Master-Master
Types of Replication
● STATEMENT
UPDATE t1 SET count=100 WHERE id=100;UPDATE t1 SET count=100 WHERE id=100;
INSERT INTO t1 VALUES (102, 1);INSERT INTO t1 VALUES (102, 1);
Types of Replication
● ROW
table t1 change:table t1 change:
ROW id=100 count=100ROW id=100 count=100
table t1 change:table t1 change:
add row with id=102, count=1add row with id=102, count=1
Types of Replication
● MIXED
UPDATE t1 SET count=100 WHERE id=100;UPDATE t1 SET count=100 WHERE id=100;
table t1 change:table t1 change:
ROW id=100 count=100ROW id=100 count=100
INSERT INTO t1 VALUES (102, 1);INSERT INTO t1 VALUES (102, 1);
table t1 change:table t1 change:
add row with id=102, count=1add row with id=102, count=1
What is Galera
● Write set replication - WSREPWrite set replication - WSREP● Global Transaction ID - GTIDGlobal Transaction ID - GTID
What is Galera
● Write set replication - WSREPWrite set replication - WSREP
UPDATE t1 SET count=100 WHERE id=100;UPDATE t1 SET count=100 WHERE id=100;
INSERT INTO t1 VALUES (102, 1);INSERT INTO t1 VALUES (102, 1);
Write setWrite set
What is Galera
● Write set replication - WSREPWrite set replication - WSREP
UPDATE t1 SET count=100 WHERE id=100;UPDATE t1 SET count=100 WHERE id=100;
INSERT INTO t1 VALUES (102, 1);INSERT INTO t1 VALUES (102, 1);
Write setWrite set
GTID: 318e70bb-4ba2-4707-aa5f-20cf44c3d367GTID: 318e70bb-4ba2-4707-aa5f-20cf44c3d367
What is Galera
● Write set replication - WSREPWrite set replication - WSREP
UPDATE t1 SET count=100 WHERE id=100;UPDATE t1 SET count=100 WHERE id=100;
INSERT INTO t1 VALUES (102, 1);INSERT INTO t1 VALUES (102, 1);
Write setWrite set
GTID: 318e70bb-4ba2-4707-aa5f-20cf44c3d367GTID: 318e70bb-4ba2-4707-aa5f-20cf44c3d367
Certification based replication???Certification based replication???
● WSREP XXX-XXX– certificate that it can proceed
– check based on table's primary key
How is it implemented?
How is it implemented?
How is it implemented?
● WSREP plugin– backing up data
● logs and files
– conns between nodes
– generating GTIDs
– certification of WSETs
WSREP
How is it implemented?
Node states
● State Snapshot Transfer (SST)– Logical - mysqldump
– Physical● rsync/rsync_wan● xtrabackup
wsrep_sst_method=xtrabackupv2● Incremental State Transfer (IST)
5a76ef62-30ec-11e1-0800-dba504cf2aab:197222
5a76ef62-30ec-11e1-0800-dba504cf2aab:201913
– Write-set cache (GCache)
Requirements
● binlog_format=ROW● Storage engine InnoDB/XtraDB● All tables should have a primary key
Setup
/etc/yum.repos.d/galera.repo
[galera]
name = Galera
baseurl = http://releases.galeracluster.com/centos/6/x86_64
gpgkey = http://releases.galeracluster.com/GPG-KEY-galeracluster.com
gpgcheck = 1
Setup
yum install \
Percona-XtraDB-Cluster-server \
Percona-XtraDB-Cluster-client \
Percona-XtraDB-Cluster-galera-3.x86_64 \
galera \
socat \
pv \
pigz \
nc
Setup
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
user=mysql
binlog_format=ROW
bind-address=0.0.0.0
default_storage_engine=innodb
innodb_autoinc_lock_mode=2
innodb_flush_log_at_trx_commit=0
innodb_buffer_pool_size=122M
Setup
wsrep_provider=/usr/lib64/galera3/libgalera_smm.so
wsrep_provider_options="gcache.size=300M;gcache.page_size=300M"
wsrep_cluster_name="example_cluster"
wsrep_cluster_address="gcomm://10.19.1.8,10.19.1.9"
wsrep_sst_method=xtrabackup-v2
wsrep_sst_auth="root:ensurethehighest"
Setup
[sst]
progress=/var/log/mysql/sst.log
streamfmt=xbstream
transferfmt=socat
encrypt=2
encrypt-algo=AES256
tkey=/etc/mysql/key.pem
tcert=/etc/mysql/cert.pem
compressor="pigz -6"
decompressor="pigz -d"
First start
# mysql_install_db
# service mysql start --wsrep-new-cluster
Adding new node
● Add GRANTs for the new machine– GRANT ALL ON *.* TO 'root'@'10.19.1.10' IDENTIFIED BY 'ensurethehighest';
● Copy the my.cnf from another node● Fix the node_name and node_address● Add the IP of the local node to cluster_address● Start MySQL on the new node● After the sync is done and the new node is in the cluster
– update the cluster_address in the configuration of the other nodes– update the cluster_address in the running mysql instances:
mysql> set global wsrep_cluster_address =
'gcomm://10.19.1.8,10.19.1.9,10.19.1.10';
Arbitrator
# chkconfig garb on
# cat /etc/sysconfig/garb
GALERA_NODES="10.19.1.8:4567 10.19.1.9:4567 10.19.1.10:4567"
GALERA_GROUP="gp_cluster"
# /etc/init.d/garb restart
QUESTIONS???QUESTIONS???
Marian HackMan Marinov <[email protected]>