简单的话就这么配。然后add
5.17 解决中文名称不能写数据库的问题
107
[root@test01 ~]# mysql -uroot -pchampin zabbix
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 2757
Server version: 10.3.12-MariaDB-log 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 [zabbix]> show create table triggers\G
*************************** 1. row ***************************
Table: triggers
Create Table: CREATE TABLE `triggers` (
`triggerid` bigint(20) unsigned NOT NULL,
`expression` varchar(2048) NOT NULL DEFAULT '',
`description` varchar(255) NOT NULL DEFAULT '',
`url` varchar(255) NOT NULL DEFAULT '',
`status` int(11) NOT NULL DEFAULT 0,
`value` int(11) NOT NULL DEFAULT 0,
`priority` int(11) NOT NULL DEFAULT 0,
`lastchange` int(11) NOT NULL DEFAULT 0,
`comments` text NOT NULL,
`error` varchar(2048) NOT NULL DEFAULT '',
`templateid` bigint(20) unsigned DEFAULT NULL,
`type` int(11) NOT NULL DEFAULT 0,
`state` int(11) NOT NULL DEFAULT 0,
`flags` int(11) NOT NULL DEFAULT 0,
`recovery_mode` int(11) NOT NULL DEFAULT 0,
`recovery_expression` varchar(2048) NOT NULL DEFAULT '',
`correlation_mode` int(11) NOT NULL DEFAULT 0,
`correlation_tag` varchar(255) NOT NULL DEFAULT '',
`manual_close` int(11) NOT NULL DEFAULT 0,
PRIMARY KEY (`triggerid`),
KEY `triggers_1` (`status`),
KEY `triggers_2` (`value`,`lastchange`),
KEY `triggers_3` (`templateid`),
CONSTRAINT `c_triggers_1` FOREIGN KEY (`templateid`) REFERENCES `triggers` (`triggerid`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=latin1
1 row in set (0.002 sec)
MariaDB [zabbix]>
MariaDB [zabbix]> show variables like 'character%';
+--------------------------+----------------------------------+
| Variable_name | Value |
+--------------------------+----------------------------------+
| character_set_client | utf8 |
| character_set_connection | utf8 |
| character_set_database | latin1 |
| character_set_filesystem | binary |
| character_set_results | utf8 |
| character_set_server | latin1 |
| character_set_system | utf8 |
| character_sets_dir | /usr/local/mysql/share/charsets/ |
+--------------------------+----------------------------------+
8 rows in set (0.002 sec)
要设定这一行参数
| character_set_database | latin1 改成utf8
MariaDB [zabbix]> quit
Bye
用这条命令导出
[root@test01 ~]# mysqldump -uroot -pchampin --default-character-set=utf8 zabbix > zabbix.sql
[root@test01 ~]# vim !$
vim zabbix.sql
在vim普通模式下查找替换,latin1替换成utf8
:1,$s/latin1/utf8/g
导入“其实这也是mysql的备份和恢复”
[root@test01 ~]# mysql -uroot -pchampin --default-character-set=utf8 zabbix < zabbix.sql
[root@test01 ~]#
[root@test01 ~]# mysql -uroot -pchampin zabbix
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 2830
Server version: 10.3.12-MariaDB-log 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 [zabbix]> show create table items\G
*************************** 1. row ***************************
Table: items
Create Table: CREATE TABLE `items` (
`itemid` bigint(20) unsigned NOT NULL,
`type` int(11) NOT NULL DEFAULT 0,
`snmp_community` varchar(64) NOT NULL DEFAULT '',
`snmp_oid` varchar(512) NOT NULL DEFAULT '',
`hostid` bigint(20) unsigned NOT NULL,
`name` varchar(255) NOT NULL DEFAULT '',
`key_` varchar(255) NOT NULL DEFAULT '',
`delay` varchar(1024) NOT NULL DEFAULT '0',
`history` varchar(255) NOT NULL DEFAULT '90d',
`trends` varchar(255) NOT NULL DEFAULT '365d',
`status` int(11) NOT NULL DEFAULT 0,
`value_type` int(11) NOT NULL DEFAULT 0,
`trapper_hosts` varchar(255) NOT NULL DEFAULT '',
`units` varchar(255) NOT NULL DEFAULT '',
`snmpv3_securityname` varchar(64) NOT NULL DEFAULT '',
`snmpv3_securitylevel` int(11) NOT NULL DEFAULT 0,
`snmpv3_authpassphrase` varchar(64) NOT NULL DEFAULT '',
`snmpv3_privpassphrase` varchar(64) NOT NULL DEFAULT '',
`formula` varchar(255) NOT NULL DEFAULT '',
`error` varchar(2048) NOT NULL DEFAULT '',
`lastlogsize` bigint(20) unsigned NOT NULL DEFAULT 0,
`logtimefmt` varchar(64) NOT NULL DEFAULT '',
`templateid` bigint(20) unsigned DEFAULT NULL,
`valuemapid` bigint(20) unsigned DEFAULT NULL,
`params` text NOT NULL,
`ipmi_sensor` varchar(128) NOT NULL DEFAULT '',
`authtype` int(11) NOT NULL DEFAULT 0,
`username` varchar(64) NOT NULL DEFAULT '',
`password` varchar(64) NOT NULL DEFAULT '',
`publickey` varchar(64) NOT NULL DEFAULT '',
`privatekey` varchar(64) NOT NULL DEFAULT '',
`mtime` int(11) NOT NULL DEFAULT 0,
`flags` int(11) NOT NULL DEFAULT 0,
`interfaceid` bigint(20) unsigned DEFAULT NULL,
`port` varchar(64) NOT NULL DEFAULT '',
`description` text NOT NULL,
`inventory_link` int(11) NOT NULL DEFAULT 0,
`lifetime` varchar(255) NOT NULL DEFAULT '30d',
`snmpv3_authprotocol` int(11) NOT NULL DEFAULT 0,
`snmpv3_privprotocol` int(11) NOT NULL DEFAULT 0,
`state` int(11) NOT NULL DEFAULT 0,
`snmpv3_contextname` varchar(255) NOT NULL DEFAULT '',
`evaltype` int(11) NOT NULL DEFAULT 0,
`jmx_endpoint` varchar(255) NOT NULL DEFAULT '',
`master_itemid` bigint(20) unsigned DEFAULT NULL,
`timeout` varchar(255) NOT NULL DEFAULT '3s',
`url` varchar(2048) NOT NULL DEFAULT '',
`query_fields` varchar(2048) NOT NULL DEFAULT '',
`posts` text NOT NULL,
`status_codes` varchar(255) NOT NULL DEFAULT '200',
`follow_redirects` int(11) NOT NULL DEFAULT 1,
`post_type` int(11) NOT NULL DEFAULT 0,
`http_proxy` varchar(255) NOT NULL DEFAULT '',
`headers` text NOT NULL,
`retrieve_mode` int(11) NOT NULL DEFAULT 0,
`request_method` int(11) NOT NULL DEFAULT 0,
`output_format` int(11) NOT NULL DEFAULT 0,
`ssl_cert_file` varchar(255) NOT NULL DEFAULT '',
`ssl_key_file` varchar(255) NOT NULL DEFAULT '',
`ssl_key_password` varchar(64) NOT NULL DEFAULT '',
`verify_peer` int(11) NOT NULL DEFAULT 0,
`verify_host` int(11) NOT NULL DEFAULT 0,
`allow_traps` int(11) NOT NULL DEFAULT 0,
PRIMARY KEY (`itemid`),
UNIQUE KEY `items_1` (`hostid`,`key_`),
KEY `items_3` (`status`),
KEY `items_4` (`templateid`),
KEY `items_5` (`valuemapid`),
KEY `items_6` (`interfaceid`),
KEY `items_7` (`master_itemid`),
CONSTRAINT `c_items_1` FOREIGN KEY (`hostid`) REFERENCES `hosts` (`hostid`) ON DELETE CASCADE,
CONSTRAINT `c_items_2` FOREIGN KEY (`templateid`) REFERENCES `items` (`itemid`) ON DELETE CASCADE,
CONSTRAINT `c_items_3` FOREIGN KEY (`valuemapid`) REFERENCES `valuemaps` (`valuemapid`),
CONSTRAINT `c_items_4` FOREIGN KEY (`interfaceid`) REFERENCES `interface` (`interfaceid`),
CONSTRAINT `c_items_5` FOREIGN KEY (`master_itemid`) REFERENCES `items` (`itemid`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 变成了utf8
1 row in set (0.001 sec)
MariaDB [zabbix]>
MariaDB [zabbix]> show create table triggers\G
*************************** 1. row ***************************
Table: triggers
Create Table: CREATE TABLE `triggers` (
`triggerid` bigint(20) unsigned NOT NULL,
`expression` varchar(2048) NOT NULL DEFAULT '',
`description` varchar(255) NOT NULL DEFAULT '',
`url` varchar(255) NOT NULL DEFAULT '',
`status` int(11) NOT NULL DEFAULT 0,
`value` int(11) NOT NULL DEFAULT 0,
`priority` int(11) NOT NULL DEFAULT 0,
`lastchange` int(11) NOT NULL DEFAULT 0,
`comments` text NOT NULL,
`error` varchar(2048) NOT NULL DEFAULT '',
`templateid` bigint(20) unsigned DEFAULT NULL,
`type` int(11) NOT NULL DEFAULT 0,
`state` int(11) NOT NULL DEFAULT 0,
`flags` int(11) NOT NULL DEFAULT 0,
`recovery_mode` int(11) NOT NULL DEFAULT 0,
`recovery_expression` varchar(2048) NOT NULL DEFAULT '',
`correlation_mode` int(11) NOT NULL DEFAULT 0,
`correlation_tag` varchar(255) NOT NULL DEFAULT '',
`manual_close` int(11) NOT NULL DEFAULT 0,
PRIMARY KEY (`triggerid`),
KEY `triggers_1` (`status`),
KEY `triggers_2` (`value`,`lastchange`),
KEY `triggers_3` (`templateid`),
CONSTRAINT `c_triggers_1` FOREIGN KEY (`templateid`) REFERENCES `triggers` (`triggerid`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 变成了utf8
1 row in set (0.000 sec)
现在我们再来试试中文 update
包括很多地方都可以改成中文,
5.18 解决图形中文乱码
但还有个问题就是图形中如果存在中文的话,还是会显示乱码,因为没有支持中文文字的字体,这个问题就要处理一下字体,把windows的字体搞过来,
在windows下找到宋体字体。最简单的方法是用rz命令上传到linux系统里
通过配置文件找到字体以及所在的路径
[root@test01 zabbix]# vim include/defines.inc.php
字体上传到linux进来后
[root@test01 zabbix]# mv simsun.ttc fonts/
[root@test01 zabbix]# cd fonts/
[root@test01 fonts]# ls
graphfont.ttf simsun.ttc
[root@test01 fonts]# mv graphfont.ttf graphfont.ttf.bak; ln ./simsun.ttc graphfont.ttf
[root@test01 fonts]# ls
graphfont.ttf graphfont.ttf.bak simsun.ttc
[root@test01 fonts]# rm -f graphfont.ttf
[root@test01 fonts]# ls
graphfont.ttf.bak simsun.ttc
[root@test01 fonts]# ln -s ./simsun.ttc graphfont.ttf
[root@test01 fonts]# ls
graphfont.ttf graphfont.ttf.bak simsun.ttc
[root@test01 fonts]# ls -l
总用量 17788
lrwxrwxrwx. 1 root root 12 4月 15 13:30 graphfont.ttf -> ./simsun.ttc
lrwxrwxrwx. 1 root root 33 3月 21 13:36 graphfont.ttf.bak -> /etc/alternatives/zabbix-web-font
-rw-r--r--. 1 root root 18214472 9月 15 2018 simsun.ttc
[root@test01 fonts]#