分布式应用:kylin 部署 zabbix 监控平台

本文详细描述了在Kylin环境中部署Zabbix监控平台的过程,包括修改MySQL数据库设置、配置zabbix服务器、Web界面调整,以及遇到的问题如查看版本错误、去除注释和空行、图表显示异常等,并提供了相应的解决方案和性能优化建议。
摘要由CSDN通过智能技术生成

目录

  一、实验

1.环境

2. kylin 修改mysql数据库

3. kylin 部署 zabbix 监控平台

4. kylin 修改 zabbix 配置

5. kylin 修改zabbix web

二、问题

1. zabbix_server 查看版本报错

2.zabbix_server 文件如何去掉注释"#"和空行

3. zabbix图表显示异常

4.zabbix-server如何进行性能优化配置

5. zabbix运行架构


  一、实验

1.环境

(1)主机

表1  主机

主机架构版本IP备注
kylin银河麒麟V10192.168.204.77 

mysql数据库8.0.18-1
zabbix监控6.0

(2)查看内核

麒麟4.X版本相当于 CentOS 8.X ,麒麟3.X版本相当于 CentOS 7.X

[root@kylin ~]# uname -r

2. kylin 修改mysql数据库

(1)查看

[root@kylin ~]# mysql -uroot -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 93
Server version: 8.0.18 MySQL Community Server - GPL

Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.

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> show databases;
+--------------------+
| Database           |
+--------------------+
| halodb             |
| information_schema |
| mysql              |
| performance_schema |
| sys                |
+--------------------+
5 rows in set (0.00 sec)

mysql> quit
Bye
[root@kylin ~]# 

(2)修改

zabbix需要mysql的缺省验证插件

[root@kylin ~]# vim /etc/my.cnf

修改前:

修改后:

(3)重启

[root@kylin ~]# systemctl restart mysqld

(4)创建zabbix初始数据库

创建数据库: zabbix

创建用户:zabbix

授权zabbix用户管理zabbix库 :  grant all privileges on zabbix.* to zabbix@localhost;

打开数据库函数功能 : set global log_bin_trust_function_creators = 1;

[root@kylin ~]# mysql -uroot -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.0.18 MySQL Community Server - GPL

Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.

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> create database zabbix character set utf8mb4 collate utf8mb4_bin;
Query OK, 1 row affected (0.01 sec)

mysql> create user zabbix@localhost identified by 'root@mySQL123'; 
Query OK, 0 rows affected (0.01 sec)

mysql> use mysql;
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> select user,plugin from user where user='zabbix';
+--------+-----------------------+
| user   | plugin                |
+--------+-----------------------+
| zabbix | mysql_native_password |
+--------+-----------------------+
1 row in set (0.00 sec)

mysql> grant all privileges on zabbix.* to zabbix@localhost;
Query OK, 0 rows affected (0.01 sec)

mysql> set global log_bin_trust_function_creators = 1;
Query OK, 0 rows affected (0.00 sec)

mysql> quit
Bye
[root@kylin ~]# 

3. kylin 部署 zabbix 监控平台

(1)zabbix官方仓库地址

Zabbix Official Repository

(2)选择仓库

(3)下载

[root@kylin opt]# wget https://repo.zabbix.com/zabbix/6.0/rhel/8/x86_64/zabbix-release-6.0-4.el8.noarch.rpm

(4)安装

[root@kylin opt]# rpm -ivh zabbix-release-6.0-4.el8.noarch.rpm 

(5)查看仓库

生成新repo

[root@kylin opt]# cd /etc/yum.repos.d/
[root@kylin yum.repos.d]# ll

(6)查看 zabbix repo

[root@kylin yum.repos.d]# more zabbix.repo 

(7) 安装

[root@kylin yum.repos.d]# dnf install zabbix-server-mysql zabbix-web-mysql zabbix-nginx-conf zabbix-sql-scripts zabbix-selinux-policy zabbix-agent

依次输入y 导入公钥

(8)查看

[root@kylin yum.repos.d]# ll /usr/share/zabbix-sql-scripts/mysql/server.sql.gz 

(9)导入初始框架和数据

[root@kylin yum.repos.d]# zcat /usr/share/zabbix-sql-scripts/mysql/server.sql.gz | /usr/bin/mysql --default-character-set=utf8mb4 -uzabbix -p zabbix

(10)查看

导入的zabbix数据库放在了/var/lib/mysql

[root@kylin yum.repos.d]# cd /var/lib/mysql
[root@kylin mysql]# ls

[root@kylin mysql]# cd zabbix/
[root@kylin zabbix]# ls

4. kylin 修改 zabbix 配置

(1) 查看zabbix配置目录

[root@kylin zabbix]# cd /etc/zabbix/
[root@kylin zabbix]# ll

(2)修改zabbix配置文件

[root@kylin zabbix]# vim zabbix_server.conf 
……
DBPassword=root@mySQL123
……

修改前:

修改后:

(3)查看二进制命令

[root@kylin opt]# ll /usr/sbin/zabbix_server
lrwxrwxrwx 1 root root 31  2月 20 00:53 /usr/sbin/zabbix_server -> /etc/alternatives/zabbix-server

查看版本成功

[root@kylin opt]# /usr/sbin/zabbix_server -V

(4)修改 zabbix web配置

[root@kylin opt]# cd /etc/nginx/
[root@kylin nginx]# ls
conf.d     fastcgi.conf          fastcgi_params          koi-utf  maojing             mime.types          nginx.conf          scgi_params          uwsgi_params          win-utf
default.d  fastcgi.conf.default  fastcgi_params.default  koi-win  mime_mailcap.types  mime.types.default  nginx.conf.default  scgi_params.default  uwsgi_params.default
[root@kylin nginx]# cd conf.d/
[root@kylin conf.d]# ls
php-fpm.conf  zabbix.conf
[root@kylin conf.d]# vim zabbix.conf 

修改前:

修改后:

(5)启动 Zabbix server 和 agent 进程

[root@kylin zabbix]# systemctl restart zabbix-server zabbix-agent nginx php-fpm

查看进程

[root@kylin zabbix]# ps -ef |grep zabbix

开机自启

[root@kylin zabbix]#  systemctl enable zabbix-server zabbix-agent nginx php-fpm

查看日志

[root@kylin zabbix]# tail -f /var/log/zabbix/zabbix_server.log

5. kylin 修改zabbix web

(1) 访问web

http://192.168.204.77:8080/

(2)修改语言

(3)必要条件检测

(4)输入密码

(5)主机名称和时区

(6)下一步

(7)完成

etc/zabbix/web/zabbix.conf.php

查看

[root@kylin zabbix]# cd /etc/zabbix/
[root@kylin zabbix]# cd web/
[root@kylin web]# ll

(7)登录

(8) 输入默认账户

1)用户名称
Admin

2)密码
zabbix

(9)进入系统

(10)查看主机

(11)查看图表

二、问题

1. zabbix_server 查看版本报错

(1)报错

[root@kylin zabbix]# /usr/sbin/zabbix_server -v
/usr/sbin/zabbix_server: symbol lookup error: /usr/sbin/zabbix_server: undefined symbol: usmAES192PrivProtocol

(2)原因分析

查看库文件

[root@kylin zabbix]# ldd /usr/sbin/zabbix_server | grep -i snmp
	libnetsnmp.so.35 => /usr/lib64/libnetsnmp.so.35 (0x00007f14c1371000)

查看库文件支持的命令

[root@kylin zabbix]# nm -D /usr/lib64/libnetsnmp.so.35 | grep -i aes
                 U EVP_aes_128_cfb128
00000000000df2a0 D usmAES128PrivProtocol
00000000000deda0 D usmAESPrivProtocol
0000000000098b00 T usm_set_aes_iv

(3)解决方法

net-snmp-libs库版本太老,需要升级。

查看版本:

[root@kylin zabbix]# rpm -qa | grep net-snmp-libs
net-snmp-libs-5.9-3.p04.ky10.x86_64

卸载

[root@kylin zabbix]# dnf remove net-snmp-libs

下载

net-snmp-libs-5.8-22.el8.x86_64.rpm Oracle Linux 8 Download (pkgs.org)

[root@kylin opt]# wget https://yum.oracle.com/repo/OracleLinux/OL8/baseos/latest/x86_64/getPackage/net-snmp-libs-5.8-22.el8.x86_64.rpm

安装

[root@kylin opt]# rpm -ivh net-snmp-libs-5.8-22.el8.x86_64.rpm 

查看库

[root@kylin opt]# ll /usr/lib64/libnetsnmp.so.35
lrwxrwxrwx 1 root root 20 10月  9  2021 /usr/lib64/libnetsnmp.so.35 -> libnetsnmp.so.35.0.0

再次查看库文件支持命令

[root@kylin opt]# nm -D /usr/lib64/libnetsnmp.so.35 | grep -i aes
                 U EVP_aes_128_cfb128
                 U EVP_aes_192_cfb128
                 U EVP_aes_256_cfb128
00000000002e5560 D usmAES128PrivProtocol
00000000002e4ec0 D usmAES192CiscoPrivProtocol
00000000002e4f80 D usmAES192PrivProtocol
00000000002e4e60 D usmAES256CiscoPrivProtocol
00000000002e4f20 D usmAES256PrivProtocol
00000000002e4fe0 D usmAESPrivProtocol
000000000009f1e0 T usm_set_aes_iv
[root@kylin opt]# 

重新安装zabbix-server-mysql

[root@kylin opt]# dnf install  zabbix-server-mysql

查看二进制命令

[root@kylin opt]# ll /usr/sbin/zabbix_server
lrwxrwxrwx 1 root root 31  2月 20 00:53 /usr/sbin/zabbix_server -> /etc/alternatives/zabbix-server

成功:

[root@kylin opt]# /usr/sbin/zabbix_server -V

2.zabbix_server 文件如何去掉注释"#"和空行

(1)查看

[root@kylin zabbix]# grep -v "#" /etc/zabbix/zabbix_server.conf |grep -v "^$"

3. zabbix图表显示异常

(1)报错

监控-主机-仪表盘

显示带方框的异常图标(汉字方块)

(2)原因分析

中文乱码,会⽆法显⽰汉字。

zabbix出图界⾯对应的字体⽂件在/usr/share/zabbix/assets/fonts⽬录下,默认是graphfont.ttf⽂件,但此⽂件在银河麒麟服务器下是不存在的,所以出图界⾯中⽂⽆法显⽰
[root@kylin web]# cd /usr/share/zabbix
[root@kylin zabbix]# ls
actionconf.php   audio               chart3.php  chart.php      data                 history.php                  hostinventories.php  image.php       index.php      jsLoader.php  maintenance.php  report4.php  sysmaps.php      trigger_prototypes.php
api_jsonrpc.php  auditacts.php       chart4.php  composer.json  disc_prototypes.php  host_discovery.php           host_prototypes.php  imgstore.php    index_sso.php  jsrpc.php     map.php          robots.txt   templates.php    triggers.php
app              browserwarning.php  chart6.php  composer.lock  favicon.ico          hostgroups.php               httpconf.php         include         items.php      local         modules          setup.php    toptriggers.php  vendor
assets           chart2.php          chart7.php  conf           graphs.php           hostinventoriesoverview.php  httpdetails.php      index_http.php  js             locale        report2.php      sysmap.php   tr_events.php    zabbix.php
[root@kylin zabbix]# cd assets/
[root@kylin assets]# ls
fonts  img  styles
[root@kylin assets]# cd fonts/
[root@kylin fonts]# ls
graphfont.ttf
[root@kylin fonts]# ll
总用量 0
lrwxrwxrwx 1 root root 33  2月 20 00:12 graphfont.ttf -> /etc/alternatives/zabbix-web-font
[root@kylin fonts]# ll /etc/alternatives/zabbix-web-font
lrwxrwxrwx 1 root root 38  2月 20 00:12 /etc/alternatives/zabbix-web-font -> /usr/share/fonts/dejavu/DejaVuSans.ttf
[root@kylin fonts]# ll /usr/share/fonts/dejavu/DejaVuSans.ttf
-rw-r--r-- 1 root root 756072  5月 17  2015 /usr/share/fonts/dejavu/DejaVuSans.ttf
[root@kylin fonts]# 

(3)解决方法

下载需要的中⽂字体⽂件,然后拷⻉到/usr/share/zabbix/assets/fonts⽬录下,重命名为graphfont.ttf即可。

删除

[root@kylin fonts]# rm -rf graphfont.ttf 

上传新字体

刷新恢复正常

4.zabbix-server如何进行性能优化配置

(1)重要配置项

 ListenPort=10051
 LogFile=/tmp/zabbix_server.log
 DBHost=localhost
 DBName=zabbix 
 DBUser=zabbix 
 DBPassword=root@mySQL123
 ListenIP=0.0.0.0
 StartPollers=5
 StartTrappers=10
 StartDiscoverers=10
 AlertScriptsPath=/usr/local/zabbix/share/zabbix/alertscripts

(2)配置项说明

1) ListenPort
ListenPort是zabbix server默认监听端⼝,LogFile⽤来指定zabbix server⽇志输出路径,DBHost为数据库的地址,如果数据库在本机,可不做修改,DBName为数据库名称,DBUser为连接数据库的⽤⼾名,DBPassword为连接数据量对应的⽤⼾密码。ListenIP为zabbix server监听的IP地址,也就是zabbix server启动的监听端⼝对哪些ip开放,Agentd为主动模式时,这个值建议设置为0.0.0.0。

2)StartPollers
StartPollers ⽤于设置zabbix serve服务启动时启动Pollers(主动收集数据进程)的数量,数量越多,则服务端吞吐能⼒越强,同时对系统资源消耗越⼤。

3)StartTrappers
StartTrappers⽤于设置zabbix server服务启动时启动Trappers(负责处理Agentd推送过来的数据的进程)的数量。Agentd为主动模式时,zabbix server需要设置这个值⼤⼀些。

4)StartDiscoverers
StartDiscoverers⽤于设置zabbix server服务启动时启动Discoverers进程的数量,如果zabbix监控报Discoverers进程忙时,需要提⾼该值。

5)AlertScriptsPath
AlertScriptsPath⽤来配置zabbix server运⾏脚本存放⽬录,⼀些供zabbix server使⽤的脚本,都可以放在这⾥。

5. zabbix运行架构

(1)架构

  • 25
    点赞
  • 23
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值