How do you achieve high availability using MySQL? Master/slave replication has always been the goto strategy, but it is far from a complete solution. In this presentation, we will leverage tools like ProxySQL, Github’s Orchestrator project, and Consul to provide a single endpoint on top of master/slave replica sets that are automatically monitored, where automatic promotion of slaves happens in case of a dead master, where slave servers benefit from autofailover, and where read/write query splitting is abstracted.
34. CREATE DATABASE IF NOT EXISTS orchestrator;
CREATE USER 'orchestrator'@'127.0.0.1' IDENTIFIED
BY 'orch_backend_password';
GRANT ALL PRIVILEGES ON `orchestrator`.* TO
'orchestrator'@'127.0.0.1';
Orchestrator DB
36. CREATE USER 'orchestrator'@'orch_host' IDENTIFIED BY
'orch_topology_password';
GRANT SUPER, PROCESS, REPLICATION SLAVE, RELOAD ON *.* TO
'orchestrator'@'orch_host';
GRANT SELECT ON mysql.slave_master_info TO
'orchestrator'@'orch_host';
On all DB nodes
76. UPDATE global_variables SET variable_value = 'proxysql_check'
WHERE variable_name='mysql-monitor_username';
UPDATE global_variables SET variable_value = 'password'
WHERE variable_name='mysql-monitor_password';
UPDATE global_variables SET variable_value =
'admin:password;remote:password'
WHERE variable_name='admin-admin_credentials';
UPDATE global_variables SET variable_value = 'haproxy_check:'
WHERE variable_name='admin-stats_credentials';
Set variables
81. LOAD ADMIN VARIABLES TO RUNTIME;
SAVE ADMIN VARIABLES TO DISK;
LOAD MYSQL VARIABLES TO RUNTIME;
SAVE MYSQL VARIABLES TO DISK;
LOAD MYSQL SERVERS TO RUNTIME;
SAVE MYSQL SERVERS TO DISK;
LOAD MYSQL USERS TO RUNTIME;
SAVE MYSQL USERS TO DISK;
LOAD MYSQL QUERY RULES TO RUNTIME;
SAVE MYSQL QUERY RULES TO DISK;
Load config
83. How do you synchronise
ProxySQL & Orchestrator?
84. ✓Fetch master from Consul agent
✓Use Consul template
✓Parse master IP into ProxySQL config file
✓Remove ProxySQL DB file
✓Reload ProxySQL
ProxySQL & Orchestrator sync