一.zabbix语言设置成中文后,有乱码解决如下
1.从windows下控制面板->字体->选择一种中文字库例如“楷体”
2.将字体上传至/var/www/html/zabbix/fonts目录下
3.修改zabbix页面管理的中文字体设置
1
2
3
4
[root@zabbix-server zabbix-2.4.5]# vim /var/www/html/zabbix/include/defines.inc.php
#修改如下2行
define('ZBX_FONT_NAME', 'simkai');
define('ZBX_GRAPH_FONT_NAME', 'simkai');
修改后的zabbix界面。
wKiom1VAkT_yESpGAAOayaLuqW8397.jpg
二.修改完以上步骤后,zabbix界面的历史记录还是乱码,这是由于mysql的数据库字符集导致的,解决办法如下
1.备份zabbix数据库,并修改备份下来的数据文件
[root@zabbix-server ~]# mysqldump zabbix >zabbix.sql
[root@zabbix-server ~]# sed -i 's/latin1/utf8/g' zabbix.sql
2.删除zabbix数据库
mysql> drop database zabbix;
Query OK, 104 rows affected (0.42 sec)
3.关闭mysql数据库,设置默认字符集
[root@zabbix-server ~]# service mysqld stop
Stopping mysqld: [ OK ]
#在mysql配置文件中添加字符集参数
[root@zabbix-server ~]# vim /etc/my.cnf
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
default-character-set = utf8
user=mysql
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
4.启动mysql并恢复zabbix数据库
[root@zabbix-server ~]# service mysqld start
Starting mysqld: [ OK ]
[root@zabbix-server ~]# mysql
mysql> create database zabbix;
Query OK, 1 row affected (0.00 sec)
mysql> show create database zabbix;
+----------+-----------------------------------------------------------------+
| Database | Create Database |
+----------+-----------------------------------------------------------------+
| zabbix | CREATE DATABASE `zabbix` /*!40100 DEFAULT CHARACTER SET utf8 */ |
+----------+-----------------------------------------------------------------+
1 row in set (0.00 sec)
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| test |
| zabbix |
+--------------------+
4 rows in set (0.00 sec)
mysql> use zabbix;
Database changed
mysql> source zabbix.sql;
5.查看修改后的结果
wKioL1VAmEOwhB4yAAXRQKchUbQ243.jpg
三.在client端192.168.3.29安装zabbix
安装基础软件包
1
[root@zabbix-c1 ~]# yum install wget vim tree gcc gcc-c++ -y
安装zabbix_agentd
[root@zabbix-c1 ~]# groupadd -g 201 zabbix
[root@zabbix-c1 ~]# useradd -g zabbix -u 201 -s /sbin/nologin zabbix
[root@zabbix-c1 ~]# tar xf zabbix-2.4.5.tar.gz
[root@zabbix-c1 ~]# cd zabbix-2.4.5
#开始编译安装zabbix客户端
[root@zabbix-c1 zabbix-2.4.5]# ./configure --prefix=/usr/local/zabbix --enable-agent
[root@zabbix-c1 zabbix-2.4.5]# make && make install
#创建zabbix的日志目录
[root@zabbix-c1 zabbix-2.4.5]# mkdir /var/log/zabbix
[root@zabbix-c1 zabbix-2.4.5]# chown zabbix.zabbix /var/log/zabbix
#复制zabbix_agentd启动文件到/etc/init.d目录下
[root@zabbix-c1 zabbix-2.4.5]# cp misc/init.d/fedora/core/zabbix_agentd /etc/init.d/
[root@zabbix-c1 zabbix-2.4.5]# chmod 755 /etc/init.d/zabbix_agentd
#在iptables中放行10050和10051端口
[root@zabbix-c1 zabbix-2.4.5]# iptables -I INPUT -p tcp -m multiport --dports 10050:10051 -j ACCEPT
[root@zabbix-c1 zabbix-2.4.5]# service iptables save #保存iptables规则
iptables: Saving firewall rules to /etc/sysconfig/iptables:[ OK ]
#查看iptables结果
[root@zabbix-c1 zabbix-2.4.5]# iptables -L -n
Chain INPUT (policy ACCEPT)
target prot opt source destination
ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 multiport dports 10050:10051
ACCEPT all -- 0.0.0.0/0 0.0.0.0/0 state RELATED,ESTABLISHED
ACCEPT icmp -- 0.0.0.0/0 0.0.0.0/0
ACCEPT all -- 0.0.0.0/0 0.0.0.0/0
ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 state NEW tcp dpt:22
REJECT all -- 0.0.0.0/0 0.0.0.0/0 reject-with icmp-host-prohibited
Chain FORWARD (policy ACCEPT)
target prot opt source destination
REJECT all -- 0.0.0.0/0 0.0.0.0/0 reject-with icmp-host-prohibited
Chain OUTPUT (policy ACCEPT)
target prot opt source destination
#修改启动文件和配置软连接
[root@zabbix-c1 zabbix-2.4.5]# sed -i "s@BASEDIR=/usr/local@BASEDIR=/usr/local/zabbix@g" /etc/init.d/zabbix_agentd
[root@zabbix-c1 zabbix-2.4.5]# ln -s /usr/local/zabbix/etc/ /etc/zabbix
[root@zabbix-c1 zabbix-2.4.5]# ln -s /usr/local/zabbix/bin/* /usr/bin
[root@zabbix-c1 zabbix-2.4.5]# ln -s /usr/local/zabbix/sbin/* /usr/sbin/
#/etc/zabbix/zabbix_agentd.conf,这里的IP地址写的是zabbix_server端的IP地址
[root@zabbix-c1 zabbix-2.4.5]# sed -i "s@Server=127.0.0.1@Server=192.168.3.28@g" /etc/zabbix/zabbix_agentd.conf
[root@zabbix-c1 zabbix-2.4.5]# sed -i "s@ServerActive=127.0.0.1@ServerActive=192.168.3.28:10051@g" /etc/zabbix/zabbix_agentd.conf
[root@zabbix-c1 zabbix-2.4.5]# sed -i "s@tmp/zabbix_agentd.log@var/log/zabbix/zabbix_agentd.log@g" /etc/zabbix/zabbix_agentd.conf
[root@zabbix-c1 zabbix-2.4.5]# sed -i "s@^# UnsafeUserParameters=0@UnsafeUserParameters=1\n@g" /etc/zabbix/zabbix_agentd.conf
#设置zabbix_agentd开机自动启动,并启动zabbix_agentd服务
[root@zabbix-c1 zabbix-2.4.5]# chkconfig zabbix_agentd on
[root@zabbix-c1 zabbix-2.4.5]# service zabbix_agentd start
Starting zabbix_agentd: [ OK ]