You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
What follows is somewhat specific to my needs at the time. I'll try to make it as generic as possible so it can be easier to adapt to other situations. I'll start out with VMs on our vSphere system. Then I'll go back and add in whatever extra steps I might have needed to change when doing this within OpenStack.
Steps taken when initially testing database replication.
Cloned prod-redcap-database VM in vSphere.
Disable any cron jobs that might be running.
for user in $(cut -f1 -d: /etc/passwd); do echo $user; crontab -u $user -l; done
mv /var/spool/cron /var/spool/cron_is_disabled
Started up clone VM without networking so I can change IPs and make firewall changes without affecting production.
Assigned new IP address
Cloned prod-redcap-app VM in vSphere. So I could have a web frontend to use.
Modified networking and firewall rules as before to reference new IPs.
Assigned new IP address
Changed prod-redcap-database-clone database to allow prod-redcap-app-clone to access REDCap files and update itself.
[root@prod-redcap-database-clone ~] → MariaDB-10.6.19 > RENAME USER 'appsdomu_user'@'<Old IP Address>' TO 'appsdomu_user'@'<New IP Address>';
[root@prod-redcap-database-clone ~] → MariaDB-10.6.19 > RENAME USER 'rcprod_updater'@'<Old IP Address>' TO 'rcprod_updater'@'<New IP Address>';
[root@prod-redcap-database-clone ~] → MariaDB-10.6.19 > FLUSH PRIVILEGES;
Decided to use mariadb-backup (fork of Percona XtraBackup) instead of mysqldump.
Test took about 30 minutes. Much faster and easier.
Backs up everything in the database.
Created backup user in prod-redcap-database-clone
[root@prod-redcap-database-clone ~] → MariaDB-10.6.19 > CREATE USER 'backupuser'@'localhost' IDENTIFIED BY '<Password>';
[root@prod-redcap-database-clone ~] → MariaDB-10.6.19 > GRANT RELOAD, PROCESS, LOCK TABLES, BINLOG MONITOR ON *.* TO 'backupuser'@'localhost';
[root@prod-redcap-database-clone ~] → MariaDB-10.6.19 > FLUSH PRIVILEGES;
Made backup of prod-redcap-database-clone mariadb database.
Early on during the database unicode upgrade transition, I ran into the following error during replication:
Last_SQL_Error: Column 4 of table 'redcap_alerts_sent_log' cannot be converted from type 'varchar(573 octets)' to type 'varchar(764 octets) character set utf8mb4'
This fix in this case was to enable slave_type_conversions in MariaDB.
REDCap Database Migration and Replication
Helpful links:
Note
What follows is somewhat specific to my needs at the time. I'll try to make it as generic as possible so it can be easier to adapt to other situations. I'll start out with VMs on our vSphere system. Then I'll go back and add in whatever extra steps I might have needed to change when doing this within OpenStack.
Steps taken when initially testing database replication.
prod-redcap-databaseVM in vSphere.for user in $(cut -f1 -d: /etc/passwd); do echo $user; crontab -u $user -l; donemv /var/spool/cron /var/spool/cron_is_disabledprod-redcap-appVM in vSphere. So I could have a web frontend to use.prod-redcap-database-cloneprod-redcap-database-clonemariadb database.replica-server-vm.prod-redcap-database-clonetoreplica-server-vm.replica-server-vm, so I added another volume.prod-redcap-database-clone.replica-server-vm.replica-server-vm.mariadb-backup --copy-back --force-non-empty-directories --parallel=#prod-redcap-database-clone(or primary).prod-redcap-database-cloneto generate certs for mariadb TLS. Replication requires it.prod-redcap-database-cloneto use the certs.prod-redcap-database-clone.[root@prod-redcap-database-clone ~] vi /etc/my.cnfxtrabackup_binlog_infofile.mariadb_backup_binlog_infoExamples:
my.cnfon replica database to set a differentserver_idfrom the primary database.[root@prod-redcap-database-clone ~] vim /usr/local/etc/mysql/my.cnfNote
Early on during the database unicode upgrade transition, I ran into the following error during replication:
Last_SQL_Error: Column 4 of table 'redcap_alerts_sent_log' cannot be converted from type 'varchar(573 octets)' to type 'varchar(764 octets) character set utf8mb4'
This fix in this case was to enable
slave_type_conversionsin MariaDB.MariaDB Help Link: "Replication When the Primary and Replica Have Different Table Definitions"
You can check the replica status (
\Gto make it easier to read):