zabbix5.0版本(安装部署+添加服务器+拆分数据库)

devtools/2024/12/31 18:29:33/

目录

1.监控内容

2.监控工具

3.Zabbix安装

4.Zabbix添加监控服务器

5.拆分数据库


本篇文章介绍zabbix监控监控是对我们操作系统进行不间断的监控,这是软件生命周期非常重要的一环,可以做到事前告警,事后根据监控内容排查问题(金丝雀,监控重要指标),有问题的时候,运维需要管理运维债务(在软件开发过程中积累的一些技术债务)

1.监控内容

我们需要监控硬件(磁盘df -h,内存free,磁盘IO,负载CPU,网络),软件服务(端口、进程、状态),业务层面(监控业务数据,订单量,注册用户,充值用户),只要是有值,zabbix都能监控,核心功能就是自定义监控

2.监控工具

zabbix 硬件 服务状态 自定义监控

Nagions 网络产品 交换机 路由器 中型大型公司使用

Cacti 流量

Open-Falcon 小米公司自研

prometheus 监控kubernetes docker,比zabbix更好

监控宝等等

3.Zabbix安装

服务端:10.0.0.71(配置与监控数量有关,企业中一般是8G内存,4核或6核)

客户端:10.0.0.7,10.0.0.8

系统版本为CentOS7.9

(1)配置yum源

rpm -Uvh https://repo.zabbix.com/zabbix/5.0/rhel/7/x86_64/zabbix-release-5.0-1.el7.noarch.rpm
yum clean all

(2)安装zabbix服务

yum -y install zabbix-server-mysql zabbix-agent

(3)安装scl源,更好的兼容已经安装的软件包,避免把系统搞烂

yum -y install centos-release-scl

(4)开启前端的仓库

[root@Zabbix ~]# cat /etc/yum.repos.d/zabbix.repo
[zabbix]
name=Zabbix Official Repository - $basearch
baseurl=http://repo.zabbix.com/zabbix/5.0/rhel/7/$basearch/
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX-A14FE591[zabbix-frontend]
name=Zabbix Official Repository frontend - $basearch
baseurl=http://repo.zabbix.com/zabbix/5.0/rhel/7/$basearch/frontend
enabled=1            #开这里
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX-A14FE591[zabbix-debuginfo]
name=Zabbix Official Repository debuginfo - $basearch
baseurl=http://repo.zabbix.com/zabbix/5.0/rhel/7/$basearch/debuginfo/
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX-A14FE591
gpgcheck=1[zabbix-non-supported]
name=Zabbix Official Repository non-supported - $basearch
baseurl=http://repo.zabbix.com/non-supported/rhel/7/$basearch/
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX
gpgcheck=1

(5)安装php和apache前端

 yum -y install zabbix-web-mysql-scl zabbix-apache-conf-scl

(6)安装mariadb

yum -y install mariadb-server
systemctl start mariadb
systemctl enable mariadb

(7)配置zabbix数据库

[root@Zabbix ~]# mysql -uroot
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 2
Server version: 5.5.68-MariaDB MariaDB ServerCopyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.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 'zabbix';
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)]> set global log_bin_trust_function_creators = 1;
Query OK, 0 rows affected (0.00 sec)MariaDB [(none)]> quit;
Bye

(8)导入数据库,初始化数据

[root@Zabbix ~]# zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -uzabbix -p zabbix
Enter password: zabbix

检查是否成功

[root@Zabbix ~]# mysql -uroot
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 5
Server version: 5.5.68-MariaDB MariaDB ServerCopyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.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 -ADatabase 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)

(9)配置数据库

[root@Zabbix ~]# mysql -uroot
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 8
Server version: 5.5.68-MariaDB MariaDB ServerCopyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.MariaDB [(none)]> set global log_bin_trust_function_creators = 0;
Query OK, 0 rows affected (0.00 sec)MariaDB [(none)]> quit
Bye

(10)修改zabbix连接数据库的信息

[root@Zabbix ~]# egrep ^DB /etc/zabbix/zabbix_server.conf
DBName=zabbix
DBUser=zabbix
DBPassword=zabbix    #取消注释

(11)修改时区

[root@Zabbix ~]# tail -1 /etc/opt/rh/rh-php72/php-fpm.d/zabbix.conf
php_value[date.timezone] = Asia/Shanghai

(12)启动zabbix进程

[root@Zabbix ~]# systemctl restart zabbix-server zabbix-agent httpd rh-php72-php-fpm
[root@Zabbix ~]# systemctl enable zabbix-server zabbix-agent httpd rh-php72-php-fpm

(13)浏览器访问

(14)修改语言为中文

(15)修改乱码

上传windows字体到zabbix

[root@Zabbix ~]# cd /usr/share/fonts/dejavu
[root@Zabbix dejavu]# ll
total 5288
-rw-r--r-- 1 root root 611212 Feb 27  2011 DejaVuSans-BoldOblique.ttf
-rw-r--r-- 1 root root 672300 Feb 27  2011 DejaVuSans-Bold.ttf
-rw-r--r-- 1 root root 580168 Feb 27  2011 DejaVuSansCondensed-BoldOblique.ttf
-rw-r--r-- 1 root root 631992 Feb 27  2011 DejaVuSansCondensed-Bold.ttf
-rw-r--r-- 1 root root 576004 Feb 27  2011 DejaVuSansCondensed-Oblique.ttf
-rw-r--r-- 1 root root 643852 Feb 27  2011 DejaVuSansCondensed.ttf
-rw-r--r-- 1 root root 345204 Feb 27  2011 DejaVuSans-ExtraLight.ttf
-rw-r--r-- 1 root root 611556 Feb 27  2011 DejaVuSans-Oblique.ttf
-rw-r--r-- 1 root root 720012 Feb 27  2011 DejaVuSans.ttf
[root@Zabbix dejavu]# rz -E
rz waiting to receive.
[root@Zabbix dejavu]# mv DejaVuSans.ttf DejaVuSans.ttf.bak
[root@Zabbix dejavu]# mv simhei.ttf DejaVuSans.ttf

4.Zabbix添加监控服务器

(1)安装zabbix-agent客户端,准备一台服务器10.0.0.7

#配置yum仓库
rpm -ivh https://mirrors.aliyun.com/zabbix/zabbix/5.0/rhel/7/x86_64/zabbix-agent-5.0.34-1.el7.x86_64.rpm
#解决软件冲突
yum -y install centos-release-scl
#安装客户端agent
yum -y install zabbix-agent

(2)配置zabbix客户端服务器信息,启动服务端

[root@Web01 yum.repos.d]# cat /etc/zabbix/zabbix_agentd.conf
Server=172.16.1.71
[root@Web01 yum.repos.d]# systemctl start zabbix-agent

(3)zabbix监控web01

5.拆分数据库

(1)准备一台数据库服务器10.0.0.51安装mariadb

[root@DB01 ~]# yum -y install mariadb-server
[root@DB01 ~]# systemctl start mariadb
[root@DB01 ~]# systemctl enable mariadb
[root@DB01 ~]# mysql
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 2
Server version: 5.5.68-MariaDB MariaDB ServerCopyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.MariaDB [(none)]> create database zabbix character set utf8 collate utf8_bin;
Query OK, 1 row affected (0.00 sec)MariaDB [(none)]> create user 'zabbix'@'%' identified by 'zabbix';
Query OK, 0 rows affected (0.00 sec)MariaDB [(none)]> grant all privileges on zabbix.* to 'zabbix'@'%';
Query OK, 0 rows affected (0.00 sec)MariaDB [(none)]> quit
Bye

(2)导出zabbix服务器zabbix数据库,导入到新的数据库

[root@Zabbix ~]# mysqldump -uroot -B zabbix > zabbix.sql
[root@Zabbix ~]# cat zabbix.sql |mysql -h 172.16.1.51 -uzabbix -pzabbix zabbix

(3)配置WEB连接数据库信息并重启服务

[root@Zabbix ~]# cat /etc/zabbix/web/zabbix.conf.php
<?php
// Zabbix GUI configuration file.$DB['TYPE']				= 'MYSQL';
$DB['SERVER']			= '172.16.1.51';
$DB['PORT']				= '3306';
$DB['DATABASE']			= 'zabbix';
$DB['USER']				= 'zabbix';
$DB['PASSWORD']			= 'zabbix';
......
[root@Zabbix ~]# grep ^DB /etc/zabbix/zabbix_server.conf 
DBHost=172.16.1.51
DBName=zabbix
DBUser=zabbix
DBPassword=zabbix
[root@Zabbix ~]# systemctl restart zabbix-server httpd

http://www.ppmy.cn/devtools/146247.html

相关文章

在线免费批量生成 Word 文档工具

为了方便的批量生成 Word 文档&#xff0c;写了个在线 Word 文档批量生成工具&#xff0c;可以根据 Excel 数据和 Word 模板批量生成大量个性化的 Word 文档。适用于需要批量生成格式统一但内容不同的文档场景。比如&#xff1a; 批量生成证书、奖状批量生成合同、协议批量生成…

计算机故障找不到x3daudio1_7.dll怎么解决?

x3daudio1_7.dll 是一个动态链接库&#xff08;Dynamic Link Library&#xff0c;简称DLL&#xff09;文件&#xff0c;属于 Microsoft DirectX 组件的一部分。DirectX 是微软公司开发的一系列多媒体编程接口&#xff0c;广泛应用于游戏和多媒体应用程序中&#xff0c;以提供高…

SpringMVC详解

文章目录 1 什么是MVC 1.1 MVC设计思想1.2 Spring MVC 2 SpringMVC快速入门3 SpringMVC处理请求 3.1 请求分类及处理方式 3.1.1 静态请求3.1.2 动态请求 3.2 处理静态请求 3.2.1 处理html文件请求3.2.2 处理图片等请求 3.3 处理动态请求 3.3.1 注解说明3.3.2 示例 3.4 常见问题…

Docker-如何启动docker

作者介绍&#xff1a;简历上没有一个精通的运维工程师。希望大家多多关注作者&#xff0c;下面的思维导图也是预计更新的内容和当前进度(不定时更新)。 我们在上一章&#xff0c;讲了虚拟化&#xff0c;虚拟化是把硬件虚拟化&#xff0c;然后创建出来的虚拟机完全隔离&#xff…

基于Spring Boot的手机卡销售系统的设计与实现

博主介绍&#xff1a;java高级开发&#xff0c;从事互联网行业六年&#xff0c;熟悉各种主流语言&#xff0c;精通java、python、php、爬虫、web开发&#xff0c;已经做了多年的设计程序开发&#xff0c;开发过上千套设计程序&#xff0c;没有什么华丽的语言&#xff0c;只有实…

微信V3支付报错 平台证书及平台证书序列号

1.平台证书及平台证书序列号设置错误报错&#xff1a; 错误1&#xff1a; Verify the response’s data with: timestamp1735184656, noncea5806b8cabc923299f8db1a174f3a4d0, signatureFZ5FgD/jtt4J99GKssKWKA/0buBSOAbWcu6H52l2UqqaJKvrsNxvodB569ZFz5G3fbassOQcSh5BFq6hvE…

C++软件设计模式之外观(Facade)模式

C软件设计模式中的外观&#xff08;Facade&#xff09;模式 1. 外观模式的定义 外观模式&#xff08;Facade Pattern&#xff09;是一种结构型设计模式&#xff0c;它为一个复杂的子系统提供一个简化的接口。外观模式通过一个统一的接口来访问子系统的多个组成部分&#xff0…

在交叉编译中,常见的ELF(elf)到底是什么意思?

ELF 是 Executable and Linkable Format 的缩写&#xff0c;中文翻译为“可执行与可链接格式”。它是一种通用的文件格式&#xff0c;主要用于存储可执行文件、目标文件&#xff08;编译后的中间文件&#xff09;、动态库&#xff08;.so 文件&#xff09;以及内存转储文件&…