Our current setup is a standalone MySQL 8.0.22
server (I know, it’s bad) and we’d like to migrate to a PXC Cluster as the application grew quite a lot.
My main issue is that I’m trying to set-up replication between our existing instance and one of the nodes in the cluster but the nodes fail with: “WSREP has not yet prepared node for application use”
Here are the steps that I took:
- Dump the database that we want to replicate:
mysqldump -h standalone -uroot -P 3306 --password \ --skip-lock-tables \ --skip-add-locks \ --single-transaction \ --flush-logs \ --master-data=2 \ somedatabase
- Import the database on PXC-3
- Change master on PXC-3 using the
MASTER_LOG_FILE
andMASTER_LOG_POS
from the dump:CHANGE MASTER TO MASTER_HOST="192.168.0.100", MASTER_USER="replication_user", MASTER_PASSWORD="*******", MASTER_LOG_FILE='binlog.000004', MASTER_LOG_POS=196;
- Start replication
After starting the replication the PXC-3 node picked-up the data however the other nodes started failing with “WSREP has not yet prepared node for application use”. After restarting them and they came back up successfully with all the data from PXC-3 replicated.
To test the replication I’ve inserted a new row in the standalone instance and went to check on PXC-3 to see if it replicated however it too started failing with “WSREP has not yet prepared node for application use”
So I’m clearly doing something wrong here, maybe I misconfigured something?
Here are the configs:
Existing (8.0.22
) instance:
[mysqld]
default_authentication_plugin=mysql_native_password
;skip-log-bin
max_connections=1024
innodb_buffer_pool_size=1G
sort_buffer_size=256000000
server-id=4
gtid_mode=ON
enforce-gtid-consistency=ON
log-bin=binlog
binlog-format=row
binlog-do-db=somedatabase
PXC-node-3 (8.0.34-26.1
)
[mysqld]
server-id=3
datadir=/var/lib/mysql
socket=/var/run/mysqld/mysqld.sock
log-error=/var/log/mysql/error.log
log_error_verbosity=2
pid-file=/var/run/mysqld/mysqld.pid
# Binary log expiration period is 604800 seconds, which equals 7 days
binlog_expire_logs_seconds=604800
######## wsrep ###############
# Path to Galera library
wsrep_provider=/usr/lib/galera4/libgalera_smm.so
# Cluster connection URL contains IPs of nodes
#If no IP is found, this implies that a new cluster needs to be created,
#in order to do that you need to bootstrap this node
wsrep_cluster_address=gcomm://192.168.122.100,192.168.122.101,192.168.122.102
# In order for Galera to work correctly binlog format should be ROW
binlog_format=ROW
# Slave thread to use
wsrep_slave_threads=8
wsrep_log_conflicts
# This changes how InnoDB autoincrement locks are managed and is a requirement for Galera
innodb_autoinc_lock_mode=2
# Node IP address
wsrep_node_address=192.168.122.102
# Cluster name
wsrep_cluster_name=pxc-cluster
#If wsrep_node_name is not specified, then system hostname will be used
wsrep_node_name=pxc-cluster-node-3
#pxc_strict_mode allowed values: DISABLED,PERMISSIVE,ENFORCING,MASTER
pxc_strict_mode=ENFORCING
pxc_encrypt_cluster_traffic=off
# SST method
wsrep_sst_method=xtrabackup-v2
# Tuning
max_connections=1024
innodb_buffer_pool_size=2G
sort_buffer_size=256M
# Temporary replication
gtid_mode=ON
enforce-gtid-consistency=ON
log-replica-updates=ON
skip-replica-start=ON
Here’s an overview of I’m trying to achieve in this first phase of the migration: