帮助文档
专业提供香港服务器、香港云服务器、香港高防服务器租用、香港云主机、台湾服务器、美国服务器、美国云服务器vps租用、韩国高防服务器租用、新加坡服务器、日本服务器租用 一站式全球网络解决方案提供商!专业运营维护IDC数据中心,提供高质量的服务器托管,服务器机房租用,服务器机柜租用,IDC机房机柜租用等服务,稳定、安全、高性能的云端计算服务,实时满足您的多样性业务需求。 香港大带宽稳定可靠,高级工程师提供基于服务器硬件、操作系统、网络、应用环境、安全的免费技术支持。
服务器资讯 / 香港服务器租用 / 香港VPS租用 / 香港云服务器 / 美国服务器租用 / 台湾服务器租用 / 日本服务器租用 / 官方公告 / 帮助文档
【运维知识进阶篇】zabbix5.0稳定版详解1(安装+部署+添加服务器+拆分数据库)
发布时间:2024-02-29 11:22:43   分类:帮助文档
【运维知识进阶篇】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 Server

Copyright (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 Server

Copyright (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 -A

Database 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 Server

Copyright (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

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


 
拆分数据库
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 Server

Copyright (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
// 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年运维经验,持续分享运维干货,感谢大家的阅读和关注!
 


香港云服务器租用推荐
服务器租用资讯
·广东云服务有限公司怎么样
·广东云服务器怎么样
·广东锐讯网络有限公司怎么样
·广东佛山的蜗牛怎么那么大
·广东单位电话主机号怎么填写
·管家婆 花生壳怎么用
·官网域名过期要怎么办
·官网邮箱一般怎么命名
·官网网站被篡改怎么办
服务器租用推荐
·美国服务器租用
·台湾服务器租用
·香港云服务器租用
·香港裸金属服务器
·香港高防服务器租用
·香港服务器租用特价