【运维知识进阶篇】zabbix5.0稳定版详解1(安装+部署+添加服务器+拆分数据库)

本文主要是介绍【运维知识进阶篇】zabbix5.0稳定版详解1(安装+部署+添加服务器+拆分数据库),希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

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

目录

监控内容

监控工具

Zabbix安装

1、配置yum源

2、安装zabbix服务

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

4、开启前端的仓库

5、安装php和apache前端 

6、安装mariadb

7、配置zabbix数据库

8、导入数据库,初始化数据

9、再次配置数据库

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

11、修改时区

12、启动zabbix进程

13、浏览器访问安装

14、修改语言为中文

15、修改乱码 

Zabbix添加监控服务器

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

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

3、zabbix监控web01

拆分数据库

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

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

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


监控内容

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

监控工具

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

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

Cacti 流量

Open-Falcon 小米公司自研

prometheus 监控kubernetes docker,比zabbix更好

监控宝等等

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、浏览器访问安装

d9ef7e6a8ea44f1583dcbc919b785aa4.png

8a6b4309217244298875119a82ec9d2e.png

65202f38d84549ef8727ed25523b9266.png

e3e611e6934d4b72aeaf3110a643c136.png

 a83025ace364492f97b38d251922c5ba.png

5e8e0375b51943f9961ff59e9ebfae01.png

 8f407813a90549bdaef62d4752f1c0c5.png

14、修改语言为中文

87995ffbe4984603b59e3c5d7fc2d742.png

15、修改乱码 

上传windows字体到zabbix中

950977514e9f44688adb20c67db196c4.png

 

51029308cb6b4b8fbb3c295ce462e9c3.png

[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

ed5224229ed94326bcbd2c65bddf10f7.png

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

24d62e6d9144485a9a065c67e40c1832.png

faa8672c025a470d866ff03f791100be.png

fc8bc337317b4a159233214bd88ebadd.png 2256bc38b31547a095cc802050b5d031.png

拆分数据库

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

我是koten,10年运维经验,持续分享运维干货,感谢大家的阅读和关注!

 

这篇关于【运维知识进阶篇】zabbix5.0稳定版详解1(安装+部署+添加服务器+拆分数据库)的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/316169

相关文章

CSS will-change 属性示例详解

《CSSwill-change属性示例详解》will-change是一个CSS属性,用于告诉浏览器某个元素在未来可能会发生哪些变化,本文给大家介绍CSSwill-change属性详解,感... will-change 是一个 css 属性,用于告诉浏览器某个元素在未来可能会发生哪些变化。这可以帮助浏览器优化

Python基础文件操作方法超详细讲解(详解版)

《Python基础文件操作方法超详细讲解(详解版)》文件就是操作系统为用户或应用程序提供的一个读写硬盘的虚拟单位,文件的核心操作就是读和写,:本文主要介绍Python基础文件操作方法超详细讲解的相... 目录一、文件操作1. 文件打开与关闭1.1 打开文件1.2 关闭文件2. 访问模式及说明二、文件读写1.

Ubuntu中远程连接Mysql数据库的详细图文教程

《Ubuntu中远程连接Mysql数据库的详细图文教程》Ubuntu是一个以桌面应用为主的Linux发行版操作系统,这篇文章主要为大家详细介绍了Ubuntu中远程连接Mysql数据库的详细图文教程,有... 目录1、版本2、检查有没有mysql2.1 查询是否安装了Mysql包2.2 查看Mysql版本2.

Oracle数据库常见字段类型大全以及超详细解析

《Oracle数据库常见字段类型大全以及超详细解析》在Oracle数据库中查询特定表的字段个数通常需要使用SQL语句来完成,:本文主要介绍Oracle数据库常见字段类型大全以及超详细解析,文中通过... 目录前言一、字符类型(Character)1、CHAR:定长字符数据类型2、VARCHAR2:变长字符数

Win11安装PostgreSQL数据库的两种方式详细步骤

《Win11安装PostgreSQL数据库的两种方式详细步骤》PostgreSQL是备受业界青睐的关系型数据库,尤其是在地理空间和移动领域,:本文主要介绍Win11安装PostgreSQL数据库的... 目录一、exe文件安装 (推荐)下载安装包1. 选择操作系统2. 跳转到EDB(PostgreSQL 的

详解C++中类的大小决定因数

《详解C++中类的大小决定因数》类的大小受多个因素影响,主要包括成员变量、对齐方式、继承关系、虚函数表等,下面就来介绍一下,具有一定的参考价值,感兴趣的可以了解一下... 目录1. 非静态数据成员示例:2. 数据对齐(Padding)示例:3. 虚函数(vtable 指针)示例:4. 继承普通继承虚继承5.

前端高级CSS用法示例详解

《前端高级CSS用法示例详解》在前端开发中,CSS(层叠样式表)不仅是用来控制网页的外观和布局,更是实现复杂交互和动态效果的关键技术之一,随着前端技术的不断发展,CSS的用法也日益丰富和高级,本文将深... 前端高级css用法在前端开发中,CSS(层叠样式表)不仅是用来控制网页的外观和布局,更是实现复杂交

Linux换行符的使用方法详解

《Linux换行符的使用方法详解》本文介绍了Linux中常用的换行符LF及其在文件中的表示,展示了如何使用sed命令替换换行符,并列举了与换行符处理相关的Linux命令,通过代码讲解的非常详细,需要的... 目录简介检测文件中的换行符使用 cat -A 查看换行符使用 od -c 检查字符换行符格式转换将

SpringBoot实现数据库读写分离的3种方法小结

《SpringBoot实现数据库读写分离的3种方法小结》为了提高系统的读写性能和可用性,读写分离是一种经典的数据库架构模式,在SpringBoot应用中,有多种方式可以实现数据库读写分离,本文将介绍三... 目录一、数据库读写分离概述二、方案一:基于AbstractRoutingDataSource实现动态

使用Python实现快速搭建本地HTTP服务器

《使用Python实现快速搭建本地HTTP服务器》:本文主要介绍如何使用Python快速搭建本地HTTP服务器,轻松实现一键HTTP文件共享,同时结合二维码技术,让访问更简单,感兴趣的小伙伴可以了... 目录1. 概述2. 快速搭建 HTTP 文件共享服务2.1 核心思路2.2 代码实现2.3 代码解读3.