Hello,
I just installed zabbix in a distributed way as a zabbix newbie it wasn't easy, so I want to share my step by step documentation.
I want to mention places where I got information to create this step by step:
- zabbix forums: https://www.zabbix.com/forum/
- zabbix documentation: https://www.zabbix.com/documentation...es/rhel_centos
- the book "Mastering Zabbix" by Andrea Dalle Vacche and Stefano Kewan Lee
I hope it helps somebody
********
CENTOS 7
********
Step by step for a distributed installation of zabbix on three different servers:
- MySQL server 8.0.19-1.el7 on centos 7-1908 with minimal installation
- Apache hhtpd 2.4.6-90.el7 server on centos 7-1908 with minimal installation
- Zabbix 4.4.7-1.el7 server on centos 7-1908 with minimal installation
We are goint to use in this examples some passwords and IPs that you may change to adapt this tutorial to your installation
MySQL Server
************
# hostname: mysql-zabbix
# ip: 192.168.50.52
# install packages
rpm -Uvh https://repo.zabbix.com/zabbix/4.4/r...el7.noarch.rpm
yum update
yum install -y wget
wget https://dev.mysql.com/get/mysql80-co...7-3.noarch.rpm
rpm -Uvh https://dev.mysql.com/get/mysql80-co...7-3.noarch.rpm
yum install -y mysql-server zabbix-server-mysql
# enable services
systemctl start mysqld
systemctl enable mysqld
# initializing mysql
cat /var/log/mysqld.log
# review temporal password created during installation
/usr/bin/mysql_secure_installation
# use temporal password to start the script. Apply new password: "password+1" in our example
# create users for the database
mysql -u root -p
# ALTER USER 'root'@'localhost' IDENTIFIED BY 'password+1';
create database zabbix character set utf8 collate utf8_bin;
create user 'zabbix'@'%' identified by 'password+1';
ALTER USER 'zabbix'@'%' IDENTIFIED WITH mysql_native_password BY 'password+1';
grant all privileges on zabbix.* to 'zabbix'@'%';
quit;
# import tables to the database
zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -uzabbix -p -D zabbix
# enable native password login in mysql
vi /etc/my.cnf
default-authentication-plugin=mysql_native_password
bind-address=0.0.0.0
port=3306
# disable selinux to avoid some problems
vi /etc/selinux/config
SELINUX=disabled
#setenforce 0
# configure the firewall
firewall-cmd --permanent --zone=public --add-port=3306/tcp
firewall-cmd --reload
reboot
# zabbix-agent installation and access to the MySQL database
yum install -y zabbix-agent
vi /etc/zabbix/zabbix_agentd.conf
Server=192.168.50.53
ServerActive=192.168.50.53
Hostname=mysql-zabbix
firewall-cmd --permanent --add-port=10050/tcp
firewall-cmd --permanent --add-port=10051/tcp
firewall-cmd --reload
mysql
CREATE USER 'zabbix_monitor'@'%' IDENTIFIED BY 'password+1';
GRANT USAGE ON *.* TO 'zabbix_monitor'@'%';
FLUSH PRIVILEGES;
quit;
vi /etc/zabbix/zabbix_agentd.d/userparameter_mysql.conf
UserParameter=mysql.ping[*], mysqladmin -h"$1" -P"$2" ping
UserParameter=mysql.get_status_variables[*], mysql -h"$1" -P"$2" -sNX -e "show global status"
UserParameter=mysql.version[*], mysqladmin -s -h"$1" -P"$2" version
UserParameter=mysql.db.discovery[*], mysql -h"$1" -P"$2" -sN -e "show databases"
UserParameter=mysql.dbsize[*], mysql -h"$1" -P"$2" -sN -e "SELECT SUM(DATA_LENGTH + INDEX_LENGTH) FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA='$3'"
UserParameter=mysql.replication.discovery[*], mysql -h"$1" -P"$2" -sNX -e "show slave status"
UserParameter=mysql.slave_status[*], mysql -h"$1" -P"$2" -sNX -e "show slave status"
mkdir /var/lib/zabbix -p
vi /var/lib/zabbix/.my.cnf
[client]
user = zabbix_monitor
password = password+1
host = localhost
systemctl start zabbix-agent
systemctl enable zabbix-agent
reboot
Zabbix Server
*************
# hostname: zabbix-srv
# ip: 192.168.50.53
# install packages
rpm -Uvh https://repo.zabbix.com/zabbix/4.4/r...el7.noarch.rpm
yum update
yum install -y zabbix-server-mysql
# zabbix server configuration
vi /etc/zabbix/zabbix_server.conf
DBHost=192.168.50.52
DBName=zabbix
DBUser=zabbix
DBPassword=passwordRoot
DBPort=3306
# disable selinux
vi /etc/selinux/config
SELINUX=disabled
# configure firewall
firewall-cmd --permanent --add-port=10050/tcp
firewall-cmd --permanent --add-port=10051/tcp
firewall-cmd --reload
# enable services
systemctl start zabbix-server
systemctl enable zabbix-server
reboot
# zabbix-agent
yum install -y zabbix-agent
vi /etc/zabbix/zabbix_agentd.conf
Server=192.168.50.53
ServerActive=192.168.50.53
Hostname=zabbix-srv.localdomain
systemctl start zabbix-agent
systemctl enable zabbix-agent
reboot
# SNMPTraps configuration
firewall-cmd --add-port=162/udp --permanent
firewall-cmd --reload
yum install −y net-snmp-utils net-snmp net-snmp-perl wget
# SNMPTraps configuration: configure perl script zabbix_trap_receiver.pl and zabbix_server.conf
cd /tmp
wget https://sourceforge.net/projects/zab...x-4.4.6.tar.gz
tar -zxvf zabbix-4.4.6.tar.gz
cp ./zabbix-4.4.6/misc/snmptrap/zabbix_trap_receiver.pl /usr/bin
chmod +x /usr/bin/zabbix_trap_receiver.pl
# SNMPTraps configuration: configure snmptrapd.conf
vi /etc/snmp/snmptrapd.conf
# add the following lines
# authCommunity execute public
# perl do "/usr/bin/zabbix_trap_receiver.pl";
# SNMPTraps configuration: configure zabbix_server.conf
vi /etc/zabbix/zabbix_server.conf
# edit the following lines
# StartSNMPTrapper=1
# SNMPTrapperFile=/tmp/zabbix_traps.tmp
# SNMPTraps configuration: enable services
systemctl restart zabbix-server
systemctl enable snmptrapd
reboot
# Testing Traps
# Create the item:
# - Host: 'Zabbix server'
# - Item:
# - Name: SNMP TRAP TESTING
# - Type: SNMP Trap
# - Key: snmptrap.fallback
# - Host interface: 192.168.50.53:161
# - Type of information: Text
#
# Check the item created in "Monitoring > Latest data" (check "Show items without data" box)
snmptrap -v 1 -c public 192.168.50.53 '.1.3.6.1.6.3.1.1.5.4' '0.0.0.0' 6 33 '55' .1.3.6.1.6.3.1.1.5.4 s "eth0"
cat /tmp/zabbix_traps.tmp
# it should show something like this:
# 19:04:29 2020/03/26 ZBXTRAP 192.168.50.53
# PDU INFO:
# notificationtype TRAP
# version 0
# receivedfrom UDP: [192.168.50.53]:33751->[192.168.50.53]:162
# errorstatus 0
# messageid 0
# community public
# transactionid 2
# errorindex 0
# requestid 0
# VARBINDS:
# DISMAN-EVENT-MIB::sysUpTimeInstance type=67 value=Timeticks: (55) 0:00:00.55
# SNMPv2-MIB::snmpTrapOID.0 type=6 value=OID: IF-MIB::linkUp.0.33
# IF-MIB::linkUp type=4 value=STRING: "eth0"
# SNMP-COMMUNITY-MIB::snmpTrapCommunity.0 type=4 value=STRING: "public"
# SNMPv2-MIB::snmpTrapEnterprise.0 type=6 value=OID: IF-MIB::linkUp
Apache Server
*************
# hostname: apache-zabbix
# ip: 192.168.50.51
# install packages
rpm -Uvh https://repo.zabbix.com/zabbix/4.4/r...el7.noarch.rpm
yum update
yum -y install yum-utils
yum-config-manager --enable rhel-7-server-optional-rpms
yum -y install zabbix-server-mysql zabbix-web-mysql
# enable services
systemctl enable httpd
# configure firewall
firewall-cmd --add-service={http,https} --permanent
firewall-cmd --reload
# enable connection between apache and zabbix server
setsebool -P httpd_can_connect_zabbix on
setsebool -P httpd_can_network_connect_db on
# configure php
vi /etc/httpd/conf.d/zabbix.conf
php_value date.timezone Europe/Madrid
reboot
# install zabbix-agent
yum install -y zabbix-agent
vi /etc/zabbix/zabbix_agentd.conf
Server=192.168.50.53
ServerActive=192.168.50.53
Hostname=apache-zabbix.localdomain
# install zabbix-agent: configure firewall
firewall-cmd --permanent --add-port=10050/tcp
firewall-cmd --permanent --add-port=10051/tcp
firewall-cmd --reload
# install zabbix-agent: enable services
systemctl start zabbix-agent
systemctl enable zabbix-agent
reboot
I just installed zabbix in a distributed way as a zabbix newbie it wasn't easy, so I want to share my step by step documentation.
I want to mention places where I got information to create this step by step:
- zabbix forums: https://www.zabbix.com/forum/
- zabbix documentation: https://www.zabbix.com/documentation...es/rhel_centos
- the book "Mastering Zabbix" by Andrea Dalle Vacche and Stefano Kewan Lee
I hope it helps somebody
********
CENTOS 7
********
Step by step for a distributed installation of zabbix on three different servers:
- MySQL server 8.0.19-1.el7 on centos 7-1908 with minimal installation
- Apache hhtpd 2.4.6-90.el7 server on centos 7-1908 with minimal installation
- Zabbix 4.4.7-1.el7 server on centos 7-1908 with minimal installation
We are goint to use in this examples some passwords and IPs that you may change to adapt this tutorial to your installation
MySQL Server
************
# hostname: mysql-zabbix
# ip: 192.168.50.52
# install packages
rpm -Uvh https://repo.zabbix.com/zabbix/4.4/r...el7.noarch.rpm
yum update
yum install -y wget
wget https://dev.mysql.com/get/mysql80-co...7-3.noarch.rpm
rpm -Uvh https://dev.mysql.com/get/mysql80-co...7-3.noarch.rpm
yum install -y mysql-server zabbix-server-mysql
# enable services
systemctl start mysqld
systemctl enable mysqld
# initializing mysql
cat /var/log/mysqld.log
# review temporal password created during installation
/usr/bin/mysql_secure_installation
# use temporal password to start the script. Apply new password: "password+1" in our example
# create users for the database
mysql -u root -p
# ALTER USER 'root'@'localhost' IDENTIFIED BY 'password+1';
create database zabbix character set utf8 collate utf8_bin;
create user 'zabbix'@'%' identified by 'password+1';
ALTER USER 'zabbix'@'%' IDENTIFIED WITH mysql_native_password BY 'password+1';
grant all privileges on zabbix.* to 'zabbix'@'%';
quit;
# import tables to the database
zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -uzabbix -p -D zabbix
# enable native password login in mysql
vi /etc/my.cnf
default-authentication-plugin=mysql_native_password
bind-address=0.0.0.0
port=3306
# disable selinux to avoid some problems
vi /etc/selinux/config
SELINUX=disabled
#setenforce 0
# configure the firewall
firewall-cmd --permanent --zone=public --add-port=3306/tcp
firewall-cmd --reload
reboot
# zabbix-agent installation and access to the MySQL database
yum install -y zabbix-agent
vi /etc/zabbix/zabbix_agentd.conf
Server=192.168.50.53
ServerActive=192.168.50.53
Hostname=mysql-zabbix
firewall-cmd --permanent --add-port=10050/tcp
firewall-cmd --permanent --add-port=10051/tcp
firewall-cmd --reload
mysql
CREATE USER 'zabbix_monitor'@'%' IDENTIFIED BY 'password+1';
GRANT USAGE ON *.* TO 'zabbix_monitor'@'%';
FLUSH PRIVILEGES;
quit;
vi /etc/zabbix/zabbix_agentd.d/userparameter_mysql.conf
UserParameter=mysql.ping[*], mysqladmin -h"$1" -P"$2" ping
UserParameter=mysql.get_status_variables[*], mysql -h"$1" -P"$2" -sNX -e "show global status"
UserParameter=mysql.version[*], mysqladmin -s -h"$1" -P"$2" version
UserParameter=mysql.db.discovery[*], mysql -h"$1" -P"$2" -sN -e "show databases"
UserParameter=mysql.dbsize[*], mysql -h"$1" -P"$2" -sN -e "SELECT SUM(DATA_LENGTH + INDEX_LENGTH) FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA='$3'"
UserParameter=mysql.replication.discovery[*], mysql -h"$1" -P"$2" -sNX -e "show slave status"
UserParameter=mysql.slave_status[*], mysql -h"$1" -P"$2" -sNX -e "show slave status"
mkdir /var/lib/zabbix -p
vi /var/lib/zabbix/.my.cnf
[client]
user = zabbix_monitor
password = password+1
host = localhost
systemctl start zabbix-agent
systemctl enable zabbix-agent
reboot
Zabbix Server
*************
# hostname: zabbix-srv
# ip: 192.168.50.53
# install packages
rpm -Uvh https://repo.zabbix.com/zabbix/4.4/r...el7.noarch.rpm
yum update
yum install -y zabbix-server-mysql
# zabbix server configuration
vi /etc/zabbix/zabbix_server.conf
DBHost=192.168.50.52
DBName=zabbix
DBUser=zabbix
DBPassword=passwordRoot
DBPort=3306
# disable selinux
vi /etc/selinux/config
SELINUX=disabled
# configure firewall
firewall-cmd --permanent --add-port=10050/tcp
firewall-cmd --permanent --add-port=10051/tcp
firewall-cmd --reload
# enable services
systemctl start zabbix-server
systemctl enable zabbix-server
reboot
# zabbix-agent
yum install -y zabbix-agent
vi /etc/zabbix/zabbix_agentd.conf
Server=192.168.50.53
ServerActive=192.168.50.53
Hostname=zabbix-srv.localdomain
systemctl start zabbix-agent
systemctl enable zabbix-agent
reboot
# SNMPTraps configuration
firewall-cmd --add-port=162/udp --permanent
firewall-cmd --reload
yum install −y net-snmp-utils net-snmp net-snmp-perl wget
# SNMPTraps configuration: configure perl script zabbix_trap_receiver.pl and zabbix_server.conf
cd /tmp
wget https://sourceforge.net/projects/zab...x-4.4.6.tar.gz
tar -zxvf zabbix-4.4.6.tar.gz
cp ./zabbix-4.4.6/misc/snmptrap/zabbix_trap_receiver.pl /usr/bin
chmod +x /usr/bin/zabbix_trap_receiver.pl
# SNMPTraps configuration: configure snmptrapd.conf
vi /etc/snmp/snmptrapd.conf
# add the following lines
# authCommunity execute public
# perl do "/usr/bin/zabbix_trap_receiver.pl";
# SNMPTraps configuration: configure zabbix_server.conf
vi /etc/zabbix/zabbix_server.conf
# edit the following lines
# StartSNMPTrapper=1
# SNMPTrapperFile=/tmp/zabbix_traps.tmp
# SNMPTraps configuration: enable services
systemctl restart zabbix-server
systemctl enable snmptrapd
reboot
# Testing Traps
# Create the item:
# - Host: 'Zabbix server'
# - Item:
# - Name: SNMP TRAP TESTING
# - Type: SNMP Trap
# - Key: snmptrap.fallback
# - Host interface: 192.168.50.53:161
# - Type of information: Text
#
# Check the item created in "Monitoring > Latest data" (check "Show items without data" box)
snmptrap -v 1 -c public 192.168.50.53 '.1.3.6.1.6.3.1.1.5.4' '0.0.0.0' 6 33 '55' .1.3.6.1.6.3.1.1.5.4 s "eth0"
cat /tmp/zabbix_traps.tmp
# it should show something like this:
# 19:04:29 2020/03/26 ZBXTRAP 192.168.50.53
# PDU INFO:
# notificationtype TRAP
# version 0
# receivedfrom UDP: [192.168.50.53]:33751->[192.168.50.53]:162
# errorstatus 0
# messageid 0
# community public
# transactionid 2
# errorindex 0
# requestid 0
# VARBINDS:
# DISMAN-EVENT-MIB::sysUpTimeInstance type=67 value=Timeticks: (55) 0:00:00.55
# SNMPv2-MIB::snmpTrapOID.0 type=6 value=OID: IF-MIB::linkUp.0.33
# IF-MIB::linkUp type=4 value=STRING: "eth0"
# SNMP-COMMUNITY-MIB::snmpTrapCommunity.0 type=4 value=STRING: "public"
# SNMPv2-MIB::snmpTrapEnterprise.0 type=6 value=OID: IF-MIB::linkUp
Apache Server
*************
# hostname: apache-zabbix
# ip: 192.168.50.51
# install packages
rpm -Uvh https://repo.zabbix.com/zabbix/4.4/r...el7.noarch.rpm
yum update
yum -y install yum-utils
yum-config-manager --enable rhel-7-server-optional-rpms
yum -y install zabbix-server-mysql zabbix-web-mysql
# enable services
systemctl enable httpd
# configure firewall
firewall-cmd --add-service={http,https} --permanent
firewall-cmd --reload
# enable connection between apache and zabbix server
setsebool -P httpd_can_connect_zabbix on
setsebool -P httpd_can_network_connect_db on
# configure php
vi /etc/httpd/conf.d/zabbix.conf
php_value date.timezone Europe/Madrid
reboot
# install zabbix-agent
yum install -y zabbix-agent
vi /etc/zabbix/zabbix_agentd.conf
Server=192.168.50.53
ServerActive=192.168.50.53
Hostname=apache-zabbix.localdomain
# install zabbix-agent: configure firewall
firewall-cmd --permanent --add-port=10050/tcp
firewall-cmd --permanent --add-port=10051/tcp
firewall-cmd --reload
# install zabbix-agent: enable services
systemctl start zabbix-agent
systemctl enable zabbix-agent
reboot
Comment