官方地址:https://www.zabbix.com/cn/features
Zabbix是一个企业级解决方案,支持实时监控数千台服务器,虚拟机和网络设备,采集百万级监控指标,适用于任何IT基础架构、服务、应用程序和资源的解决方案
周期性时序数据
主机/对象:服务器、路由器、交换机、存储、防火墙、IP、PORT、URL、自定义监控对象…
采集目标:监控项,指标数据(metrics data)
监控数据存储系统
SQL: MySQL/MariaDB
历史数据: 每个监控项采集到的每个监控值
趋势数据: 趋势表里主要保留某个监控项一个小时内历史数据的最大值、最小值和平均值以及该监控项一个小时内所采集到的数据个数。
可按照预定义的阈值等级实现分层报警
email,短信,微信,语音,故障自治愈
数据采集方式:zabbix-server,zabbix-proxy,zabbix-agent
Agentless:SNMP,Telnet,ssh, IPMI, JMX
Agent:zabbix agent
zabbix database
zabbix web:
graph -> screen -> slideshow(将多个screen以幻灯片的方式进行轮流展示)
grafana:
以zabbix为数据源展示更绚丽的界面
host (host groups) <- templates #从模板继承告警配置
host -> items -> triggers -> action (条件-conditions, 操作-operations) #自定义告警配置
部署环境:
服务器系统:ubuntu 18.04.3/Centos 7.x
主机类型 | IP地址 |
---|---|
zabbix server | 10.10.100.100 |
zabbix 主动代理 | 10.10.100.101 |
zabbix 被动代理 | 10.10.100.102 |
mysql master | 10.10.100.103 |
mysql slave | 10.10.100.104 |
web server1 | 10.10.100.105 |
web server2 | 10.10.100.106 |
官方文档:
https://www.zabbix.com/documentation/5.0/zh/manual
使用apt在ubuntu 安装zabbix 5.0.x版本
https://www.zabbix.com/cn/download?zabbix=5.0&os_distribution=ubuntu&os_version=18.04_bionic&db=mysql&ws=apache
root@zabbix-server:~# wget https://repo.zabbix.com/zabbix/5.0/ubuntu/pool/main/z/zabbix-release/zabbix-release_5.0-1+bionic_all.deb
root@zabbix-server:~# dpkg -i zabbix-release_5.0-1+bionic_all.deb
root@zabbix-server:~# apt update
root@zabbix-server:~# apt install zabbix-server-mysql zabbix-frontend-php zabbix-apache-conf zabbix-agent
在10.10.100.103 (mysql master)上安装数据库
root@mysql-master:~# apt update
root@mysql-master:~# apt install mysql-server
#修改监听地址
root@mysql-master:~# vim /etc/mysql/mysql.conf.d/mysqld.cnf
bind-address = 0.0.0.0
root@mysql-master:~# systemctl restart mysql
#登入数据库并创建数据库及账号
root@mysql-master:~# mysql
mysql> create database zabbix character set utf8 collate utf8_bin;
mysql> create user zabbix@'10.10.100.%' identified by '123456';
mysql> grant all privileges on zabbix.* to zabbix@'10.10.100.%';
在zabbix-server(10.10.100.100)初始化数据库
root@zabbix-server:~# zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -uzabbix -h10.10.100.103 -p123456 zabbix
#登入数据库验证
root@zabbix-server:~# mysql -uzabbix -h10.10.100.103 -p123456
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| zabbix |
+--------------------+
2 rows in set (0.00 sec)
mysql> use zabbix;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql> show tables;
+----------------------------+
| Tables_in_zabbix |
+----------------------------+
| acknowledges |
| actions |
| alerts |
| application_discovery |
| application_prototype |
| application_template |
| applications |
| auditlog |
| auditlog_details |
| autoreg_host |
| conditions |
....
编辑zabbix server配置文件配置数据库信息
root@zabbix-server:~# vim /etc/zabbix/zabbix_server.conf
DBHost=10.10.100.103
DBName=zabbix
DBUser=zabbix
DBPassword=123456
DBPort=3306
启动zabbix
root@zabbix-server:~# systemctl restart zabbix-server zabbix-agent apache2
root@zabbix-server:~# systemctl enable zabbix-server zabbix-agent apache2
root@zabbix-server:~# vim /etc/zabbix/apache.conf
php_value date.timezone Asia/Shanghai
root@zabbix-server:~# systemctl restart zabbix-server zabbix-agent apache2
root@zabbix-server:~# cd /usr/local/src/
#下载源码包
root@zabbix-server:/usr/local/src# wget https://cdn.zabbix.com/zabbix/sources/stable/5.0/zabbix-5.0.15.tar.gz
#创建zabbix用户
root@zabbix-server:/usr/local/src# groupadd -g 1001 zabbix
root@zabbix-server:/usr/local/src# useradd -u 1001 -g 1001 zabbix
root@zabbix-server:/usr/local/src# id zabbix
uid=1001(zabbix) gid=1001(zabbix) groups=1001(zabbix)
Centos
yum install gcc libxml2-devel net-snmp net-snmp-devel curl curl-devel php php-bcmath php-mbstring mariadb mariadb-devel -y
Ubuntu
root@zabbix-server:/usr/local/src# apt-get install apache2 apache2-bin apache2-data apache2-utils fontconfig-config fonts-dejavu-core fping libapache2-mod-php libapache2-mod-php7.2 libapr1 libaprutil1 libaprutil1-dbd-sqlite3 libaprutil1-ldap libfontconfig1 libgd3 libiksemel3 libjbig0 libjpeg-turbo8 libjpeg8 liblua5.2-0 libodbc1 libopenipmi0 libsensors4 libsnmp-base libsnmp30 libsodium23 libssh2-1 libtiff5 libwebp6 libxpm4 php-bcmath php-common php-gd php-ldap php-mbstring php-mysql php-xml php7.2-bcmath php7.2-cli php7.2-common php7.2-gd php7.2-json php7.2-ldap php7.2-mbstring php7.2-mysql php7.2-opcache php7.2-readline php7.2-xml snmpd ssl-cert ttf-dejavu-core libmysqlclient-dev libxml2-dev libxml2 snmp libsnmp-dev libevent-dev openjdk-8-jdk curl libcurl4-openssl-dev
root@zabbix-server:/usr/local/src# tar xf zabbix-5.0.15.tar.gz
root@zabbix-server:/usr/local/src# cd zabbix-5.0.15/
root@zabbix-server:/usr/local/src/zabbix-5.0.15# ./configure --prefix=/apps/zabbix_server --enable-server --enable-agent --with-mysql --with-net-snmp --with-libcurl --with-libxml2 --enable-java
root@zabbix-server:/usr/local/src/zabbix-5.0.15# make install
root@mysql-master:~# apt update
root@mysql-master:~# apt install mysql-server
#修改监听地址
root@mysql-master:~# vim /etc/mysql/mysql.conf.d/mysqld.cnf
bind-address = 0.0.0.0
root@mysql-master:~# systemctl restart mysql
#登入数据库并创建账号
root@mysql-master:~# mysql
mysql> create database zabbix_server character set utf8 collate utf8_bin;
Query OK, 1 row affected (0.00 sec)
mysql> create user zabbix_server@'10.10.100.%' identified by '123456';
Query OK, 0 rows affected (0.00 sec)
mysql> grant all privileges on zabbix_server.* to zabbix_server@'10.10.100.%';
Query OK, 0 rows affected (0.00 sec)
#zabbix server安装mysql客户端
root@zabbix-server:~# apt install mysql-client -y
#登入数据库验证权限
root@zabbix-server:~# mysql -uzabbix_server -h10.10.100.103 -p123456
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| zabbix_server |
+--------------------+
2 rows in set (0.00 sec)
#导入初始化数据
root@zabbix-server:~# cd /usr/local/src/zabbix-5.0.15/database/mysql
root@zabbix-server:/usr/local/src/zabbix-5.0.15/database/mysql# mysql -uzabbix_server -h10.10.100.103 -p123456 zabbix_server
root@zabbix-server:/usr/local/src/zabbix-5.0.15/database/mysql# mysql -uzabbix_server -h10.10.100.103 -p123456 zabbix_server
root@zabbix-server:/usr/local/src/zabbix-5.0.15/database/mysql# mysql -uzabbix_server -h10.10.100.103 -p123456 zabbix_server
#修改数据库对应配置
root@zabbix-server:~# vim /apps/zabbix_server/etc/zabbix_server.conf
LogFile=/tmp/zabbix_server.log
DBHost=10.10.100.103
DBName=zabbix_server
DBUser=zabbix_server
DBPassword=123456
DBPort=3306
root@zabbix-server:~# mkdir /var/www/html/zabbix
root@zabbix-server:~# cd /usr/local/src/zabbix-5.0.15/
#拷贝web文件,zabbix 4.x版本是在frontends/php/ 5.x在ui/
root@zabbix-server:/usr/local/src/zabbix-5.0.15# cp -ra ./ui/* /var/www/html/zabbix/
zabbix-server启动文件
root@zabbix-server:~# vim /lib/systemd/system/zabbix-server.service
[Unit]
Description=Zabbix Server
After=syslog.target
After=network.target
[Service]
Environment="CONFFILE=/apps/zabbix_server/etc/zabbix_server.conf"
EnvironmentFile=-/etc/default/zabbix-server
Type=forking
Restart=on-failure
PIDFile=/tmp/zabbix_server.pid
KillMode=control-group
ExecStart=/apps/zabbix_server/sbin/zabbix_server -c $CONFFILE
ExecStop=/bin/kill -SIGTERM $MAINPID
RestartSec=10s
TimeoutSec=infinity
[Install]
WantedBy=multi-user.target
zabbix-agent启动文件
root@zabbix-server:~# vim /lib/systemd/system/zabbix-agent.service
[Unit]
Description=Zabbix Agent
After=syslog.target
After=network.target
[Service]
Environment="CONFFILE=/apps/zabbix_server/etc/zabbix_agentd.conf"
EnvironmentFile=-/etc/default/zabbix-agent
Type=forking
Restart=on-failure
PIDFile=/tmp/zabbix_agentd.pid
KillMode=control-group
ExecStart=/apps/zabbix_server/sbin/zabbix_agentd -c $CONFFILE
ExecStop=/bin/kill -SIGTERM $MAINPID
RestartSec=10s
User=zabbix
Group=zabbix
[Install]
WantedBy=multi-user.target
#启动zabbix-server
root@zabbix-server:~# systemctl start zabbix-server
root@zabbix-server:~# systemctl enable zabbix-server
#启动zabbix-agent
root@zabbix-server:~# systemctl start zabbix-agent
root@zabbix-server:~# systemctl enable zabbix-agent
root@zabbix-server:~# apt-get install php-gettext php-xml php-net-socket php-gd php-mysql
root@zabbix-server:~# vim /etc/php/7.2/apache2/php.ini
post_max_size = 16M
max_execution_time = 300
max_input_time = 300
date.timezone = Asia/Shanghai
root@zabbix-server:~# systemctl restart apache2
刷新验证
数据库配置
zabbix server配置
手动下载配置信息
#将刚刚下载的文件上传到服务器
root@zabbix-server:~# ll /var/www/html/zabbix/conf/zabbix.conf.php
-rw-r--r-- 1 root root 1515 Sep 29 18:04 /var/www/html/zabbix/conf/zabbix.conf.php
由于ubuntu系统目前未安装中文语言环境所以无法选择中文显示,需要在ubuntu系统安装中文语言环境,如下
#安装简体中文语言环境
root@zabbix-server:~# apt-get install language-pack-zh*
#增加中文语言环境变量
root@zabbix-server:~# vim /etc/environment
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games"
LANG="zh_CN.UTF-8"
#重新设置本地配置
root@zabbix-server:~# dpkg-reconfigure locales
#重启apache
root@zabbix-server:~# systemctl restart apache2
当前系统有些监控项部分显示有乱码,使由于web界面显示为中文但是系统没有相关字体支持,因此需要相关字体的支持才能正常显示
在Windows上找到控制面板–>字体–>楷体(或者其他个人喜欢的中文字体),然后将字体拷贝到windows系统其他目录,比如拷贝至windows当前用户的桌面。
将windows 字体文件上传至zabbix web目录,具体路径为/ZABBIX/WEB/PATH/assets/fonts/
root@zabbix-server:~# ll /var/www/html/zabbix/assets/fonts/simkai.ttf
-rw-r--r-- 1 root root 11787328 Sep 29 18:19 /var/www/html/zabbix/assets/fonts/simkai.ttf
root@zabbix-server:~# cd /var/www/html/zabbix/
root@zabbix-server:/var/www/html/zabbix# vim include/de
debug.inc.php defines.inc.php
root@zabbix-server:/var/www/html/zabbix# vim include/defines.inc.php
81 #define('ZBX_GRAPH_FONT_NAME', 'DejaVuSans'); // font file name
82 define('ZBX_GRAPH_FONT_NAME', 'simkai'); // font file name
123 #define('ZBX_FONT_NAME', 'DejaVuSans');
124 define('ZBX_FONT_NAME', 'simkai');