In this blog we will see how to set-up a ProxySQL for HA
ProxySQL doesn’t natively support any high availability solution it is a single
point of failure. (It means if the proxy server goes down your application is
down)
There are many ways to fix the SPOF issue.
Here we will be using a Keepalived on the proxy servers (we need more than
on proxysql server).
From the Keepalived doc,
- Keepalived is a routing software written in C.
- The main goal of this project is to provide simple and robust facilities for loadbalancing and high-availability to Linux system and Linux based infrastructures.
- Load Balancing framework relies on well-known and widely used Linux Virtual Server (IPVS) kernel module providing Layer4 loadbalancing.
- Keepalived implements a set of checkers to dynamically and adaptively maintain and manage load balanced server pool according their health.
- On the other hand high-availability is achieved by VRRP protocol. VRRP is a fundamental brick for router failover.
- In addition, Keepalived implements a set of hooks to the VRRP finite state machine providing low-level and high-speed protocol interactions.
- In order to offer fastest network failure detection, Keepalived implements BFD protocol.
- VRRP state transition can take into account BFD hint to drive fast state transition.
- Keepalived frameworks can be used independently or all together to provide resilient infrastructures.
Our setup will be as below
Single proxy on 3 node galera can be found on my previous blog here.
Here Keepalived will make sure one proxysql will be routing your queries to the
PXC , if active node goes down, the passive node will be promoted as active
and application will be connecting to your database via that proxy. It is achieved
by assigning the VIP on that particular proxy node.
Below is the process to setup a Keepalived
We will make Proxy Active as Master and Proxy Passive as Backup ie, if proxy is
down on active the Proxy on Passive which is backup act as Master.
Here rather than percona proxy i am using native proxy 2.0.5 which supports
Install Keepalived on both proxy servers
Install Keepalived
Setup the Keepalived configuration file
vi /etc/keepalived/keepalived.conf
Config file for master node
Config file for backup node
We need to start the Keepalived on active node at first and the
keepalived will set the state to Master and you can see the connections towards the PXC nodes.
On proxy active node you can see the VIP assigned
ip addr show eth0
Testing the failover
To test the same, i will stop the proxy service on active node
On checking the status of keepalived on passive node
You can see the floating IP been assigned to the passive node and it transfer its state from backup to master.
No comments:
Post a Comment