Setting Up MariaDB MaxScale Binlog Proxy
MariaDB MaxScale Binlog Server is a replication proxy that acts as an intermediate master, storing binary logs and allowing replicas to fetch them. It enables scalable replication and fast recovery.
Step 1: Install MariaDB MaxScale
On Ubuntu/Debian:
sudo apt-get update
sudo apt-get install maxscale
On RHEL/CentOS:
sudo yum install maxscale
Verify Installation:
maxscale --version
Step 2: Configure MaxScale as a Binlog Proxy
Edit MaxScale's configuration file:
sudo nano /etc/maxscale.cnf
Add the following binlog replication settings:
[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
binlogrouter
acts as the binlog proxy.binlogdir
stores the binlog files.
Save and exit (Ctrl+X
, Y
, Enter
).
Step 3: Set Up Users on the Primary Database
Log in to your MariaDB primary database:
mysql -u root -p
mysql -u root -p
Create a replication user for MaxScale:
CREATE USER 'maxscale'@'%' IDENTIFIED BY 'maxpass';
GRANT REPLICATION SLAVE, REPLICATION CLIENT ON *.* TO 'maxscale'@'%';
FLUSH PRIVILEGES;
Step 4: Start and Enable MaxScale
sudo systemctl enable maxscale
sudo systemctl start maxscale
sudo systemctl status maxscale
sudo systemctl start maxscale
sudo systemctl status maxscale
Step 5: Configure Replica Servers to Use MaxScale
On each replica database, configure replication to fetch binlogs from MaxScale instead of the primary DB:
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 replication status:
SHOW SLAVE STATUS\G;
Conclusion
MariaDB MaxScale Binlog Proxy helps in:
Scalable replication without overloading the primary database.
Fast disaster recovery using binlog caching.
Automatic failover with minimal downtime.
No comments:
Post a Comment