Zabbix是一个企业级的分布式开源监控方案。Zabbix是一款能够监控各种网络参数以及服务器健康性和完整性的软件。Zabbix使用灵活的通知机制,允许用户为几乎任何事件配置基于邮件的告警。这样可以快速反馈服务器的问题。基于已存储的数据,Zabbix提供了出色的报告和数据可视化功能。
Zabbix是一个高度集成的网络监控解决方案,一个简单的安装包中提供多样性的功能。
Zabbix结构
1. Server
Zabbix server是监控代理程序报告系统可用性、系统完整性和统计信息的核心组件。Zabbix Server是所有配置信息、统计信息和操作数据的核心存储器。
2. 数据库存储
所有配置信息和Zabbix收集到的数据都被存储在数据库中。
3. Web界面
为了在任何地方和任何平台都能轻松地访问Zabbix,Zabbix提供了基于Web的界面。该界面是Zabbix Server的一部分,通常跟Zabbix Server运行在同一台物理机器上。
如果使用SQLite,Zabbix Web界面必须要跟Zabbix Server运行在同一台物理机器上。
4. Proxy代理服务器
Zabbix Proxy可以替Zabbix Server收集性能和可用性数据。Proxy代理服务器是Zabbix软件可选择部署的一部分。当然,Proxy代理服务器可以帮助单台Zabbix Server分担负载压力。
5. Agent监控代理
Zabbix Agents监控代理部署在监控目标上,能够主动监控本地资源和应用程序,并将收集到的数据报告给Zabbix Server。
规划节点
IP | 主机名 | 节点 |
---|---|---|
10.30.59.205 | zabbix-server01 | Server节点 |
10.30.59.215 | zabbix-agent | Agent节点 |
修改主机名
[root@localhost ~]# hostnamectl set-hostname zabbix-server01
[root@localhost ~]# bash
[root@zabbix-server01 ~]# ifconfig ens192 |awk 'NR==2 {print $2}' 查看IP
关闭防火墙
[root@zabbix-server01 ~]# sed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config
[root@zabbix-server01 ~]# systemctl stop firewalld
[root@zabbix-server01 ~]# systemctl disable firewalld
Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
[root@zabbix-server01 ~]# free -m 查看内存
total used free shared buff/cache available
Mem: 3790 122 3511 8 155 3453
Swap: 3967 0 3967
安装zabbix(获取官方源)
[root@zabbix-server01 ~]# rpm -Uvh https://mirrors.aliyun.com/zabbix/zabbix/5.0/rhel/7/x86_64/zabbix-release-5.0-1.el7.noarch.rpm
Retrieving https://mirrors.aliyun.com/zabbix/zabbix/5.0/rhel/7/x86_64/zabbix-release-5.0-1.el7.noarch.rpm
warning: /var/tmp/rpm-tmp.Jzneux: Header V4 RSA/SHA512 Signature, key ID a14fe591: NOKEY
Preparing... ################################# [100%]
Updating / installing...
1:zabbix-release-5.0-1.el7 ################################# [100%]
检查/查看zabbix.repo
[root@zabbix-server01 ~]# ls /etc/yum.repos.d/
CentOS-Base.repo CentOS-Media.repo
CentOS-CR.repo CentOS-Sources.repo
CentOS-Debuginfo.repo CentOS-Vault.repo
CentOS-fasttrack.repo zabbix.repo
[root@zabbix-server01 ~]# sed -i 's#http://repo.zabbix.com#https://mirrors.aliyun.com/zabbix#' /etc/yum.repos.d/zabbix.repo
[root@zabbix-server01 ~]# yum clean all 清楚缓存
安装工具包
[root@zabbix-server01 ~]# yum install zabbix-server-mysql zabbix-agent -y
[root@zabbix-server01 ~]# yum install centos-release-scl -y
修改zabbix.repo的文件
[root@zabbix-server01 ~]# vi /etc/yum.repos.d/zabbix.repo
[zabbix-frontend]
enabled=1 修改为1
[root@zabbix-server01 ~]# yum install zabbix-web-mysql-scl zabbix-apache-conf-scl -y
[root@zabbix-server01 ~]# yum install mariadb-server -y
配置数据库开机启动
[root@zabbix-server01 ~]# systemctl enable --now mariadb
Created symlink from /etc/systemd/system/multi-user.target.wants/mariadb.service to /usr/lib/systemd/system/mariadb.service.
[root@zabbix-server01 ~]# mysql_secure_installation 初始化
Enter current password for root (enter for none): 默按回车
OK, successfully used password, moving on...
Set root password? [Y/n] y
New password:
Re-enter new password:
Password updated successfully!
Reloading privilege tables..
... Success!
添加数据库用户,以及zabbix所需的数据库信息
[root@zabbix-server01 ~]# mysql -uroot -p000000
MariaDB [(none)]> create database zabbix character set utf8 collate utf8_bin;
Query OK, 1 row affected (0.00 sec)
MariaDB [(none)]> create user zabbix@localhost identified by '000000';
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> grant all privileges on zabbix.* to zabbix@localhost;
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> flush privileges;
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> Ctrl-C -- exit!
Aborted
使用zabbix-mysql命令,导入数据库信息
[root@zabbix-server01 ~]# zcat /usr/share/doc/zabbix-server-mysql-5.0.12/create.sql.gz |mysql -uzabbix -p zabbix
Enter password:000000
[root@zabbix-server01 ~]# mysql -uzabbix -p000000
MariaDB [(none)]> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| zabbix |
+--------------------+
2 rows in set (0.00 sec)
MariaDB [(none)]> 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
MariaDB [zabbix]> show tables;
+----------------------------+
| Tables_in_zabbix |
+----------------------------+
| acknowledges |
| actions |
| alerts |
| application_discovery |
| application_prototype |
| application_template |
| applications |
| auditlog |
| auditlog_details |
| autoreg_host |
| conditions |
| config |
| config_autoreg_tls |
| corr_condition |
| corr_condition_group |
| corr_condition_tag |
| corr_condition_tagpair |
| corr_condition_tagvalue |
| corr_operation |
| correlation |
| dashboard |
| dashboard_user |
| dashboard_usrgrp |
| dbversion |
| dchecks |
| dhosts |
| drules |
| dservices |
| escalations |
| event_recovery |
| event_suppress |
| event_tag |
| events |
| expressions |
| functions |
| globalmacro |
| globalvars |
| graph_discovery |
| graph_theme |
| graphs |
| graphs_items |
| group_discovery |
| group_prototype |
| history |
| history_log |
| history_str |
| history_text |
| history_uint |
| host_discovery |
| host_inventory |
| host_tag |
| hostmacro |
| hosts |
| hosts_groups |
| hosts_templates |
| housekeeper |
| hstgrp |
| httpstep |
| httpstep_field |
| httpstepitem |
| httptest |
| httptest_field |
| httptestitem |
| icon_map |
| icon_mapping |
| ids |
| images |
| interface |
| interface_discovery |
| interface_snmp |
| item_application_prototype |
| item_condition |
| item_discovery |
| item_preproc |
| item_rtdata |
| items |
| items_applications |
| lld_macro_path |
| lld_override |
| lld_override_condition |
| lld_override_opdiscover |
| lld_override_operation |
| lld_override_ophistory |
| lld_override_opinventory |
| lld_override_opperiod |
| lld_override_opseverity |
| lld_override_opstatus |
| lld_override_optag |
| lld_override_optemplate |
| lld_override_optrends |
| maintenance_tag |
| maintenances |
| maintenances_groups |
| maintenances_hosts |
| maintenances_windows |
| mappings |
| media |
| media_type |
| media_type_message |
| media_type_param |
| module |
| opcommand |
| opcommand_grp |
| opcommand_hst |
| opconditions |
| operations |
| opgroup |
| opinventory |
| opmessage |
| opmessage_grp |
| opmessage_usr |
| optemplate |
| problem |
| problem_tag |
| profiles |
| proxy_autoreg_host |
| proxy_dhistory |
| proxy_history |
| regexps |
| rights |
| screen_user |
| screen_usrgrp |
| screens |
| screens_items |
| scripts |
| service_alarms |
| services |
| services_links |
| services_times |
| sessions |
| slides |
| slideshow_user |
| slideshow_usrgrp |
| slideshows |
| sysmap_element_trigger |
| sysmap_element_url |
| sysmap_shape |
| sysmap_url |
| sysmap_user |
| sysmap_usrgrp |
| sysmaps |
| sysmaps_elements |
| sysmaps_link_triggers |
| sysmaps_links |
| tag_filter |
| task |
| task_acknowledge |
| task_check_now |
| task_close_problem |
| task_data |
| task_remote_command |
| task_remote_command_result |
| task_result |
| timeperiods |
| trends |
| trends_uint |
| trigger_depends |
| trigger_discovery |
| trigger_tag |
| triggers |
| users |
| users_groups |
| usrgrp |
| valuemaps |
| widget |
| widget_field |
+----------------------------+
166 rows in set (0.00 sec)
MariaDB [zabbix]> Ctrl-C -- exit!
Aborted
修改配置文件的数据库密码
[root@zabbix-server01 ~]# vi /etc/zabbix/zabbix_server.conf
DBPassword=000000 修改此句
[root@zabbix-server01 ~]# grep '^DBpa' /etc/zabbix/zabbix_server.conf
修改php配置文件的时区信息
[root@zabbix-server01 ~]# vi /etc/opt/rh/rh-php72/php-fpm.d/zabbix.conf
php_value[date.timezone] = Asia/Shanghai 修改这一句
启动zabbix相关服务
[root@zabbix-server01 ~]# systemctl restart zabbix-server zabbix-agent httpd rh-php72-php-fpm
[root@zabbix-server01 ~]# systemctl enable zabbix-server zabbix-agent httpd rh-php72-php-fpm
Created symlink from /etc/systemd/system/multi-user.target.wants/zabbix-server.service to /usr/lib/systemd/system/zabbix-server.service.
Created symlink from /etc/systemd/system/multi-user.target.wants/zabbix-agent.service to /usr/lib/systemd/system/zabbix-agent.service.
Created symlink from /etc/systemd/system/multi-user.target.wants/httpd.service to /usr/lib/systemd/system/httpd.service.
Created symlink from /etc/systemd/system/multi-user.target.wants/rh-php72-php-fpm.service to /usr/lib/systemd/system/rh-php72-php-fpm.service.
显示PHP版本信息等内容(需要全部显示OK)
填写连接数据库的必要信息,Password为000000(其他不需要修改)
填写Zabbix服务端的详细信息,Name字段可以随意填写,是给监控平台起个名字
安装Zabbix,安装成功后,单击右下角“Finish”按钮
进入登录界面,使用默认的用户名和密码Admin/zabbix登录
进入Zabbix主页
点击 User setting ,将“Language”一栏修改为“Chinexe(zh CN)”