Implementing Read-Write Separation with Atlas and MHA

Atlas is a data access layer solution built on MySQL protocol, developed by the Qihoo 360 Web Platform Department infrastructure team. It enhances the mysql-proxy 0.8.2 foundation with optimizations and additional features. Within Qihoo 360, Atlas manages MySQL workloads handling billions of daily read/write operations.

Key Considerations

  • Atlas requires a 64-bit operating system.
  • CentOS 5.X uses Atlas-XX.el5.x86_64.rpm; CentOS 6.X uses Atlas-XX.el6.x86_64.rpm.
  • Supported backend MySQL versions start from 5.1, with 5.6 or later recommended.

Installation Download the RPM package from the official repository and install it.

yum install -y Atlas*.rpm

Configurasion Navigate to the configuration directory and modify the settings file.

cd /usr/local/mysql-proxy/conf
cp test.cnf test.cnf.bak
vim test.cnf

The configuration file should include the following sections:

[mysql-proxy]
admin-username = admin_user
admin-password = admin_pass
proxy-backend-addresses = 192.168.1.10:3306
proxy-read-only-backend-addresses = 192.168.1.11:3306,192.168.1.12:3306
pwds = replicator:abc123def456=,admin_user:xyz789=
daemon = true
keepalive = true
event-threads = 8
log-level = message
log-path = /var/log/mysql-proxy
sql-log=ON
proxy-address = 0.0.0.0:6033
admin-address = 0.0.0.0:2345
charset=utf8

Starting Atlas Use the provided script to start the Atlas service and verify the process.

/usr/local/mysql-proxy/bin/mysql-proxyd test start
ps aux | grep proxy

Testing Atlas Functionality Connect to Atlas using a MySQL client.

mysql -uadmin_user -padmin_pass -h 192.168.1.10 -P 6033

Test read load balancing across replica nodes.

SELECT @@server_id;

Test write operations directed to the primary backend.

BEGIN;
SELECT @@server_id;
COMMIT;

Configuring Application Users To create a user app_user with specific privileges accessible from a designated subnet:

  1. Create the user on the primary MySQL server.
GRANT SELECT, UPDATE, INSERT ON *.* TO 'app_user'@'192.168.1.%' IDENTIFIED BY 'app_password';
  1. Generate an encrypted password for Atlas configuration.
/usr/local/mysql-proxy/bin/encrypt app_password
  1. Update the Atlas configuraton file with the new user credentials.
vim /usr/local/mysql-proxy/conf/test.cnf
# Add to pwds line: app_user:encrypted_hash=
  1. Restart Atlas and test the connection.
/usr/local/mysql-proxy/bin/mysql-proxyd test restart
mysql -uapp_user -papp_password -h 192.168.1.10 -P 6033

Atlas Administrative Operasions Connect to the administrative interface.

mysql -uadmin_user -padmin_pass -h127.0.0.1 -P2345

View the command help.

SELECT * FROM help;

List all backend server nodes.

SELECT * FROM backends;

Set a backend node offline or online.

SET OFFLINE 2;
SET ONLINE 2;

Dynamically remove or add a replica backend.

REMOVE BACKEND 3;
ADD SLAVE 192.168.1.13:3306;

View configured Atlas user accounts.

SELECT * FROM pwds;

Add a new user account directly via the admin interface.

ADD PWD new_user:plaintext_password;

Persist runtime configuration changes to the configuration file.

SAVE CONFIG;

Tags: MHA Atlas Read-Write Separation MySQL High Availability Database Proxy

Posted on Tue, 19 May 2026 21:36:58 +0000 by whitmard