See www.zabbix.com for the official Zabbix site.

Docs/howto/high availability on Centos 6.x

From Zabbix.org
Jump to: navigation, search

Centos 6.x HA Guide

!! Activate EPEL Repo's !!

In this guide we will talk about zabbixserver1 and 2 as the nodes for failover, zabbixdb wil be our database and zabbixcluster will be our virtual ip for the cluster

Use fixed ip's

system-config-network [1]


Zabbix Install Guide

Zabbix Rhel6.x install guide

On the Database Server:

Normally the database should be installed on some storage For testing we install it on a seperate server using the normal zabbix installation procedure.

Only the mysqld service will be started automatic on boot !

Modifications:

Give access to the database for each machine in the cluster

grant all privileges on zabbix.* to zabbix@<ip clusternode> identified by 'zabbix';
flush privileges;

if the connection to the db is not working try with hostname instead of <ip name>

Edit the hosts file on each server.

vi /etc/hosts

10.0.0.28 zabbixserver1
10.0.0.29 zabbixserver2
10.0.0.21 zabbixdb
10.0.0.31 zabbixcluster (free ip for virtual server)

Don't make names longer then 15 characters !

Cluster Node's

Edit the zabbix servers config

vi /etc/zabbix/zabbix_server.conf
 DBHost=zabbixdb

Edit the zabbix web config.

vi /etc/zabbix/web/zabbix.conf.php

<?php
// Zabbix GUI configuration file
global $DB;

$DB['TYPE']     = 'MYSQL';
$DB['SERVER']   = 'zabbixdb';
$DB['PORT']     = '0';
$DB['DATABASE'] = '<dbname>';
$DB['USER']     = '<dbuser>';
$DB['PASSWORD'] = '<dbpasswd>';

// SCHEMA is relevant only for IBM_DB2 database
$DB['SCHEMA'] = '';

$ZBX_SERVER      = 'zabbixcluster';
$ZBX_SERVER_PORT = '10051';
$ZBX_SERVER_NAME = '<node name>';

$IMAGE_FORMAT_DEFAULT = IMAGE_FORMAT_PNG;
?>

Stop the NetworkManager

service NetworkManager stop

Disable the service

chkconfig NetworkManager off

Edit /etc/sysconfig/network-scripts/ifcfg-eth0

NM_CONTROLLED=no

Install pacemaker and corosync

yum install pacemaker corosync pcs

Configure Corosync on 1 server and copy it to all nodes

The instructions below only apply for a machine with a single NIC. If you have a more complicated setup, you should edit the configuration manually.

export ais_port=4000
export ais_mcast=226.94.1.1
export ais_addr=`ip addr | grep "inet " | tail -n 1 | awk '{print $4}' | sed  1s/255/0/`

Display and verify the configuration options

env | grep ais_mcast=226.94.1.1

ais_addr=226.94.1.1

Once you’re happy with the chosen values, update the Corosync configuration

cp /etc/corosync/corosync.conf.example /etc/corosync/corosync.conf
sed -i.bak "s/.*mcastaddr:.*/mcastaddr:\ $ais_mcast/g" /etc/corosync/corosync.conf
sed -i.bak "s/.*mcastport:.*/mcastport:\ $ais_port/g" /etc/corosync/corosync.conf
sed -i.bak "s/.*bindnetaddr:.*/bindnetaddr:\ $ais_addr/g" /etc/corosync/corosync.conf
scp /etc/corosync/corosync.conf to the other nodes

Install and configure cman

yum install cman

The first thing we need to do, is tell CMAN complete starting up even without quorum. We can do this by changing the quorum timeout setting

sed -i.sed "s/.*CMAN_QUORUM_TIMEOUT=.*/CMAN_QUORUM_TIMEOUT=0/g" /etc/sysconfig/cman

Edit the Cluster conf

vi /etc/cluster/cluster.conf

<?xml version="1.0"?>
<cluster config_version="1" name="zabbixcluster">
  <logging debug="off"/>
  <clusternodes>
    <clusternode name="zabbixserver1" nodeid="1">
      <fence>
        <method name="pcmk-redirect">
          <device name="pcmk" port="zabbixserver1"/>
        </method>
      </fence>
    </clusternode>
    <clusternode name="zabbixserver2" nodeid="2">
      <fence>
        <method name="pcmk-redirect">
          <device name="pcmk" port="zabbixserver2"/>
        </method>
      </fence>
    </clusternode>
  </clusternodes>
  <fencedevices>
    <fencedevice name="pcmk" agent="fence_pcmk"/>
  </fencedevices>
  <cman> <multicast addr="226.94.1.1"/></cman>   => when running more clusters in same network change multicast address
</cluster>

Verify the config and start cman and pacemaker

ccs_config_validate
service cman start
cman_tool nodes
service pacemaker start
chkconfig cman on
chkconfig pacemaker on

Manage the cluster MANAGE YOUR CLUSTER ONLY THE DC !!!

check with crm_mon

Create resources: VIP: (Virtual Ip)

  • pcs resource create ClusterIP IPaddr2 ip=10.0.0.31 cidr_netmask=32 op monitor interval=2s
  • pcs property set stonith-enabled=false
  • pcs resource create zabbix-server lsb:zabbix-server op monitor interval=5s
  • pcs resource group add zabbix-cluster ClusterIP zabbix-server
  • pcs property set no-quorum-policy="ignore"
  • pcs property set default-resource-stickiness="100"

Firewall & SeLinux

  • SeLinux can stay in enforcing
  • Open following ports in the firewall 10050,10051,5404,5405

EXTRA'S

When u have issues:

pcs config show

MAKE SURE THERE ARE NO CONSTRAINTS !! (unless if you want zabbix run always on 1 place)

If u want zabbix always to run on zabbixserver2

pcs constraint location zabbix-cluster prefers zabbixserver2=INFINITY


This setup was based on parts of the Clusterlabs Documentation


Send comments & idea's to patrik<at>open-future.be