Centos6.5部署Zabbix3.2(备忘)

配置yum源

1
2
3
4
wget --no-check-certificate http://lug.ustc.edu.cn/wiki/_export/code/mirrors/help/epel?codeblock=0 -O epel.repo
wget --no-check-certificate http://lug.ustc.edu.cn/wiki/_export/code/mirrors/help/epel?codeblock=1 -O epel-testing.repo
yum install -y http://www.percona.com/downloads/percona-release/redhat/0.1-3/percona-release-0.1-3.noarch.rpm
rpm -Uvh http://mirror.webtatic.com/yum/el6/latest.rpm

安装LNMP环境及依赖包

1
yum -y install nginx Percona-Server-server-57 Percona-Server-client-57 Percona-Server-devel-57 Percona-Server-tokudb-57 php56w php56w-fpm php56w-mysql gcc-c++ libxml2-devel net-snmp-devel libcurl-devel fping php56w-bcmath php56w-mbstring php56w-gd php56w-xmlwriter php56w-xmlreader

数据库初始化,支持TokuDB

1
2
3
4
5
6
7
8
数据库初始化
mysqld --initialize-insecure --user=mysql --datadir=/data/mysql/data/
启用TokuDB
ps_tokudb_admin --enable -uroot -pgeekwolf
若无法加载tokudb引擎,请查看huge pages是否关闭:
echo never > /sys/kernel/mm/transparent_hugepage/enabled
echo never > /sys/kernel/mm/transparent_hugepage/defrag

安装Zabbix

1
2
3
4
5
6
7
wget https://nchc.dl.sourceforge.net/project/zabbix/ZABBIX%20Latest%20Stable/3.2.2/zabbix-3.2.2.tar.gz
groupadd zabbix
useradd -g zabbix -s /sbin/nologin
tar xf zabbix-3.2.2.tar.gz
./configure --enable-server --enable-agent --with-mysql --enable-ipv6 --with-net-snmp --with-libcurl --with-libxml2
make -j8
make install

配置zabbix_agent

1
2
3
4
5
6
7
8
vim /usr/local/etc/zabbix_agentd.conf
PidFile=/tmp/zabbix_agentd.pid
LogFile=/tmp/zabbix_agentd.log
LogFileSize=0
Server=192.168.1.1
ServerActive=192.168.1.1
Hostname=192.168.1.2
UnsafeUserParameters=1

配置zabbix_server

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
vim /usr/local/etc/zabbix_server.conf
DBHost=192.168.1.1
DBName=zabbix
DBUser=zabbix
DBPassword=zabbix
DebugLevel=3
StartPollers=80
CacheSize=32M
TrendCacheSize=32M
HistoryCacheSize=32M
LogFile=/tmp/zabbix_server.log
AlertScriptsPath=/usr/local/etc/scripts
FpingLocation=/usr/bin/fping
StartPingers=20
HousekeepingFrequency=1
MaxHousekeeperDelete=10000
Timeout=10

部署Zabbix FrontEnd

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
cd zabbix-3.2.2/
cp frontends/php/* /usr/share/zabbix/
chown apache.apache /usr/share/zabbix -R
mysql>create database zabbix;
mysql>source database/mysql/schema.sql;
mysql>source database/mysql/images.sql;
mysql>source database/mysql/data.sql;
拷贝启动脚本:
cp misc/init.d/fedora/core5/* /etc/rc.d/init.d/
配置Nginx:
vim /etc/nginx/conf.d/zabbix.conf
server {
listen 80;
server_name zbx.simlinux.com;
index index.html index.php;
root /usr/share/zabbix;
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}

启动agent和server服务

1
2
3
service zabbix_agentd start
service zabbix_server start
service nginx reload

修改php.ini配置:

1
2
3
4
5
6
always_populate_raw_post_data = -1
max_execution_time = 300
max_input_time = 300
data.timezone = PRC
post_max_size=16M
service php-fpm reload

修改数据表引擎和创建分区表

1
2
3
4
5
alter table history engines='tokudb';
alter table history_log engines='tokudb';
alter table history_str engines='tokudb';
alter table history_text engines='tokudb';
alter table trends engines='tokudb';

分区表可参考http://blog.simlinux.com/archives/1776.html

安装Zabbix Web

访问http://192.168.1.1 进行安装,默认账号密码: admin zabbix

遇到的问题

A. Zabbix设置中文显示时,图形部分字体显示方框

解决方法:
Zabbix默认使用DejaVuSan.ttf字体,不支持中文
拷贝本地C:\Windows\Fonts下的微软雅黑字体上传到Zabbix Web目录fonts下,即msyh.ttf
sed -i ‘s/DejaVuSans/msyh/g’ ./include/defines.inc.php

B. Zabbix_server日志提示20434:20161217:105010.997 fping failed: fping6: Address family for hostname not supported
解决方法:
zabbix_server.conf中指定fping和fping6路径
FpingLocation=/usr/sbin/fping
Fping6Location=/usr/sbin/fping6

坚持原创分享,您的支持将鼓励我继续创作