Skip to content

Instantly share code, notes, and snippets.

@scottames
Last active August 5, 2020 12:02
Show Gist options
  • Save scottames/5f55768da642483f5928 to your computer and use it in GitHub Desktop.
Save scottames/5f55768da642483f5928 to your computer and use it in GitHub Desktop.
MaxScale & Pacemaker on CentOS 7

MaxScale & Pacemaker on CentOS 7

Install packages on both nodes

sudo yum install corosync pcs pacemaker maxscale

Set the password for the hacluster user [both nodes]

sudo passwd hacluster

Start the pcs daemon service [both nodes]

sudo systemctl start pcsd

Authenticate the cluster

sudo pcs cluster auth node01.domain.local node02.domain.local

Create cluster

sudo pcs cluster setup --name clustername node01.domain.local node02.domain.local
  • Example output

    Shutting down pacemaker/corosync services...
    Redirecting to /bin/systemctl stop  pacemaker.service
    Redirecting to /bin/systemctl stop  corosync.service
    Killing any remaining services...
    Removing all cluster configuration files...
    node01.domain.local: Succeeded
    node02.domain.local: Succeeded
  • Check the changes in: nano /etc/corosync/corosync.conf

Start the cluster

sudo pcs cluster start --all

Check the cluster status

sudo pcs status cluster
sudo pcs status nodes
sudo corosync-cmapctl | grep members
sudo pcs status corosync
sudo crm_verify -L -V

Set quorum settings

sudo pcs property set stonith-enabled=false
sudo pcs property set no-quorum-policy=ignore
  • Verify the properties with: sudo pcs property

Create a virtual IP resource called virtual_ip

sudo pcs resource create virtual_ip ocf:heartbeat:IPaddr2 \
 ip=10.10.10.123 cidr_netmask=24 \
 op monitor interval=30s

Check the resource status

sudo pcs status resources

Prevent Resources from Moving after Recovery

sudo pcs resource defaults resource-stickiness=100
  • Confirm the resource defaults with sudo pcs resource defaults

Create maxscale service resource called maxscale_service

  • Note: for maxscale 1.1.1 and older change systemd to lsb in the command below as the startup scripts are invoked via systemd in version 1.2 and newer.
sudo pcs resource create maxscale_service systemd:maxscale \
  op monitor interval="10s" timeout="15s" \
  op start interval="0" timeout="15s" \
  op stop interval="0" timeout="30s"

Let the cluster control maxscale on both nodes

sudo systemctl stop maxscale
  • According to maxscale guide disable maxscale from starting automatically on both nodes

    sudo systemctl disable maxscale

Create constraints so that the VIP and maxscale stay together

sudo pcs constraint colocation add maxscale_service virtual_ip INFINITY
  • View constraints with sudo pcs constraint list

  • If desired, to keep the maxscale from starting before the VIP is started on the server add an ordering constraint

    sudo pcs constraint order virtual_ip then maxscale_service

Restart the cluster

sudo pcs cluster stop --all && sudo pcs cluster start --all

Check the status

sudo pcs status

Enable cluster services on both nodes

sudo systemctl enable pcsd
sudo systemctl enable corosync
sudo systemctl enable pacemaker

Troubleshooting / Status

  • Check cluster status with sudo pcs status
  • Stop a node (force a failover) with sudo pcs cluster stop node.domain.local
  • Start a node with sudo pcs cluster start node.domain.local

Sources:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment