Zabbix5部署并添加主机

目录

一.准备数据库服务

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.本步骤完成后的样式

点击主机名进入配置

点击模版

 

链接模版并进行更新应用

 

2.查看资源表

  • 5
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
Zabbix是一款使用广泛的开源网络管理工具,它可以帮助用户监控和管理网络设备、服务器和应用程序。下面将详细介绍如何搭建和部署Zabbix: 1. 安装所需软件:在服务器上安装所需的软件,包括Apache、PHP和MySQL。 2. 下载和解压Zabbix软件包:从Zabbix官方网站上下载适合您服务器操作系统的Zabbix软件包,并将其解压到您选择的目录中。 3. 创建数据库:使用MySQL或其他数据库管理系统创建一个新的数据库,用于存储Zabbix的数据。 4. 导入数据库模板:使用提供的数据库模板将初始数据导入到之前创建的数据库中。 5. 配置Zabbix服务器:编辑Zabbix服务器配置文件,设置数据库连接参数,并指定日志文件和其他选项。 6. 启动Zabbix服务器:启动Zabbix服务器,并检查日志文件以确保服务器正常运行。 7. 配置Zabbix前端:将Zabbix前端文件复制到您选择的Web服务器(通常是Apache)的公共目录中,并确保Web服务器可以访问这些文件。 8. 访问Zabbix前端:在Web浏览器中使用指定的URL访问Zabbix前端。您将在这里设置默认管理员用户名和密码。 9. 添加主机:在Zabbix前端中,添加要监视的主机。提供主机的名称、IP地址和其他必要的信息。 10. 配置监控项:为每个主机设置要监控的不同指标,例如CPU使用率、内存使用量等。 11. 创建触发器和动作:为每个关注的指标创建触发器,并为触发器设置相应的动作,例如发送电子邮件通知。 12. 观察监控数据:通过Zabbix前端查看和分析收集到的监控数据,以便及时了解主机和应用程序的状态。 通过按照上述步骤搭建和部署Zabbix,您将能够有效地监控和管理网络环境,并及时采取行动来解决任何问题。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

树下一少年

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值