Zabbix in built HA Setup: 2 core, frontend, DB
On Frontend Server
Step1: Add the Zabbix repo
rpm -Uvh https://repo.zabbix.com/zabbix/7.0/rhel/8/x86_64/zabbix-release-latest-7.0.el8.noarch.rpm
dnf clean all
Step2: Switch DNF module version for PHP
dnf module switch-to php:8.2
Step3: Install frontend, agent
dnf install zabbix-web-mysql zabbix-apache-conf zabbix-selinux-policy zabbix-agent
Step4: Go to the pat/etc/zabbix/web/zabbix.conf.php,
if it is not there then copy from where it is
cp /usr/share/zabbix/conf/zabbix.conf.php.example /etc/zabbix/web/zabbix.conf.php
If /etc/zabbix/web/ doesn’t exist, create it first:
mkdir -p /etc/zabbix/web/
cp /usr/share/zabbix/conf/zabbix.conf.php.example /etc/zabbix/web/zabbix.conf.php
Step5: Open it now
vi /etc/zabbix/web/zabbix.conf.php
Add the following lines
DB['TYPE'] = 'MYSQL';
$DB['SERVER'] = 'DB_ip';
$DB['PORT'] = '3306';
$DB['DATABASE'] = 'zabbix';
$DB['USER'] = 'zabbix';
$DB['PASSWORD'] = 'zabbix';
-------------------------------------------------------------
$ZBX_SERVER = 'anycommon_ip';
$ZBX_SERVER_PORT = '10051';
$ZBX_SERVER_NAME = 'Zabbix HA';
$IMAGE_FORMAT_DEFAULT = IMAGE_FORMAT_PNG;
Step6: Install the HA Proxy: automatic way to connect the frontend server to the active Zabbix core server, without having to manually edit /etc/hosts
or DNS every time there's a failover.
Why HA Proxy?
- Automatically check which Zabbix core server is active
- Forward all connections (port 10051) to the active node
- No need to change anything manually after failover
- Works seamlessly with Zabbix built-in HA
yum install haproxy -y
open the file /etc/haproxy/haproxy.cfg
vi /etc/haproxy/haproxy.cfg
Add the following line at last
frontend zabbix_server
mode tcp
bind common_ip:10051
default_backend zabbix_backends
backend zabbix_backends
mode tcp
option tcp-check
tcp-check connect
server coreserver core1_ip:10051 check inter 1s fall 1 rise 1
server coreserver2 core2_ip:10051 check inter 1s fall 1 rise 1
To verify the HAProxy config file
haproxy -c -f /etc/haproxy/haproxy.cfg
Step7: Start the HA Proxy
sudo systemctl restart haproxy
sudo systemctl enable haproxy
Step8: Start the httpd
systemctl restart httpd php-fpm
systemctl enable httpd php-fpm
On Core server1 and Core server2
Step1: Add the Zabbix repo
rpm -Uvh https://repo.zabbix.com/zabbix/7.0/rhel/8/x86_64/zabbix-release-latest-7.0.el8.noarch.rpm
dnf clean all
Step1: Add the Zabbix repo
rpm -Uvh https://repo.zabbix.com/zabbix/7.0/rhel/8/x86_64/zabbix-release-latest-7.0.el8.noarch.rpm
dnf clean all
Step2: install the sql scripts
dnf install zabbix-sql-scripts zabbix-selinux-policy zabbix-agent
Step3: Install the mysql server
dnf install mysql-server
systemctl restart mysqld
Stpe4: login to DB
mysql -uroot -p
create database zabbix character set utf8mb4 collate utf8mb4_bin;
create user zabbix@localhost identified by 'password';
CREATE USER 'zabbix'@'core1_ip' IDENTIFIED BY 'zabbix';
CREATE USER 'zabbix'@'core2_ip' IDENTIFIED BY 'zabbix';
CREATE USER 'zabbix'@'Frontend_ip' IDENTIFIED BY 'zabbix';
GRANT ALL PRIVILEGES ON zabbix.* TO 'zabbix'@'core1_ip';
GRANT ALL PRIVILEGES ON zabbix.* TO 'zabbix'@'core2_ip';
GRANT ALL PRIVILEGES ON zabbix.* TO 'zabbix'@'frontend_ip';
grant all privileges on zabbix.* to zabbix@localhost;
set global log_bin_trust_function_creators = 1;
quit;
Comments
Post a Comment