Mariadb
Mariadb / Mysql related scripts and explanationsRunning a plain mariadb server on Gentoo.
Getting a mariadb server up and running unfortunately is not achieved by just running the start script.
about Mariadb #
Mariadb is considered an open source free license drop-in for MySQL. However, although they are maintained by the same company, there are differences. SQL and API are the same, but not the inner workings. The biggest difference is the query optimizer, the part that derives the operation plan. Here, MySQL outperforms Mariadb.
Mariadb, Galera, MaxScale #
A DB server is vulnerable to a failure of the server, of the storage system, etc. This can be avoided by redundancy, which means several servers and some sort of replication. Galera is quorum/consense based and organizes the replication of data (much simplified). MaxScale on top is a proxy that controls fail-safe access.
The minimal configuration should be 3 Mariadb servers in a Galera-cluster with 2 MaxScale proxies. If the database clients can only connect to one SQL-server at a time, then a keepalived failover should be added. In case of a failure, the current SQL connection gets aborted with the lost of the session.
Galera startup #
Galera reconfigures itself during normal operation, when Mariadb servers unexpectedly drop out. To start up the Galera-cluster, the first server to start needs to be the previous master. This requires a corrdinated start.
Keepalived #
Keepalived adds a second ip-address to the interfaces. The daemons exchange heartbeats and in case of absence take over the ip-address of the failing peer.
Initial setup #
The start scripts currently do no include the setup of a fresh database server, even though the default configuration is good enough.
The script mysql-install-db
usually was called to create the data directory, set up default permissions and users and also installs a “test” database.
for Gentoo users #
Gentoo provides the option to use emerge --config =dev-db/mariadb-10.6.17
. Is is an interactive tool.
This prepares everything and also temporarily starts the database server.
After that one can start the server with /etc/init.d/mysql start
.