Zabbix 1.8 安装记录

Zabbix 是一个提供 Web 管理界面的开源系统/网络监控服务器。
官方的文档写得非常好,许多内容这里就不介绍了,可以直接看官方文档:
http://www.zabbix.com/documentation/

本文只记录我的 Zabbix 1.8 的安装过程。
以下我要在同一台服务器上安装 Zabbix Server、Zabbix Proxy 和 Zabbix Agent。

安装前先配置好PHP,要求支持 php-gd、php-bcmath、php-xml、php-mysql、php-net-socket、php-mbstring,即 configure 参数中加上 –with-gd –enable-bcmath –enable-xml –with-mysql –enable-sockets –enable-mbstring。

我的配置参数如下:

./configure –prefix=/usr/local/php –with-config-file-path=/usr/local/php/etc –with-mysql=/usr/local/mysql –with-mysqli=/usr/local/mysql/bin/mysql_config –enable-fpm –enable-sockets –enable-pdo –with-pdo-mysql=/usr/local/mysql –with-gd –enable-bcmath –enable-xml –enable-mbstring

下面开始安装 Zabbix:

* 下载并解压:

wget http://prdownloads.sourceforge.net/zabbix/zabbix-1.8.tar.gz?download
tar zxf zabbix-1.8.tar.gz
cd zabbix-1.8

* 创建 zabbix 用户组和用户:

groupadd zabbix
useradd zabbix -g zabbix

* 创建 mysql 数据库:

create database zabbix character set utf8;

* 创建 mysql 用户:

grant all on zabbix.* to zabbix@localhost identified by ‘zabbix’;

* 导入表和数据:

mysql -uroot -p zabbix < create/schema/mysql.sql
mysql -uroot -p zabbix < create/data/data.sql
mysql -uroot -p zabbix < create/data/images_mysql.sql

* 配置编译:

./configure –enable-server –enable-proxy –enable-agent –with-mysql=/usr/local/mysql/bin/mysql_config –with-net-snmp –with-libcurl
make && make install

配置参数说明:

–enable-server 安装 Zabbix Server
–enable-proxy 安装 Zabbix Proxy
–enable-agent 安装 Zabbix Agent
–with-mysql 使用 mysql 做数据库服务器
–with-net-snmp 支持 SNMP
–with-libcurl 支持 curl,用于 web 监控

* 服务端口定义:
编辑 /etc/services,在后面追加:

zabbix-agent 10050/tcp Zabbix Agent
zabbix-agent 10050/udp Zabbix Agent
zabbix-trapper 10051/tcp Zabbix Trapper
zabbix-trapper 10051/udp Zabbix Trapper

* 复制配置文件:

mkdir /etc/zabbix
cp misc/conf/zabbix_server.conf /etc/zabbix/
cp misc/conf/zabbix_proxy.conf /etc/zabbix/
cp misc/conf/zabbix_agent.conf /etc/zabbix/
cp misc/conf/zabbix_agentd.conf /etc/zabbix/

* 修改 zabbix server 配置文件 /etc/zabbix/zabbix_server.conf 中的数据库用户名和密码:

DBUser=zabbix
DBPassword=zabbix

* 安装启动脚本

cp misc/init.d/gentoo/zabbix-server /etc/init.d/
cp misc/init.d/gentoo/zabbix-agentd /etc/init.d/

添加可执行权限:

chmod +x /etc/init.d/zabbix-server
chmod +x /etc/init.d/zabbix-agentd

修改 zabbix-server 头部变量定义:

NAME=zabbix_server
PATH=/bin:/usr/bin:/sbin:/usr/sbin
DAEMON=/usr/local/sbin/${NAME}
DESC=”Zabbix 1.4″
PID=/var/run/$NAME.pid

修改 zabbix-agentd 头部变量定义:

NAME=zabbix_agentd
PATH=/bin:/usr/bin:/sbin:/usr/sbin
DAEMON=/usr/local/sbin/${NAME}
DESC=”Zabbix 1.4″
PID=/var/run/$NAME.pid

* 添加到启动服务:

rc-update add zabbix-server default
rc-update add zabbix-agentd default

* 启动 Zabbix Server:

/etc/init.d/zabbix-server start

我启动时提示错误:

zabbix_server: error while loading shared libraries: libmysqlclient.so.16: cannot open shared object file: No such file or directory

因为我的 mysql client 库不在系统默认库中,做以下修改后重新启动就可以了:

echo /usr/local/mysql/lib/mysql/ >> /etc/ld.so.conf
ldconfig

* 启动 Zabbix Agentd

/etc/init.d/zabbix-agentd start

* 复制 Web Interface 到 web 目录:

cp -r frontends/php /work/www/zabbix

* 新建 nginx 配置:

server {
listen       80;
server_name  zabbix.local zabbix.hily;

access_log  /work/www/logs/zabbix.local.access.log  main;

location / {
root   /work/www/zabbix;
index  index.html index.htm index.php;
}

location ~ \.php$ {
root           /work/www/zabbix;
fastcgi_index  index.php;
include        fastcgi_params;
}

}

* 开始安装 Zabbix Web Interface
打开 http://zabbix.local/,看到提示:

Timezone for PHP is not set. Please set “date.timezone” option in php.ini.

按照提示,修改 php.ini 中时区设置:

date.timezone = Asia/Shanghai

重启 PHP-FPM:

/etc/init.d/php-fpm restart

监测环境时提示:

再次修改 php.ini:

post_max_size = 16M
max_execution_time = 300
mbstring.func_overload = 2

解决后按提示继续安装即可。

* 结束:
安装完后直接访问:
http://zabbix.local/
默认用户名和密码是:
Admin/zabbix
到此安装完成!

— EOF —

《Zabbix 1.8 安装记录》有14个想法

  1. What’s up, the whole thing is going fine here and ofcourse every one is sharing information, that’s truly fine, keep up writing.|

  2. Thanks for some other informative website. The place else may I am getting that kind of info written in such an ideal way? I’ve a undertaking that I am just now running on, and I have been on the look out for such info.

  3. Thanks , I’ve just been looking for information approximately this topic for ages and yours is the best I’ve came upon so far. But, what in regards to the bottom line? Are you certain in regards to the supply?

  4. Thank you for another informative blog. Where else may just I get that type of information written in such an ideal method? I’ve a venture that I’m simply now running on, and I’ve been on the glance out for such info.

  5. Link exchange is nothing else however it is simply placing the other person’s webpage link on your page at appropriate place and other person will also do similar for you.|

  6. ” Fantastic website. A lot of helpful info here. I am sending it to a few buddies ans additionally sharing in delicious. And obviously, thank you to your sweat! “

发表评论

电子邮件地址不会被公开。 必填项已用*标注