mariadbwebinardr07301000156458558219.pdf

Eduardo154255 0 views 32 slides Oct 16, 2025
Slide 1
Slide 1 of 32
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9
Slide 10
10
Slide 11
11
Slide 12
12
Slide 13
13
Slide 14
14
Slide 15
15
Slide 16
16
Slide 17
17
Slide 18
18
Slide 19
19
Slide 20
20
Slide 21
21
Slide 22
22
Slide 23
23
Slide 24
24
Slide 25
25
Slide 26
26
Slide 27
27
Slide 28
28
Slide 29
29
Slide 30
30
Slide 31
31
Slide 32
32

About This Presentation

MariaDB disaster recovery


Slide Content

Best practices:
Disaster recovery with
MariaDB Platform
Shane K Johnson, Senior Director of Product Marketing, MariaDB Corporation

Agenda
●Introduction
●Disaster recovery options
○Point-in-time restore
○Point-in-time rollback
○Delayed replication
○System-versioned tables
○Multiple data centers
●Reference architectures

The cost of downtime
●Small companies: $8,000/hour
●Mid-size organizations: $74,000/hour
●Large enterprises: $700,000/hour
●Amazon (2018 Prime Day): $72-99 million, 75 minute outage
●eCommerce:
○walmart.com: $2.4M/hour
○homedepot.com: $858K/hour
○bestbuy.com: $698K/hour
○costco.com: $696K/hour
○macys.com: $664K/hour

Goals
●Recovery time objective (RTO)
○Limit on duration of downtime, shorter is better
○How long should it take to restore the database
●Recovery point objective (RPO)
○Limit on amount of data lost, small is better
○How much data will be lost after the recovery

Methods
●Backups
○As frequent as possible, without interrupting applications
○Stored on tape (yesterday), stored on cloud storage (today)
●Replication
○Maintain a duplicate system off-site (multiple data centers, hybrid cloud)
●Preventative
○High availability
○Hardware – surge protectors, UPS, etc.
○Software – antivirus and firewall

Types of disasters
●Power outage
●Fire
●Network damage
Total failure
●Malicious attack/accident
●Deleted data
●Modified data
●Storage failure
Data loss/corruption

Big outages last year
●Amazon Prime Day (due to Aurora Postgres)
●Google Cloud (due to Google Cloud Datastore)
●Equinix (due to storm)
●Amazon Alexa (due to storm)
●Iomart (due to farmer, yep, he cut the fiber cable)
●Microsoft Office 365 (due to software update)
●AWS RDS (due to hardware/network failure in North Virginia region)
●Microsoft Azure (due to extreme heat in Ireland data center)

MariaDB Platform
disaster recovery options

Point-in-time restore
●Restore data to a previous point in time (offline process)
a.Empty the database or install a new database
b.Restore data from a backup
c.Start the database
d.Replay transactions since the last backup

Best practice: create a backup user
CREATE USER 'mariabackup'@'localhost'
IDENTIFIED BY 'mbu_passwd';

GRANT RELOAD, PROCESS, LOCK TABLES, REPLICATION CLIENT
ON *.* TO 'mariabackup'@'localhost';

Point-in-time restore: tools
●MariaDB Enterprise Backup (backup and restore data)
a.Backup compressed and/or encrypted tables
b.Create compressed and/or encrypted backups (of standard tables)
c.Take full, incremental and partial backups
d.Perform backups on local or remote databases
e.Can use encrypted database connections (TLS)
●mariadb-binlog (replay transactions)

MariaDB Enterprise Backup
1.Backup
a.# mariabackup --backup --target-dir=/data/backups/full
b.# mariabackup --backup --incremental-basedir=/data/backups/full --target-dir=/data/backups/inc1
c.# mariabackup --backup --incremental-basedir=/data/backups/full --target-dir=/data/backups/inc2
2.Prepare
a.# mariabackup --prepare --target-dir=/data/backups/full
b.# mariabackup --prepare --target-dir=/data/backups/full --incremental-dir=/data/backups/inc2
3.Restore
a.# mariabackup --copy-back --target-dir=/data/backups/full
b.# chown -R mysql:mysql /var/lib/mysql
# mariabackup --backup --target-dir=/data/backups/full --user=mariabackup --password=mbu_passwd

mariadb-binlog
1.Prepare the backup, and find the backups binlog position
a.# cat /data/backups/full/xtraback_binlog_info
mariadb-node4.00001 321
2.Update the configuration to use a new data dictionary
a.[mysqld]
datadir=/var/lib/mysql_new
3.Restore the backup, and start the database
4.Replay transactions since the backup
a.$ mariadb-binlog --start-position=321 --stop-datetime="2019-07-30 7:00:00" \
/var/lib/mysql/mariadb-node4.00001 > mariadb-binlog.sql
b.$ mariadb -u root -p < mariadb-binlog.sql

Best practices: options
●Prepare the backup after every incremental backup
○Rather than preparing the backup with multiple incremental backups
○Faster restore, but fewer recovery points or more storage used
●Enable parallel data transfer (--parallel=n)
○Helpful is using InnoDB file per table, or
○The InnoDB system tablespace is configured with multiple files

MariaDB Enterprise Backup
1.Backup
a.# mariabackup --backup --target-dir=/data/backups/full
b.# mariabackup --prepare --target-dir=/data/backups/full
c.# mariabackup --backup --incremental-basedir=/data/backups/full --target-dir=/data/backups/inc1
d.# mariabackup --prepare --target-dir=/data/backups/full --incremental-dir=/data/backups/inc1
e.# mariabackup --backup --incremental-basedir=/data/backups/inc1 --target-dir=/data/backups/inc2
f.# mariabackup --prepare --target-dir=/data/backups/full --incremental-dir=/data/backups/inc2
2.Restore
a.# mariabackup --copy-back --target-dir=/data/backups/full
b.# chown -R mysql:mysql /var/lib/mysql
# mariabackup --backup --target-dir=/data/backups/full --user=mariabackup --password=mbu_passwd

Point-in-time rollback
●Rewind the database to a previous point in time (online process)
a.Inverts recent transactions
■INSERT -> DELETE
■DELETE -> INSERT
■UPDATE BEFORE -> UPDATE AFTER

Point-in-time rollback: tools
●MariaDB Flashback
○Uses the binary log
■mariadb --log-in[=name]
■binlog_format=ROW
■binlog_row_image=FULL
■Alternatively, mariadb --flashback
●Create a script
○# mariadb-binlog /var/lib/mysql/mariadb-bin.000001 -d mydatabase -T mytable \
--start-datetime="2019-07-30 7:05:00" --flashback > flashback.sql
●Execute the script
○# mariadb < flashback.sql

System-versioned tables
●System-versioned tables are great for auditing, but
●They are great for disaster recovery as well...
○MariaDB preserves historical changes to a row
■UPDATEs -> INSERTs
○Rows are never deleted
■DELETEs -> UPDATEs
●DBAs can restore rows to a previous point in time

Example
CREATE TABLE tbl_customers(
id INT,
name VARCHAR(10),
status VARCHAR(10))
WITH SYSTEM VERSIONING ;

ALTER TABLE tbl_customers ADD SYSTEM VERSIONING ;

id name status
1 Shane Silver

id name status
1 Shane Gold
1 Shane Silver
// JANUARY 1, 2018
UPDATE TBL_CUSTOMERS SET status = 'Gold'
WHERE id = 1;

id name status
1 Shane Platinum
1 Shane Gold
1 Shane Silver
// JANUARY 1, 2019
UPDATE TBL_CUSTOMERS SET status = 'Platinum'
WHERE id = 1;

id name status
1 Shane Bronze
1 Shane Platinum
1 Shane Gold
1 Shane Silver
// JULY 29, 2019
UPDATE TBL_CUSTOMERS SET status = 'BRONZE'
WHERE id = 1;

// JULY 30, 2019
SELECT id, name, status, row_start, row_end
FROM TBL_CUSTOMERS
FOR SYSTEM_TIME ALL WHERE id=1;


id name status row_start row_end
1 Shane Bronze 2019-07-29 2038-01-19
1 Shane Platinum 2019-01-01 2019-07-28
1 Shane Gold 2018-01-01 2018-12-31
1 Shane Silver 2017-08-12 2017-12-31

id name status
1 Shane Platinum
// JULY 30, 2019
SELECT * FROM TBL_CUSTOMERS
FOR SYSTEM_TIME AS OF '2019-07-28'
WHERE id = 1;

Delayed replication
●Ensure data loss is not propagated to replicas
○Can use multiple replicas with different delays
■15 minutes: an issue is detected right away
■1 hour: maybe it takes a little longer to identify the issue
■1 day: someone missed the issue, but found it later
○Perform backups on delayed replicas to prevent data loss from reaching backups
●Set the delay on the replica (in seconds)
○CHANGE MASTER TO MASTER_DELAY=900; // 15 minutes

Multiple data centers
●Maintain a disaster recovery site
●Deploy MariaDB Platform in multiple data centers
○Multi-cloud or hybrid-cloud
○Asynchronous or synchronous replication

Reference
architectures

MariaDB
Server (P)
MariaDB
Server (R1)
MariaDB
Server (R2)
MariaDB
MaxScale
Writes Reads
MariaDB
Enterprise Backup
Delayed replication and
system-versioned tables

MariaDB
Server (P)
MariaDB
Server (R1)
MariaDB
Server (R2)
MariaDB
MaxScale
Writes Reads
MariaDB
Enterprise Backup
MariaDB
Server (R3)
MariaDB
Server (R4)
Delayed
replication
System
versioned
tables

MariaDB
Server (M)
MariaDB
Server (M)
MariaDB
Server (M)
MariaDB MaxScale
Reads Writes
MariaDB Enterprise Backup
Binlog server
MariaDB
Server
(versioning)
MariaDB
Server (1h)
(versioning)
MariaDB
Server (1d)
(versioning)
MariaDB
Server (1w)
(versioning)
MariaDB
Server (P)
MariaDB
Server (R)
MariaDB MaxScale
Writes Reads
Binlog server

Thank you
Questions?
Tags