Step 1: Configure Name Resolution
We need to configure our host to know it’s counterpart quickly without DNS (we don’t want false failures).
Open the following two entries to your /etc/hosts file.
|
primary_zabbixserver_ip zabbixserver1 zabbixserver1.example.com secondary_zabbixserver_ip zabbixserver2 zabbixserver2.example.com |
Step 2: Install Zabbix Server
Now we need to install the Zabbix Server, however there are so many ways to deploy this I prefer Puppet (mainly because I contribute a lot to https://github.com/dj-wasabi/puppet-zabbix) We are going to do this the standard way.
On both Zabbix Servers we will need to install Zabbix, I like MySQL, but that’s just because I’ve been using it a long time.
At the time this is written current version is Zabbix 3.0
|
#install the zabbix repository sudo rpm -ivh http://repo.zabbix.com/zabbix/3.0/rhel/7/x86_64/zabbix-release-3.0-1.el7.noarch.rpm #install zabbix-server-mysql from the zabbix repository sudo yum install zabbix-server-mysql |
I don’t really want to go far in depth to showing the entire Zabbix Server configuration, if you still need help setting the rest up please visit:
https://www.zabbix.com/documentation/3.0/manual/installation/install_from_packages#red_hat_enterprise_linuxcentos
However there is one change that is very important. You will need to configure in your
/etc/zabbix/zabbix_server.conf
|
SourceIP=<cluster_ip> ListenIP=<cluster_ip> |
Step 3: Configure Pacemaker
|
#zabbixserver1 sudo yum install pacemaker pcs sudo passwd hacluster sudo systemctl start pcsd.service sudo systemctl enable pcsd.service |
|
#zabbixserver2 sudo yum install pacemaker pcs sudo passwd hacluster sudo systemctl start pcsd.service sudo systemctl enable pcsd.service |
Lets go back to zabbixserver1 and get these two authenticating to each other.
|
sudo pcs cluster auth zabbixserver1 zabbixserver2 Username: hacluster |
Now we need to create the cluster and add the zabbix servers
|
sudo pcs cluster setup --name zabbixserver zabbixserver1 zabbixserver2 |
To start the cluster
|
sudo pcs cluster start --all |
Make sure that Pacemaker and Corosync are started at boot on both hosts.
|
#zabbixserver1 sudo systemctl enable corosync.service sudo systemctl enable pacemaker.service |
|
#zabbixserver2 sudo systemctl enable corosync.service sudo systemctl enable pacemaker.service |
Check the status of your cluster after it’s been started by using
Check the status of your nodes in the cluster by using
For Zabbix we don’t need or want stonith especially since we just have 2 servers. Lets run:
|
sudo pcs property set stonith-enabled=false |
Because we have 2 nodes our number of nodes is too low to have a quorum. To have a quorum you must have at least 2 nodes, and that would defeat the purpose of this. We will ignore the low quorum with the following.
|
pcs property set no-quorum-policy=ignore |
Now we are into the fun part! Lets create the VIP which would be used between both of these Zabbix Servers.
|
pcs resource create cluster_vip ocf:heartbeat:IPaddr2 ip=<cluster_ip> cidr_netmask=<cluster_netmask> op monitor interval=20s |
To test this you can try to ping the <cluster_ip> now.
You should also see a resource now appear when you test the command
Lets disable systemd from controlling zabbix-server. Once the next step is completed, Pacemaker will actually control the process.
|
#zabbixserver1 sudo systemctl disable zabbix-server |
|
#zabbixserver2 sudo systemctl disable zabbix-server |
Now we need to setup the Zabbix Server resource which will make sure that the systemd (CentOS 7) has zabbix-server always running in this cluster.
|
sudo pcs resource create zabbix_server systemd:zabbix-server op monitor interval=10s |
You should also see that resource now appear when you test the command
Now we may have a problem, in its current state the VIP and the zabbix_server can be running on different nodes. Definitely not what we want happening. To resolve this we need to add some constraints that tell pacemaker that they need to be on the same host, and that the cluster_ip needs to be completed before the zabbix_server
|
sudo pcs constraint colocation add zabbix_server cluster_vip sudo pcs constraint order cluster_vip then zabbix_server |
Testing the cluster can be done by the following
|
sudo pcs cluster stop zabbixserver1 |
Bonus Item
If you would like Zabbix Server to prefer a specific server you can use the following command to do so.
|
pc constraint location cluster_vip prefers zabbixserver1 pc constraint location zabbix_server prefers zabbixserver1 |
Used Resources:
https://www.digitalocean.com/community/tutorials/how-to-set-up-an-apache-active-passive-cluster-using-pacemaker-on-centos-7