High-level architecture of a complete MariaDB deployment
FedericoRazzoli
80 views
41 slides
May 15, 2024
Slide 1 of 41
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
About This Presentation
In this webinar Federico will illustrate how to design a complete MariaDB setup. This doesn't only include MariaDB, but all the components that are necessary to form a reliable, scalable architecture.
Federico will cover these points:
- MariaDB storage engines
- Asynchronous replication vs Gal...
In this webinar Federico will illustrate how to design a complete MariaDB setup. This doesn't only include MariaDB, but all the components that are necessary to form a reliable, scalable architecture.
Federico will cover these points:
- MariaDB storage engines
- Asynchronous replication vs Galera
- Load balancing and failover: ProxySQL, MaxScale, HAProxy
- Eliminating SPoFs in the proxy level
- Backup strategies
- Monitoring solutions
Size: 654.89 KB
Language: en
Added: May 15, 2024
Slides: 41 pages
Slide Content
High-level architecture
of a complete MariaDB setup
●Writes on the master (events) are logged into the binary log
●The binary log is read and sent to the replicas
●The replicas receive it and write the relay log
●The relay log events are applies to the data
○In parallel
●Replicas can be used to scale reads, but the lag should be
monitored
●GTID allows master failover is possible
High Availability & Scalability
Delayed replication:
●Asynchronous replication can be configured to be delayed
●Eg: 1 hour, 1 day
●If an SQL statements destroys data on the master, you can use the
delayed replica to recover data
High Availability & Scalability
Semi-sync replication:
●Similar to asynchronous replication
●But when a client makes a change to the data:
○The master waits until at least 1 replica has logged the event
into the binary log
○Then it returns success to the client
●This means that semisync replication makes writes slower
●And if all replicas crash, the master won't accept data writes
High Availability & Scalability
Galera is virtually synchronous replication
●Each transaction needs be certified by the majority of nodes before
it is applied to any node
●Number of nodes should be odd
●Data conflicts lead to failed transactions and potentially node
eviction
●Don't use multiple masters
●Large transactions should be avoided
●AUTO_INCREMENT id's are not necessarily in chronological order
●A node slowdown slows down the cluster
High Availability & Scalability
●Galera nodes can have replicas to scale reads without affecting
writes
●A Galera node can be the master of a node of another cluster
●In this way you can have a secondary cluster
High Availability & Scalability
Proxy layer
Proxies are needed to:
●Only send queries to working servers
●Only send writes to the master(s), send reads to replicas
●Distribute the reads more or less equally amongst replicas
Proxy layer
Why not doing this in the application?
●DBAs would need to update app configuration when the list of
servers changes
●Proxies are complex pieces of software, they know their stuff
●They also have advanced features that the application can't have,
like connections multiplexing
Proxy layer
Main existing proxies:
●ProxySQL
●MaxScale
●HAProxy
Proxy layer
●Proxies can form an independent layer
●Or each app server can run a different proxy
●…or both
●In all cases, proxies can crash. Make sure you have multiple
proxies
Proxy layer
Service discovery
●Proxies send queries to running MariaDB instances
●But proxies can fail too, like any other technology
●Application should only connect to running proxies
Service discovery
Solutions:
●Hashicorp Consul
●Kubernetes
●Cloud vendor-specific solutions
Service discovery
Backups
You need to backup:
●Configuration
●Data
If you use gitops configuration can always be recreated
We'll focus on data
Snapshots are not copies, they are taken instantaneously
They can be incremental
Backups
Mariabackup:
●Takes a copy of the files
●(Almost) no locks are taken
●Uses InnoDB transaction logs to bring the data to a consistent state
○Ie: undo transactions committed after the copy started
Backups
mariadb-dump:
●Writes all the SQL statement needed to recreate the database
●Slowest backup method, slowest recovery method
●Historically single-threaded
●Uses a long transaction
●But backups can be restored on any MariaDB version
Backups
Binary log:
●Contains events: binary changes to the rows, or SQL statements
and GTIDs
Can be analysed by a human with mariadb-binlog
●It should be periodically be copied to elsewhere
●When you restore a complete backup, check the latest GTID
●Then apply the binlog starting from the next GTID