安装zabbix客户端和配置监控请阅读Zabbix监控服务二、安装zabbix客户端与监控的配置流程
配置邮箱报警请阅读Zabbix监控服务三、配置邮件报警
配置zabbix自定义报警请阅读Zabbix监控服务四、配置自定义监控
zabbix用户、用户组、权限管理和模板、模板组管理请阅读Zabbix监控服务五、用户管理与模板管理
Zabbix是一种开源的网络监控和管理解决方案,它可以监控各种网络设备、服务器和应用程序。它提供了强大的监控功能和可定制化的警报系统,可以帮助管理员及时发现并解决各种网络问题。
Zabbix的工作原理是通过代理或直接连接到被监控的设备上收集数据,并将数据发送到Zabbix服务器进行处理和存储。Zabbix使用基于服务器-代理模型的架构,可以实现对大规模分布式网络的监控。
- 强大的监控功能:可以监控多种指标,如服务器性能、网络流量、应用程序状态等。
- 可定制化的警报系统:可以根据自定义的条件设置警报规则,及时通知管理员。
- Web界面友好:提供直观易用的用户界面,方便管理员进行配置和管理。
- 开源免费:Zabbix是开源软件,可以免费使用和定制。
- 配置复杂:对于不熟悉Zabbix的管理员来说,初次配置可能较为复杂。
- 高资源消耗:Zabbix服务器对于大规模监控需要较高的硬件配置和资源消耗。
- 缺乏图形化报表:Zabbix的报表功能相对较弱,需要通过其他工具进行数据可视化和报表生成。
总体来说,Zabbix是一款功能强大的网络监控工具,适用于大规模分布式网络环境,并且由于开源免费的特点,也受到了广泛的用户欢迎。
Linux系统 | Apache版本 | MySQL版本 | PHP版本 | zabbix版本 | Zabbix应用 |
---|---|---|---|---|---|
centos8 | httpd-2.4.57 | mariadb-10.5.9 | php-8.2.10 | Zabbix-6.4 | zabbix_server、zabbix_agent |
因为zabbix监控服务是一个web服务
目前好多yum源里面都没有mariadb10.5版本的包
//安装mariadb10.5.9
[root@zabbix ~] yum -y install http://mirror.centos.org/centos/8-stream/AppStream/x86_64/os/Packages/mariadb-common-10.5.9-1.module_el8.5.0+732+7afc82e7.x86_64.rpm http://mirror.centos.org/centos/8-stream/AppStream/x86_64/os/Packages/mariadb-errmsg-10.5.9-1.module_el8.5.0+732+7afc82e7.x86_64.rpm
[root@zabbix ~] yum -y install mysql-selinux psmisc
[root@zabbix ~] yum -y install http://mirror.centos.org/centos/8-stream/AppStream/x86_64/os/Packages/mariadb-10.5.9-1.module_el8.5.0+732+7afc82e7.x86_64.rpm
[root@zabbix ~] yum -y install http://mirror.centos.org/centos/8-stream/AppStream/x86_64/os/Packages/mariadb-server-10.5.9-1.module_el8.5.0+732+7afc82e7.x86_64.rpm
//启动mariadb,并设置开机自启
[root@zabbix ~] systemctl start mariadb
[root@zabbix ~] systemctl enable mariadb
//设置root密码
[root@zabbix ~]# mysql
MariaDB [(none)]> ALTER USER 'root'@'localhost' IDENTIFIED BY 'lcwanf001';
MariaDB [(none)]> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'lcwanf001' WITH GRANT OPTION;
Query OK, 0 rows affected (0.001 sec)
MariaDB [(none)]> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.000 sec)
MariaDB [(none)]> quit
Bye
PHP版本要大于7.4
具体过程请参考我主页的源码部署lamp架构的文章源码部署lamp
[root@zabbix ~]# systemctl disable --now firewalld
[root@zabbix ~]# vim /etc/selinux/config
[root@zabbix ~]# cat /etc/selinux/config
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# enforcing - SELinux security policy is enforced.
# permissive - SELinux prints warnings instead of enforcing.
# disabled - No SELinux policy is loaded.
SELINUX=disabled //改为disabled
# SELINUXTYPE= can take one of these three values:
# targeted - Targeted processes are protected,
# minimum - Modification of targeted policy. Only selected processes are protected.
# mls - Multi Level Security protection.
SELINUXTYPE=targeted
//创建zabbix用户
[root@zabbix ~]# useradd -r -M -s /sbin/nologin zabbix
[root@zabbix ~]# id zabbix
uid=993(zabbix) gid=991(zabbix) groups=991(zabbix)
//安装依赖包(在部署lamp架构的时候就已经安装了部分依赖包,所以这边就只需要安装几个就行了)
[root@zabbix ~]# yum -y install net-snmp-devel libevent-devel mysql-devel
[root@zabbix ~]# yum -y install http://mirror.centos.org/centos/8-stream/PowerTools/x86_64/os/Packages/OpenIPMI-devel-2.0.31-3.el8.x86_64.rpm
//下载源码包
[root@zabbix ~]# wget https://cdn.zabbix.com/zabbix/sources/stable/6.4/zabbix-6.4.6.tar.gz
//解压
[root@zabbix ~]# ls
anaconda-ks.cfg zabbix-6.4.6.tar.gz
[root@zabbix ~]# tar xf zabbix-6.4.6.tar.gz
[root@zabbix ~]# ls
anaconda-ks.cfg zabbix-6.4.6 zabbix-6.4.6.tar.gz
//登录到数据库里面,创建zabbix数据库、zabbix用户,并授权
MariaDB [(none)]> create database zabbix character set utf8mb4 collate utf8mb4_bin;
Query OK, 1 row affected (0.001 sec)
MariaDB [(none)]> create user 'zabbix'@'localhost' identified by 'zabbix001';
Query OK, 0 rows affected (0.001 sec)
MariaDB [(none)]> grant all privileges on zabbix.* to 'zabbix'@'localhost';
Query OK, 0 rows affected (0.001 sec)
MariaDB [(none)]> SET GLOBAL log_bin_trust_function_creators = 1;
Query OK, 0 rows affected (0.000 sec)
MariaDB [(none)]> flush privileges;
Query OK, 0 rows affected (0.001 sec)
MariaDB [(none)]> quit
//导入表和数据
[root@zabbix ~]# ls
anaconda-ks.cfg zabbix-6.4.6 zabbix-6.4.6.tar.gz
[root@zabbix ~]# cd zabbix-6.4.6/
[root@zabbix zabbix-6.4.6]# ls
aclocal.m4 compile configure.ac INSTALL man sass
AUTHORS conf COPYING install-sh misc src
bin config.guess database m4 missing ui
build config.sub depcomp Makefile.am NEWS
ChangeLog configure include Makefile.in README
[root@zabbix zabbix-6.4.6]# cd database/
[root@zabbix database]# ls
elasticsearch Makefile.am Makefile.in mysql oracle postgresql sqlite3
[root@zabbix database]# cd mysql/
[root@zabbix mysql]# ls
data.sql history_pk_prepare.sql Makefile.am schema.sql
double.sql images.sql Makefile.in
//导入表和数据到zabbix库里面
[root@zabbix mysql]# mysql -uzabbix -pzabbix001 zabbix < schema.sql
[root@zabbix mysql]# mysql -uzabbix -pzabbix001 zabbix < images.sql
[root@zabbix mysql]# mysql -uzabbix -pzabbix001 --default-character-set=utf8mb4 zabbix < data.sql
//再次登录到数据库,禁用log_bin_trust_function_creators
MariaDB [(none)]> SET GLOBAL log_bin_trust_function_creators = 0;
Query OK, 0 rows affected (0.001 sec)
MariaDB [(none)]> quit
//设置一个环境变量
[root@zabbix ~]# export CFLAGS="-std=gnu99"
//开始配置、编译安装
[root@zabbix ~]# cd zabbix-6.4.6/
[root@zabbix zabbix-6.4.6]# ./configure --enable-server --enable-agent --with-mysql --with-net-snmp --with-libcurl --with-libxml2 --with-openipmi
(过程省略)
LDAP support: no
IPv6 support: no
cmocka support: no
yaml support: no
***********************************************************
* Now run 'make install' *
* *
* Thank you for using Zabbix! *
* //www.zabbix.com> *
***********************************************************
(配置结果是这样就是正常的)
//执行编译安装、编译安装zabbix不需要先make再make install,直接make install就行
[root@zabbix zabbix-6.4.6]# make install
(过程省略)
//查看一下服务的配置文件
[root@zabbix zabbix-6.4.6]# cd /usr/local/etc/
[root@zabbix etc]# ls
zabbix_agentd.conf zabbix_server.conf
zabbix_agentd.conf.d zabbix_server.conf.d
//指定zabbix数据库连接密码
[root@zabbix etc]# pwd
/usr/local/etc
[root@zabbix etc]# vim zabbix_server.conf
# Default:
# DBPassword=
DBPassword=zabbix001 //添加本行,在第124行
### Option: DBSocket
//配置服务加入systemctl管理,设置开机自启
服务端
[root@zabbix ~]# vim /usr/lib/systemd/system/zabbix_server.service
[root@zabbix ~]# cat /usr/lib/systemd/system/zabbix_server.service
[Unit]
Description=zabbix server daemon
After=network.targe
[Service]
Type=forking
ExecStart=/usr/local/sbin/zabbix_server
ExecStop=pkill zabbix_server
ExecReload=/bin/kill -HUP \$MAINPID
[Install]
WantedBy=multi-user.target
客户端
[root@zabbix ~]# vim /usr/lib/systemd/system/zabbix_agentd.service
[root@zabbix ~]# cat /usr/lib/systemd/system/zabbix_agentd.service
[Unit]
Description=zabbix agentd daemon
After=network.targe
[Service]
Type=forking
ExecStart=/usr/local/sbin/zabbix_agentd
ExecStop=pkill zabbix_agentd
ExecReload=/bin/kill -HUP \$MAINPID
[Install]
WantedBy=multi-user.target
//重新加载
[root@zabbix ~]# systemctl daemon-reload
//启动服务
[root@zabbix ~]# systemctl start zabbix_server.service //服务端
[root@zabbix ~]# systemctl start zabbix_agentd.service //客户端
//设置开机自启
[root@zabbix ~]# systemctl enable --now zabbix_server.service
Created symlink /etc/systemd/system/multi-user.target.wants/zabbix_server.service → /usr/lib/systemd/system/zabbix_server.service.
[root@zabbix ~]# systemctl enable --now zabbix_agentd.service
Created symlink /etc/systemd/system/multi-user.target.wants/zabbix_agentd.service → /usr/lib/systemd/system/zabbix_agentd.service.
//查看端口号。10051是服务端,10050是客户端
[root@zabbix ~]# ss -anlt
State Recv-Q Send-Q Local Address:Port Peer Address:Port Process
LISTEN 0 128 0.0.0.0:10050 0.0.0.0:*
LISTEN 0 128 0.0.0.0:10051 0.0.0.0:*
LISTEN 0 2048 127.0.0.1:9000 0.0.0.0:*
LISTEN 0 128 0.0.0.0:22 0.0.0.0:*
LISTEN 0 80 *:3306 *:*
LISTEN 0 511 *:80 *:*
LISTEN 0 128 [::]:22 [::]:*
[root@zabbix ~]#
//修改/etc/php.ini的配置
[root@zabbix ~]# sed -ri 's/(post_max_size =).*/\1 16M/g' /etc/php.ini
[root@zabbix ~]# sed -ri 's/(max_execution_time =).*/\1 300/g' /etc/php.ini
[root@zabbix ~]# sed -ri 's/(max_input_time =).*/\1 300/g' /etc/php.ini
[root@zabbix ~]# sed -i '/;date.timezone/a date.timezone = Asia/Shanghai' /etc/php.ini
//重启php-fpm
[root@zabbix ~]# systemctl restart php-fpm.service
//在 /usr/local/apache/htdocs/下给zabbix的网页文件创建一个家目录
[root@zabbix ~]# mkdir /usr/local/apache/htdocs/zabbix
//进入到解压后的源码包目录,把zabbix的网页文件全部复制到刚刚创建的目录里面去
[root@zabbix zabbix-6.4.6]# \cp -a ui/* /usr/local/apache/htdocs/zabbix/
[root@zabbix zabbix-6.4.6]# ls /usr/local/apache/htdocs/zabbix/
api_jsonrpc.php graphs.php local
api_scim.php history.php locale
app host_discovery.php map.php
assets hostinventoriesoverview.php modules
audio hostinventories.php report2.php
browserwarning.php host_prototypes.php report4.php
chart2.php httpconf.php robots.txt
chart3.php httpdetails.php setup.php
chart4.php image.php sysmap.php
chart6.php imgstore.php sysmaps.php
chart7.php include templates.php
chart.php index_http.php toptriggers.php
composer.json index.php tr_events.php
composer.lock index_sso.php trigger_prototypes.php
conf items.php triggers.php
data js vendor
disc_prototypes.php jsLoader.php widgets
favicon.ico jsrpc.php zabbix.php
//设置属主
[root@zabbix zabbix-6.4.6]# chown -R apache.apache /usr/local/apache/
//在配置文件末端,添加如下
[root@zabbix ~]# vim /etc/httpd24/httpd.conf
(省略)
*:80>
DocumentRoot "/usr/local/apache/htdocs/zabbix"
ServerName zabbix.cl.com
ProxyRequests Off
ProxyPassMatch ^/(.*\.php)$ fcgi://127.0.0.1:9000/usr/local/apache/htdocs/zabbix/
"/usr/local/apache/htdocs/zabbix.cl.com">
Options none
AllowOverride none
Require all granted
</Directory>
</VirtualHost>
//设置zabbix/conf目录的权限,让zabbix有权限生成配置文件zabbix.conf.php
[root@zabbix ~]# chmod 777 /usr/local/apache/htdocs/zabbix/conf/
//重启Apache服务
[root@zabbix ~]# systemctl restart httpd.service
如果想使用域名登录,则需要修改真机的hosts文件
路径在:C:\Windows\System32\drivers\etc
添加ip与域名的映射关系
也可以直接使用ip访问
安装过程中无法设置中文
完成安装
zabbix默认登录用户名和密码:
用户名 | 密码 |
---|---|
Admin | zabbix |
部署完成
[root@zabbix ~]# chmod 755 /usr/local/apache/htdocs/zabbix/conf