Skip to content

Instantly share code, notes, and snippets.

@chrispage1
Last active September 30, 2020 15:31
Show Gist options
  • Save chrispage1/5b2275a080a339aa26bb2d741cb0133e to your computer and use it in GitHub Desktop.
Save chrispage1/5b2275a080a339aa26bb2d741cb0133e to your computer and use it in GitHub Desktop.
Corosync pacemaker maxscale configuration

Setting up MariaDB Cluster

Original cluster setup from https://github.com/mariadb-faisalsaeed/documentation

See issue comment: faizalrf/documentation#1 (comment)

Setting up MaxScale

Below is a basic guide to creating HA Maxscale (>= 2.5) using a pre-configured pacemaker configuration

Install maxscale:

wget https://dlm.mariadb.com/1159597/MaxScale/2.5.4/maxscale-2.5.4-release/packages/ubuntu/focal/maxscale-2.5.4-1.ubuntu.focal.x86_64.deb
dpkg -i maxscale-2.5.4-1.ubuntu.focal.x86_64.deb

create our maxscale floating IP

pcs resource create maxscale_ip ocf:heartbeat:IPaddr2 ip=192.168.1.88 cidr_netmask=24 op monitor interval=30s

prevent resources from instantly moving to a recovered node

pcs resource defaults resource-stickiness=100

start monitoring our maxscale service

pcs resource create maxscale_service systemd:maxscale op monitor interval="10s" timeout="15s" op start interval="0" timeout="15s" op stop interval="0" timeout="3

stop and disable maxscale on ALL nodes

systemctl stop maxscale
systemctl disable maxscale

create a co-location constraint so the Maxscale IP & Service are always together

pcs constraint colocation add maxscale_service with maxscale_ip INFINITY

define the order in which the services should transition

sudo pcs constraint order set maxscale_ip maxscale_service

add the items into a resource group

pcs resource group add maxscale maxscale_ip
pcs resource group add maxscale maxscale_service
[maxscale]
threads=auto
# configure the REST API
admin_host=192.168.1.88
admin_auth=1
admin_enabled=1
admin_port=8989
[mariadb-90]
type=server
address=192.168.1.90
port=3307
protocol=MariaDBBackend
[mariadb-91]
type=server
address=192.168.1.91
port=3307
protocol=MariaDBBackend
[mariadb-92]
type=server
address=192.168.1.92
port=3307
protocol=MariaDBBackend
[MariaDB-Monitor]
type=monitor
module=mariadbmon
servers=mariadb-90, mariadb-91, mariadb-92
user=maxscale_monitor
password=
failcount=3
monitor_interval=1500
# maxmonitor actually performs failover etc.
verify_master_failure=true
enforce_read_only_slaves=true
# detect_replication_lag=true
auto_failover=true
auto_rejoin=true
[Read-Write-Service]
type=service
router=readwritesplit
servers=mariadb-90, mariadb-91, mariadb-92
user=maxscale_user
password=
master_reconnection=true
master_failure_mode=error_on_write
transaction_replay=true
master_accept_reads=true
slave_selection_criteria=ADAPTIVE_ROUTING
[Read-Write-Listener]
type=listener
service=Read-Write-Service
protocol=MariaDBClient
address=192.168.1.88
port=3306
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment