目录
一.准备数据库服务
1.下载进入mysql
2.创建zabbix用户和权限
3.引入初始数据库
二.部署zabbix-server
1.下载软件
2.为zabbix配置数据库
3.配置前端和php
4.修改本设备的Server、ServerActive、Hostname(选做)
三.浏览器测试
1.填写注册信息
2.登录
四.手动添加主机
1.主机配置
2.页面操作
五.为主机添加监控项
1.本步骤完成后的样式
2.查看资源表
主机信息
main-192.168.2.130
servera-192.168.2.131
serverb-192.168.2.132
一.准备数据库服务
1.下载进入mysql
[root@main ~ ]#tar -xvf mysql-5.7.43-1.el7.x86_64.rpm-bundle.tar -C /usr/local/src/
[root@main src]# ll
total 557208
-rw-r--r-- 1 7155 31415 32652444 Jun 22 2023 mysql-community-client-5.7.43-1.el7.x86_64.rpm
-rw-r--r-- 1 7155 31415 320780 Jun 22 2023 mysql-community-common-5.7.43-1.el7.x86_64.rpm
-rw-r--r-- 1 7155 31415 4969828 Jun 22 2023 mysql-community-devel-5.7.43-1.el7.x86_64.rpm
-rw-r--r-- 1 7155 31415 48586584 Jun 22 2023 mysql-community-embedded-5.7.43-1.el7.x86_64.rpm
-rw-r--r-- 1 7155 31415 23314208 Jun 22 2023 mysql-community-embedded-compat-5.7.43-1.el7.x86_64.rpm
-rw-r--r-- 1 7155 31415 134413980 Jun 22 2023 mysql-community-embedded-devel-5.7.43-1.el7.x86_64.rpm
-rw-r--r-- 1 7155 31415 3091092 Jun 22 2023 mysql-community-libs-5.7.43-1.el7.x86_64.rpm
-rw-r--r-- 1 7155 31415 1266220 Jun 22 2023 mysql-community-libs-compat-5.7.43-1.el7.x86_64.rpm
-rw-r--r-- 1 7155 31415 193030448 Jun 22 2023 mysql-community-server-5.7.43-1.el7.x86_64.rpm
-rw-r--r-- 1 7155 31415 128921364 Jun 22 2023 mysql-community-test-5.7.43-1.el7.x86_64.rpm
[root@main src]# yum localinstall mysql* -y #本地安装
systemctl start mysqld
[root@main src]# grep password /var/log/mysqld.log
2024-04-12T11:55:24.321030Z 1 [Note] A temporary password is generated for root@localhost: snkr(j;B!4gZ
[root@main src]# mysql -uroot -p #使用临时密码登录
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1216
Server version: 5.7.43 MySQL Community Server (GPL)
Copyright (c) 2000, 2023, Oracle and/or its affiliates.
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> alter user 'root'@'localhost' identified by 'Slb@317418'; #登录过后更改root密码
2.创建zabbix用户和权限
mysql> create database zabbix character set utf8 collate utf8_bin;
mysql> create user zabbix@localhost identified by 'Slb@317418';
mysql> grant all privileges on zabbix.* to zabbix@localhost;
mysql> set global log_bin_trust_function_creators = 1;
mysql> exit;
[root@main doc]# cd zabbix-server-mysql-5.0.42/
[root@main zabbix-server-mysql-5.0.42]# ll
total 3260
-rw-r--r-- 1 root root 98 Mar 25 18:10 AUTHORS
-rw-r--r-- 1 root root 1255502 Mar 25 18:10 ChangeLog
-rw-r--r-- 1 root root 17990 Mar 25 18:10 COPYING
-rw-r--r-- 1 root root 2040341 Mar 25 18:12 create.sql.gz
-rw-r--r-- 1 root root 282 Mar 25 18:10 double.sql
-rw-r--r-- 1 root root 52 Mar 25 18:10 NEWS
-rw-r--r-- 1 root root 1322 Mar 25 18:10 README
3.引入初始数据库
[root@main doc]# zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -uzabbix -p zabbix
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 |
| 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)
mysql> set global log_bin_trust_function_creators = 0;
mysql> exit;
二.部署zabbix-server
参照官网步骤进行下载Zabbix
1.下载软件
[root@main ~]# rpm -Uvh https://repo.zabbix.com/zabbix/5.0/rhel/7/x86_64/zabbix-release-5.0-1.el7.noarch.rpm && yum clean all
[root@main ~]# yum install zabbix-server-mysql zabbix-agent centos-release-scl
# 安装Zabbix server,Web前端,agent,frontend
[root@main ~]# vim /etc/yum.repos.d/zabbix.repo #将zabbix的前端仓库打开
[root@main ~]# yum install zabbix-web-mysql-scl zabbix-nginx-conf-scl
2.为zabbix配置数据库
[root@main ~]# vim /etc/zabbix/zabbix_server.conf #配置好zabbix用户密码
3.配置前端和php
[root@main ~]# vim /etc/opt/rh/rh-nginx116/nginx/conf.d/zabbix.conf #选用8080端口
[root@main ~]# vim /etc/opt/rh/rh-php72/php-fpm.d/zabbix.conf #添加nginx,更改时区为上海
[root@main ~]# systemctl restart zabbix-server zabbix-agent rh-nginx116-nginx rh-php72-php-fpm
[root@main ~]# systemctl enable zabbix-server zabbix-agent rh-nginx116-nginx rh-php72-php-fpm
4.修改本设备的Server、ServerActive、Hostname(选做)
[root@main ~]# vim /etc/zabbix/zabbix_agentd.conf
Server-192.168.2.130
ServerActive-192.168.2.130
Hostname-main
三.浏览器测试
没有注释nginx中的“location /”的话应该是IP:8080/zabbix/setup.php
我这注释了就直接IP:8080跳转到setup.php了
1.填写注册信息
初始用户名和密码是Admin和zabbix
2.登录
在用户设置处修改密码、语言、主题颜色等
四.手动添加主机
servera和serverb同样操作
1.主机配置
[root@main ~]# scp /etc/yum.repos.d/zabbix.repo servera:/etc/yum.repos.d/
[root@main ~]# scp /etc/yum.repos.d/zabbix.repo serverb:/etc/yum.repos.d/
[root@servera ~]# vim /etc/yum.repos.d/zabbix.repo #修改仓库
[root@servera ~]# yum install -y zabbix-agent2.x86_64
[root@servera ~]# vim /etc/zabbix/zabbix_agentd.conf #将Server和ServerActive修改为main的地址,Hostname修改为servera/serverb自己的hostname,和后面再面板上添加主机名称一致
[root@servera ~]# cat /etc/zabbix/zabbix_agentd.conf | grep Server=192
Server=192.168.2.130
[root@servera ~]# cat /etc/zabbix/zabbix_agentd.conf | grep ServerActive=192
ServerActive=192.168.2.130
[root@servera ~]# cat /etc/zabbix/zabbix_agentd.conf | grep Hostname=
# Hostname=
Hostname=servera
[root@serverb ~]# cat /etc/zabbix/zabbix_agentd.conf | grep Server=192
Server=192.168.2.130
[root@serverb ~]# cat /etc/zabbix/zabbix_agentd.conf | grep ServerActive=192
ServerActive=192.168.2.130
[root@serverb ~]# cat /etc/zabbix/zabbix_agentd.conf | grep Hostname=
# Hostname=
Hostname=serverb
2.页面操作
配置->主机->创建主机,填充你主机的名称、IP、端口->添加完成
五.为主机添加监控项
1.本步骤完成后的样式
点击主机名进入配置
点击模版
链接模版并进行更新应用