Zabbix 4.4管理界面中文乱码解决方法

1.zabbix 4.4 安装配置过程可参考官方文档:

 文档链接地址:https://www.zabbix.com/download?zabbix=4.4&os_distribution=centos&os_version=7&db=mysql

2.Zabbix 4.4 安装完成之后,监控图形页面出现字符集乱码,如下所示:

 

解决方法:

《1》C:\Windows\Fonts\微软雅黑 常规  字体上传到zabbix服务器zabbix-web-font 目录下,

 

《2》zabbix 的安装目录如下:

[root@docker /]# whereis zabbix
zabbix: /usr/lib/zabbix /etc/zabbix /usr/share/zabbix

切换到/usr/share/zabbix 目录,

[root@docker zabbix]# cd /usr/share/zabbix/
[root@docker zabbix]# ls 
actionconf.php                 adm.workingtime.php  chart4.php           favicon.ico                  httpdetails.php  local            robots.txt         sysmaps.php
adm.gui.php                    api_jsonrpc.php      chart5.php           graphs.php                   image.php        locale           screenconf.php     templates.php
adm.housekeeper.php            app                  chart6.php           history.php                  imgstore.php     maintenance.php  screenedit.php     toptriggers.php
adm.iconmapping.php            applications.php     chart7.php           host_discovery.php           include          map.import.php   screen.import.php  tr_events.php
adm.images.php                 assets               chart.php            hostgroups.php               index_http.php   map.php          screens.php        trigger_prototypes.php
adm.macros.php                 audio                charts.php           hostinventoriesoverview.php  index.php        overview.php     services.php       triggers.php
adm.other.php                  auditacts.php        conf                 hostinventories.php          items.php        php.php          setup.php          usergrps.php
adm.regexps.php                auditlogs.php        conf.import.php      host_prototypes.php          js               profile.php      slideconf.php      users.php
adm.triggerdisplayoptions.php  browserwarning.php   correlation.php      host_screen.php              jsLoader.php     queue.php        slides.php         zabbix.php
adm.triggerseverities.php      chart2.php           discoveryconf.php    hosts.php                    jsrpc.php        report2.php      srv_status.php
adm.valuemapping.php           chart3.php           disc_prototypes.php  httpconf.php                 latest.php       report4.php      sysmap.php

发现并未有存放字体fonts目录,于是手动创建fonts目录,将字体文件上传至此目录下。

[root@docker zabbix]# mkdir -p /usr/share/zabbix/fonts

使用rz -y 命令将字体文件msyh.ttf 上传至该目录;

[root@docker fonts]# ls  
msyh.ttf

《3》切换至目录/etc/alternatives/ ,可以看到zabbix-web-font文件实际上是一个软连接,链接的文件实际位置是:/usr/share/fonts/dejavu/DejaVuSans.ttf 。

[root@docker /]# ll /etc/alternatives/zabbix-web-font 
lrwxrwxrwx. 1 root root 38 Aug 19 13:45 /etc/alternatives/zabbix-web-font -> /usr/share/fonts/dejavu/DejaVuSans.ttf

这里我们删除默认软连接的字符集,指向刚刚新安装的字符集路径。

[root@docker fonts]# ll /etc/alternatives/zabbix-web-font 
lrwxrwxrwx. 1 root root 38 Aug 19 13:45 /etc/alternatives/zabbix-web-font -> /usr/share/fonts/dejavu/DejaVuSans.ttf
[root@docker fonts]# rm -rf  /etc/alternatives/zabbix-web-font 
[root@docker fonts]# ln -s /usr/share/zabbix/fonts/msyh.ttf /etc/alternatives/zabbix-web-font
[root@docker fonts]# ll /etc/alternatives/zabbix-web-font 
lrwxrwxrwx. 1 root root 32 Aug 20 12:25 /etc/alternatives/zabbix-web-font -> /usr/share/zabbix/fonts/msyh.ttf

《4》修改系统配置文件,让web页面支持简体中文显示

[root@docker fonts]# vim /usr/share/zabbix/include/locales.inc.php

找到如下所示:

'zh_CN' => ['name' => _('Chinese (zh_CN)'),     'display' => false],

修改为
'zh_CN' => ['name' => _('Chinese (zh_CN)'),     'display' => true],

将false 改为true, 保存退出。

《5》重启zabbix-server 服务

[root@docker fonts]# systemctl restart zabbix-server

《6》退出并重新登录WEB,查看图形,显示正常。

  

另外还有一种情况就是安装配置MySQL数据库的时候,没有指定MySQL数据库的字符集。如下所示:

[root@docker fonts]# mysql 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1838
Server version: 5.6.45 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> status;
--------------
mysql  Ver 14.14 Distrib 5.6.45, for Linux (x86_64) using  EditLine wrapper

Connection id:        1838
Current database:    
Current user:        root@localhost
SSL:            Not in use
Current pager:        stdout
Using outfile:        ''
Using delimiter:    ;
Server version:        5.6.45 MySQL Community Server (GPL)
Protocol version:    10
Connection:        Localhost via UNIX socket
Server characterset:    utf8
Db     characterset:    utf8
Client characterset:    utf8
Conn.  characterset:    utf8
UNIX socket:        /var/lib/mysql/mysql.sock
Uptime:            2 hours 13 min 16 sec

Threads: 26  Questions: 134782  Slow queries: 0  Opens: 168  Flush tables: 1  Open tables: 161  Queries per second avg: 16.856
--------------

设置MySQL数据库字符集为UTF8模式,MySQL数据库修改字符集的方法。在/etc/my.cnf 的【mysqld】端加入如下代码:

[mysqld]
character-set-server=utf8

保存退出,重启MySQL数据库服务即可。

至此,Zabbix 4.4 图像乱码问题解决 。

 

posted @ 2019-08-20 12:47  caoss  阅读(7278)  评论(1编辑  收藏  举报