Skip to main content

Setting Up MariaDB MaxScale Binlog Proxy for backup/failover


 


Setting Up MariaDB MaxScale Binlog Proxy

MariaDB MaxScale Binlog Server acts as an intermediate master replication proxy. By storing binary logs and serving them to replicas, it enables scalable replication architectures, reduces primary database load, and accelerates disaster recovery.

Step 1: Install MariaDB MaxScale

Install MaxScale using the package manager appropriate for your Linux distribution, then verify the installation.

On Ubuntu/Debian:

sudo apt-get update
sudo apt-get install maxscale

On RHEL/CentOS:

sudo yum install maxscale

Verify the installation:

maxscale --version

Step 2: Configure MaxScale as a Binlog Proxy

Open MaxScale's core configuration file to establish the routing properties and specify your database backend configuration.

sudo nano /etc/maxscale.cnf

Add the following configurations for the monitor block and the binlog router service:

[maxscale]
threads=4

[Replication-Monitor]
type=monitor
module=mariadbmon
servers=primary-db,replica-db1,replica-db2
user=maxscale
password=maxpass
monitor_interval=10000
auto_failover=true

[Binlog-Server]
type=service
router=binlogrouter
servers=primary-db
user=maxscale
password=maxpass
filestem=binlog
binlogdir=/var/lib/maxscale/binlogs
gtid_strict_mode=on

Key parameters defined above:

  • router=binlogrouter: Directs MaxScale to act explicitly as a binlog proxy proxying system.
  • binlogdir: The dedicated storage directory where MaxScale caches binary logs locally.

Step 3: Set Up Users on the Primary Database

Access the primary database instance to provision administrative credentials and replication authority to MaxScale.

mysql -u root -p

Execute the following queries to create the proxy user account and apply capabilities:

CREATE USER 'maxscale'@'%' IDENTIFIED BY 'maxpass';
GRANT REPLICATION SLAVE, REPLICATION CLIENT ON *.* TO 'maxscale'@'%';
FLUSH PRIVILEGES;

Step 4: Start and Enable MaxScale

Register MaxScale with the system init daemon to start automatically upon booting, then initiate the runtime service process.

sudo systemctl enable maxscale
sudo systemctl start maxscale
sudo systemctl status maxscale

Step 5: Configure Replica Servers to Use MaxScale

Log into each of your target replica database nodes. Point their data-fetching routes directly to your MaxScale proxy instance instead of targeting the primary database node infrastructure directly.

CHANGE MASTER TO
    MASTER_HOST='maxscale-server-ip',
    MASTER_PORT=3306,
    MASTER_USER='maxscale',
    MASTER_PASSWORD='maxpass',
    MASTER_LOG_FILE='binlog.000001',
    MASTER_LOG_POS=4;

START SLAVE;

Verify that your data stream pipeline status reflects normal active operation:

SHOW SLAVE STATUS\G;
Conclusion: Implementing the MariaDB MaxScale Binlog Proxy architecture successfully insulates your primary production database against high-volume read replica scaling loads, provides a robust localized binlog caching layer for fast disaster recovery, and automates high-availability database cluster failovers.

Comments

Popular posts from this blog

Setup a Multi-Protocol VPN Server Using SoftEther on Centos7

  Introduction This article explains how to install and configure a multi-protocol VPN server using the SoftEther package. We enable and configure OpenVPN and L2TP over IPSec and SSTP VPN Servers on Linux. What is SoftEther SoftEther VPN is one of the world’s most powerful and easy-to-use multi-protocol VPN software, made by the good folks at the University of Tsukuba, Japan. It runs on Windows, Linux, Mac, FreeBSD and Solaris and is freeware and open-source. You can use SoftEther for any personal or commercial use free of charge. Step 1: Create a Virtual Server First, you need to create a DigitalOcean Droplet. As mentioned in SoftEther’s website, SoftEther will work on almost every Linux distro with kernel v2.4 or above,; however it’s recommended to choose one of these distributions: CentOS, Fedora, or Red Hat Enterprise Linux. Personally I have tried it on Ubuntu, CentOS and Fedora, both 32 and 64 bit editions, and it has worked perfectly. Step 2: Update your Server Software Usin...

Deploying a laravel app using nginx alias

  server { listen 80; server_name subdomian.example.com; root /var/www/mainapp/; add_header X-Frame-Options "SAMEORIGIN"; add_header X-XSS-Protection "1; mode=block"; add_header X-Content-Type-Options "nosniff"; index index.html index.htm index.php; charset utf-8; error_log /var/log/nginx/error.log warn; location / { try_files $uri $uri/ /index.php?$query_string; } location = /favicon.ico { access_log off; log_not_found off; } location = /robots.txt { access_log off; log_not_found off; } error_page 404 /index.php; location ~ \.php$ { fastcgi_pass unix:/var/run/php/php8.1-fpm.sock; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name; include fastcgi_params; } location /laravelapp { alias /var/www/mainapp/laravelapp/public; index index.php index.html in...