Zabbix 4.4管理界面中文亂碼解決方法

1.zabbix 4.4 安裝配置過程可參考官方文檔:php

 文檔連接地址:https://www.zabbix.com/download?zabbix=4.4&os_distribution=centos&os_version=7&db=mysqlmysql

2.Zabbix 4.4 安裝完成以後,監控圖形頁面出現字符集亂碼,以下所示:web

 

解決方法:sql

《1》C:\Windows\Fonts\微軟雅黑 常規  字體上傳到zabbix服務器zabbix-web-font 目錄下,docker

 

《2》zabbix 的安裝目錄以下:數據庫

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

切換到/usr/share/zabbix 目錄,json

[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目錄,將字體文件上傳至此目錄下。vim

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

使用rz -y 命令將字體文件msyh.ttf 上傳至該目錄;centos

[root@docker fonts]# ls  
msyh.ttf

《3》切換至目錄/etc/alternatives/ ,能夠看到zabbix-web-font文件其實是一個軟鏈接,連接的文件實際位置是:/usr/share/fonts/dejavu/DejaVuSans.ttf 。api

[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 圖像亂碼問題解決 。

相關文章
相關標籤/搜索