zabbix([`zæbiks])是一个基于WEB界面的提供分布式系统监视以及网络监视功能的企业级的开源解决方案。
zabbix能监视各种网络参数,保证服务器系统安全运营;并提供灵活的通知机制以让系统管理员快速定位/解决存在的各种问题。
zabbix由2部分构成,zabbix server与可选组件zabbix agent。
zabbix server可以通过SNMPzabbix agent,ping,端口监视等方法提供对远程服务器/网络状态的监视,数据收集等功能,它可以运行在LinuxSolarisHP-UXAIX,Free BSD,Open BSD,OS X等平台上。
Zabbix的主要特点:
– 安装与配置简单,学习成本低
– 支持多语言(包括中文)
– 免费开源
– 自动发现服务器与网络设备
– 分布式监视以及WEB集中管理功能
– 可以无agent监视
– 用户安全认证和柔软的授权方式
– 通过WEB界面设置或查看监视结果
– 告警通知:微信QQEmail等发送消息,打电话
-开箱即用的模板库
等等
Zabbix主要功能:
– CPU负荷
– 内存使用
-磁盘使用
– 网络状况
– 端口监视
– 日志监视 [1]
-数据处理
—–以上来自zabbix百度百科
zabbix中文官网下载地址:https://www.zabbix.com/cn/download

安装部署(主机版本Redhat8,zabbix版本6.0LTS)

1. 安装zabbix软件仓库

[root@zabbix1 ~]# rpm -Uvh https://repo.zabbix.com/zabbix/6.0/rhel/8/x86_64/zabbix-release-6.0-4.el8.noarch.rpm
Retrieving https://repo.zabbix.com/zabbix/6.0/rhel/8/x86_64/zabbix-release-6.0-4.el8.noarch.rpm
warning: /var/tmp/rpm-tmp.KSKjpw: Header V4 RSA/SHA512 Signature, key ID a14fe591: NOKEY
Verifying... ################################# [100%]
Preparing... ################################# [100%]
Updating / installing...
1:zabbix-release-6.0-4.el8 ################################# [100%]

这里建议把软件源指向阿里云,下载会快一点。当然直接用zabbix的源也没问题。以下是我更改后指向的软件源地址:

[root@zabbix1 ~]# cat /etc/yum.repos.d/zabbix.repo 
[zabbix]
name=Zabbix Official Repository - $basearch
baseurl=https://mirrors.aliyun.com/zabbix/zabbix/6.0/rhel/8/$basearch/
enabled=1
gpgcheck=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX-A14FE591

[zabbix-non-supported]
name=Zabbix Official Repository (non-supported) - $basearch
baseurl=https://mirrors.aliyun.com/zabbix/non-supported/rhel/8/$basearch/
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX
gpgcheck=0

[zabbix-unstable]
name=Zabbix Official Repository (unstable) - $basearch
baseurl=https://mirrors.aliyun.com/zabbix/zabbix/5.5/rhel/8/$basearch/
enabled=0
gpgcheck=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX-A14FE591

[root@zabbix1 ~]# cat /etc/yum.repos.d/zabbix-agent2-plugins.repo 
[zabbix-agent2-plugins]
name=Zabbix Official Repository (Agent2 Plugins) - $basearch
baseurl=https://mirrors.aliyun.com/zabbix/zabbix-agent2-plugins/1/rhel/8/$basearch/
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX
gpgcheck=0

1.1 检查一下软件源更改后有没有问题。

[root@westos_student50 ~]# dnf clean all
Updating Subscription Management repositories.
Unable to read consumer identity
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
12 files removed

[root@zabbix1 ~]# yum makecache 
Updating Subscription Management repositories.
Unable to read consumer identity
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Repository AppStream is listed more than once in the configuration
baseos 2.7 MB/s | 2.8 kB 00:00 
Zabbix Official Repository (Agent2 Plugins) - x86_64 15 kB/s | 2.9 kB 00:00 
Zabbix Official Repository - x86_64    13 kB/s | 2.9 kB 00:00 
Zabbix Official Repository (non-supported) - x86_64 14 kB/s | 3.0 kB 00:00

2.  安装Zabbix server,Web前端及agent。

[root@zabbix1 ~]# yum install zabbix-server-mysql zabbix-web-mysql zabbix-apache-conf zabbix-sql-scripts zabbix-selinux-policy zabbix-agent
Updating Subscription Management repositories.
Unable to read consumer identity
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Last metadata expiration check: 0:00:25 ago on Fri 21 Apr 2023 03:32:35 PM CST.
Dependencies resolved.
=====================================================================================================================================================================================
Package Architecture Version Repository Size
=====================================================================================================================================================================================
Installing:
zabbix-agent x86_64 6.0.16-release1.el8 zabbix 556 k
zabbix-apache-conf noarch 6.0.16-release1.el8 zabbix 25 k
zabbix-selinux-policy x86_64 6.0.16-release1.el8 zabbix 297 k
......

3. 安装数据库,设置开机自启。

[root@zabbix1 ~]# yum install mysql* -y    (这里因为会用到的数据库模块比较多,所以建议都下载下来)
Updating Subscription Management repositories.
Unable to read consumer identity
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Last metadata expiration check: 0:02:15 ago on Fri 21 Apr 2023 03:32:35 PM CST.
Dependencies resolved.
=====================================================================================================================================================================================
Package Architecture Version Repository Size
=====================================================================================================================================================================================
Installing:
mysql x86_64 8.0.17-3.module+el8.0.0+3898+e09bb8de AppStream 11 M
mysql-common x86_64 8.0.17-3.module+el8.0.0+3898+e09bb8de AppStream 143 k
mysql-devel x86_64 8.0.17-3.module+el8.0.0+3898+e09bb8de AppStream 147 k
mysql-errmsg x86_64 8.0.17-3.module+el8.0.0+3898+e09bb8de AppStream 557 k
mysql-libs x86_64 8.0.17-3.module+el8.0.0+3898+e09bb8de AppStream 1.2 M
mysql-server x86_64 8.0.17-3.module+el8.0.0+3898+e09bb8de AppStream 22 M
mysql-test x86_64 8.0.17-3.module+el8.0.0+3898+e09bb8de AppStream 132 M
Installing dependencies:
......
[root@zabbix1 ~]# systemctl enable --now mysqld   ##开机自启
Created symlink /etc/systemd/system/multi-user.target.wants/mysqld.service → /usr/lib/systemd/system/mysqld.service.

4. 创建初始数据库

[root@zabbix1 ~]# mysql_secure_installation   ##初始化数据库

Securing the MySQL server deployment.

Connecting to MySQL using a blank password.

VALIDATE PASSWORD COMPONENT can be used to test passwords
and improve security. It checks the strength of password
and allows the users to set only those passwords which are
secure enough. Would you like to setup VALIDATE PASSWORD component?

Press y|Y for Yes, any other key for No: 
Please set the password for root here.

New password:     ##设置密码,注意数据库自带了密码校验插件,所以密码要设置成大小写特殊符号加数字一共要超过八位

Re-enter new password:      ##确认密码
By default, a MySQL installation has an anonymous user,
allowing anyone to log into MySQL without having to have
a user account created for them. This is intended only for
testing, and to make the installation go a bit smoother.
You should remove them before moving into a production
environment.

Remove anonymous users? (Press y|Y for Yes, any other key for No) : y
Success.

Normally, root should only be allowed to connect from
'localhost'. This ensures that someone cannot guess at
the root password from the network.

Disallow root login remotely? (Press y|Y for Yes, any other key for No) : y
Success.

By default, MySQL comes with a database named 'test' that
anyone can access. This is also intended only for testing,
and should be removed before moving into a production
environment.

Remove test database and access to it? (Press y|Y for Yes, any other key for No) : y
- Dropping test database...
Success.

- Removing privileges on test database...
Success.

Reloading the privilege tables will ensure that all changes
made so far will take effect immediately.

Reload privilege tables now? (Press y|Y for Yes, any other key for No) : y
Success.

All done! 
[root@zabbix1 ~]# mysql -uroot -p    ##登录初始化后的数据库
Enter password: 
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 10
Server version: 8.0.17 Source distribution

Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> create database zabbix character set utf8mb4 collate utf8mb4_bin;    ##创建zabbix数据库字符使用utf8mb4
Query OK, 1 row affected (0.00 sec)

mysql> create user zabbix@localhost identified by 'Yinshuai+001'    ##创建zabbix用户使其可以在本地登录,设置密码
-> ;
Query OK, 0 rows affected (0.00 sec)

mysql> grant all privileges on zabbix.* to zabbix@localhost;    ##授予其所有权限
Query OK, 0 rows affected (0.01 sec)

mysql> set global log_bin_trust_function_creators = 1;    ##可以不加这一条,含义是可以创建或修改存储函数
Query OK, 0 rows affected (0.00 sec)

mysql> quit   ##退出数据库
Bye

5. 导入初始架构和数据。

[root@zabbix1 ~]# zcat /usr/share/zabbix-sql-scripts/mysql/server.sql.gz | mysql --default-character-set=utf8mb4 -uzabbix -p zabbix    ##这里-p后面的zabbix不是密码它代表数据库的意思
Enter password:   ##输入刚才建立的数据库的密码,导入数据可能要等一会
[root@zabbix1 ~]# mysql -uroot -p  ##登入数据库查看导入情况
Enter password: 
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 12
Server version: 8.0.17 Source distribution

Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> set global log_bin_trust_function_creators = 0;
Query OK, 0 rows affected (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 |
| auditlog |
| 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_page |
| 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 |
| ha_node |
| 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 |
| httptest_tag |
| httptestitem |
| icon_map |
| icon_mapping |
| ids |
| images |
| interface |
| interface_discovery |
| interface_snmp |
| item_condition |
| item_discovery |
| item_parameter |
| item_preproc |
| item_rtdata |
| item_tag |
| items |
| 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 |
| 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 |
| report |
| report_param |
| report_user |
| report_usrgrp |
| rights |
| role |
| role_rule |
| script_param |
| scripts |
| service_alarms |
| service_problem |
| service_problem_tag |
| service_status_rule |
| service_tag |
| services |
| services_links |
| sessions |
| sla |
| sla_excluded_downtime |
| sla_schedule |
| sla_service_tag |
| sysmap_element_trigger |
| sysmap_element_url |
| sysmap_shape |
| sysmap_url |
| sysmap_user |
| sysmap_usrgrp |
| sysmaps |
| sysmaps_element_tag |
| 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 |
| token |
| trends |
| trends_uint |
| trigger_depends |
| trigger_discovery |
| trigger_queue |
| trigger_tag |
| triggers |
| users |
| users_groups |
| usrgrp |
| valuemap |
| valuemap_mapping |
| widget |
| widget_field |
+----------------------------+
173 rows in set (0.01 sec)

mysql> quit
Bye

6.为Zabbix server配置数据库,编辑配置文件 /etc/zabbix/zabbix_server.conf。

[root@zabbix1 ~]# vim /etc/zabbix/zabbix_server.conf
......
129 DBPassword=xxxxxxxx   ##修改成你自己数据库的密码
......

7.启动Zabbix server和agent进程,并设置开机自启。

[root@westos_student50 ~]# systemctl enable --now zabbix-server zabbix-agent httpd php-fpm
Created symlink /etc/systemd/system/multi-user.target.wants/zabbix-server.service → /usr/lib/systemd/system/zabbix-server.service.
Created symlink /etc/systemd/system/multi-user.target.wants/zabbix-agent.service → /usr/lib/systemd/system/zabbix-agent.service.
Created symlink /etc/systemd/system/multi-user.target.wants/httpd.service → /usr/lib/systemd/system/httpd.service.
Created symlink /etc/systemd/system/multi-user.target.wants/php-fpm.service → /usr/lib/systemd/system/php-fpm.service.
Job for zabbix-server.service failed because the control process exited with error code.
See "systemctl status zabbix-server.service" and "journalctl -xe" for details.

7. 1  在做到这最后启动进程的时候,发现报错了。以为是配置文件写错了,又去检查了一遍,发现没错呀。最后查看日志才发现是net-snmp-libs这个软件包版本太低了。所以要去阿里云又下载了Centos的源,更新这个软件包。

7.1.1 查看日志报错。

[root@zabbix1 ~]/usr/sbin/zabbix_server -c /etc/zabbix/zabbix-server.conf
/usr/sbin/zabbix_server: undefined symbol: usmAES192PrivProtocol   ##原因是CentOS8环境下自带的net-snmp-libs版本太低,不支持usmAES192 privacy protocol
7.1.2 到阿里云下载Centos的源。
[root@zabbix1 ~]# wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-vault-8.5.2111.repo
--2023-04-21 15:50:04-- https://mirrors.aliyun.com/repo/Centos-vault-8.5.2111.repo
Resolving mirrors.aliyun.com (mirrors.aliyun.com)... 150.139.249.205, 150.139.156.190, 150.139.249.201, ...
Connecting to mirrors.aliyun.com (mirrors.aliyun.com)|150.139.249.205|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 2495 (2.4K) [application/octet-stream]
Saving to: ‘/etc/yum.repos.d/CentOS-Base.repo’

/etc/yum.repos.d/CentOS-Base.repo 100%[==============================================================================================>] 2.44K --.-KB/s in 0.007s

2023-04-21 15:50:04 (360 KB/s) - ‘/etc/yum.repos.d/CentOS-Base.repo’ saved [2495/2495]

[root@westos_student50 ~]# yum makecache  ##查看下载的源有没有问题
Updating Subscription Management repositories.
Unable to read consumer identity
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Repository AppStream is listed more than once in the configuration
CentOS-8.5.2111 - Base - mirrors.aliyun.com 438 kB/s | 4.6 MB 00:10 
CentOS-8.5.2111 - Extras - mirrors.aliyun.com 37 kB/s | 10 kB 00:00 
CentOS-8.5.2111 - AppStream - mirrors.aliyun.com 375 kB/s | 8.4 MB 00:23 
baseos 2.1 MB/s | 2.8 kB 00:00 
Zabbix Official Repository (Agent2 Plugins) - x86_64 12 kB/s | 2.9 kB 00:00 
Zabbix Official Repository - x86_64 11 kB/s | 2.9 kB 00:00 
Zabbix Official Repository (non-supported) - x86_64 16 kB/s | 3.0 kB 00:00 
Metadata cache created.

7.1.3 升级net-snmp-libs.x86_64包。

[root@zabbix1 ~]# yum update net-snmp-libs.x86_64   -y
Updating Subscription Management repositories.
Unable to read consumer identity
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Repository AppStream is listed more than once in the configuration
Last metadata expiration check: 0:00:30 ago on Fri 21 Apr 2023 03:50:45 PM CST.
Dependencies resolved.
=====================================================================================================================================================================================
Package Architecture Version Repository Size
=====================================================================================================================================================================================
Upgrading:
net-snmp-libs x86_64 1:5.8-22.el8 base 827 k

Transaction Summary
......
7.1.4 升级后查看是否支持usmAES192CiscoPrivProtocol
[root@zabbix1 ~]# nm -D /lib64/libnetsnmp.so.35 |grep -i aes
U EVP_aes_128_cfb128
U EVP_aes_192_cfb128
U EVP_aes_256_cfb128
00000000002e5560 D usmAES128PrivProtocol
00000000002e4ec0 D usmAES192CiscoPrivProtocol    ##更新后支持usmAES192CiscoPrivProtocol
00000000002e4f80 D usmAES192PrivProtocol
00000000002e4e60 D usmAES256CiscoPrivProtocol
00000000002e4f20 D usmAES256PrivProtocol
00000000002e4fe0 D usmAESPrivProtocol
000000000009f1e0 T usm_set_aes_iv
8. 重新启动Zabbix server和agent进程,设置开机自启
[root@zabbix1 ~]# systemctl enable --now zabbix-server zabbix-agent httpd php-fpm
[root@zabbix1 ~]# systemctl status zabbix-server.service   ##查看zabbix服务已经开启
● zabbix-server.service - Zabbix Server
Loaded: loaded (/usr/lib/systemd/system/zabbix-server.service; enabled; vendor preset: disabled)
Active: active (running) since Fri 2023-04-21 15:51:24 CST; 1min 1s ago
Main PID: 39969 (zabbix_server)
Tasks: 48 (limit: 23664)
Memory: 44.5M
CGroup: /system.slice/zabbix-server.service
├─39969 /usr/sbin/zabbix_server -c /etc/zabbix/zabbix_server.conf
9. 在浏览器IP/zabbix访问,做基本的前端设置,登录zabblx。
9.1 选择语言中文。
9.2 查看组件是否设置ok。
9.3 输入数据库密码(其他不做更改)。
9.4 输入主机名称,更改时区为Asia/Shanghai。
9.5  到这一步前面错的还可以更改,点击确定后数据库的信息更改就比较麻烦了。
9.6 点击确定后前端的信息就设置完成了。
9.7 输入账号密码后登录zabbix(账号Admin密码zabbix是初始化数据库的时候就直接导入的)
10.  至此就安装部署成功啦!!!

云野 » Zabbix安装部署

发表回复