PerconaXtraDB Cluster with Galera Replication On Debian Jessie
Hey!
Today we will configure and run MySQL 5.7 cluster (with replication) using PerconaXtraDB Cluster with Galera. So let's begin...
PerconaXtraDB cluster configuration
node1 10.0.0.1
node2 10.0.0.2
node3 10.0.0.3
NODE1
wget https://repo.percona.com/apt/percona-release_0.1-4.$(lsb_release -sc)_all.deb
dpkg -i percona-release_0.1-4.$(lsb_release -sc)_all.deb
apt-get update
apt-get remove mysql-server mysql-client mysql-common
Your old databases will be preserved and of course before doing all these things be sure that you have backups...
/etc/init.d/apparmor stop
/etc/init.d/apparmor teardown
update-rc.d -f apparmor remove
apt-get autoremove
apt-get install ntp percona-xtradb-cluster-57 # (do it on all nodes)
rm /etc/mysql/percona-xtradb-cluster.conf.d/wsrep.cnf
mysql> CREATE USER 'sstuser'@'localhost' IDENTIFIED BY 'password‘;
mysql> GRANT PROCESS, RELOAD, LOCK TABLES, REPLICATION CLIENT ON *.* TO 'sstuser'@'localhost';
mysql> FLUSH PRIVILEGES;
Before your first time run cluster...
NODE1
Make sure you are using my.conf, wsrep_cluster_address=gcomm:// without all nodes ip adresses. Run the following.
systemctl unmask mysql.serviceservice mysql restart-bootstrap
NODE1 /etc/mysql/my.cnf
[mysqld]
wsrep_provider=/usr/lib/libgalera_smm.so
wsrep_cluster_name=cluster
#wsrep_cluster_address=gcomm://10.0.0.1,10.0.0.2,10.0.0.3
wsrep_cluster_address=gcomm://
wsrep_node_name=node1
wsrep_node_name=node1
wsrep_node_address=10.0.0.1
wsrep_sst_method=xtrabackup-v2
wsrep_sst_auth=sstuser:password
pxc_strict_mode=ENFORCING
binlog_format=ROW
default_storage_engine=InnoDB
innodb_autoinc_lock_mode=2
NODE2 /etc/mysql/my.cnf
[mysqld]
wsrep_provider=/usr/lib/libgalera_smm.so
wsrep_cluster_name=cluster
wsrep_cluster_address=gcomm://10.0.0.1,10.0.0.2,10.0.0.3
wsrep_node_name=node2
wsrep_node_address=10.0.0.2
wsrep_sst_method=xtrabackup-v2
wsrep_sst_auth=sstuser:password
pxc_strict_mode=ENFORCING
binlog_format=ROW
default_storage_engine=InnoDB
innodb_autoinc_lock_mode=2
NODE3 /etc/mysql/my.cnf
[mysqld]
wsrep_provider=/usr/lib/libgalera_smm.so
wsrep_cluster_name=cluster
wsrep_cluster_address=gcomm://10.0.0.1,10.0.0.2,10.0.0.3
wsrep_node_name=node3
wsrep_node_address=10.0.0.3
wsrep_sst_method=xtrabackup-v2
wsrep_sst_auth=sstuser:password
pxc_strict_mode=ENFORCING
binlog_format=ROW
default_storage_engine=InnoDB
innodb_autoinc_lock_mode=2
After launching all of three nodes, after finishing replication please change the first node my.cnf
Comment wsrep_cluster_address=gcomm://
and uncomment #wsrep_cluster_address=gcomm://10.0.0.1,10.0.0.2,10.0.0.3Testing
mysql -e "show status like 'wsrep%'"; # if you see "Synced" everything worked...
If you have issues with performance: https://www.percona.com/forums/questions-discussions/percona-xtradb-cluster/19733-poor-galera-performance
Have a good replication!
Have a good replication!
No comments: