0
votes

I have followed a guide and created a Nginx HA Cluster with a floating IP.

(Nginx, corosync, pacemaker are being used)

The guide I followed: https://dzone.com/articles/how-to-configure-nginx-high-availability-cluster-u

I succesfully created a 2 node cluster and they are both working fine. When Node1 goes offline, Node2 is used vice-versa. My problem is that in my case, Node1 should be primary, meaning it should be always used whenever it is online.

To describe it better:

  • Node1 and Node2 are online -> Node1 is being used
  • Node1 goes offline -> Node2 is being used automatically
  • (The problem) When Node1 comes back online, Node2 is still being used
  • I need to manually stop Node2 if I want Node1 to be used again.

What do I exactly need to configure to make it automatically switch to Node1 when it is online?

Thank you in advance!

1

1 Answers

1
votes

This is easily done via a simple infinity location constraint. In crmsh syntax this would appear like so:

location l_webserver_on_node1 hakase_balancing inf: node1

With that said, this does not adhere to best practices. In a well designed HA cluster both nodes should be equal, and it should not matter where the services run.

I have seen situations where there are intermittent problems with node1. For example, say node1 seems to crash and reboot about once a day. This means that twice a day your service will encounter a brief interruption as it migrates to node2 and then back to node1 when it finishes rebooting. Ideally it should only migrate to node2 once when node1 crashes the first time. Then stay there while you troubleshoot and repair/replace node1.