您的位置:首页 > 运维架构 > Linux

Linux LNMP环境下安装 zabbix

2012-02-04 13:49 155 查看
在Linux LNMP环境下安装zabbix监控,当然首先要把LNMP环境给搭建好。这个LNMP环境如何搭建的我就不说了,能来看zabbix可想你已经会搭建了,呵呵……

1.首先安装zabbix所需的组件

#yum -y install curl curl-devel net-snmp net-snmp-devel perl-DBI php-gd php-xml php-bcmath

2、下载并解压源码包

# wget http://nchc.dl.sourceforge.net/project/zabbix/ZABBIX%20Latest%20Stable/1.8.2/zabbix-1.8.2.tar.gz
# tar zxvf zabbix-1.8.2.tar.gz

3、数据库创建及导入

# mysql -uroot -p

mysql>create database zabbix;

mysql>quit;

# cd zabbix-1.8.2/create/schema/

# cat mysql.sql | mysql -uroot -p****** zabbix

# cd ../data/

# cat data.sql | mysql -uroot -p****** zabbix

# cat images_mysql.sql | mysql -uroot -p****** zabbix

4、开始编译、安装zabbix

防止安装过程中报configure: error: Not found Jabber library

# wget http://iksemel.googlecode.com/files/iksemel-1.4.tar.gz
# tar zxvf iksemel-1.4.tar.gz

# cd iksemel-1.4

# ./configure

# make && make install

# cd zabbix-1.8.2

#./configure --prefix=/usr/local/zabbix --enable-server --enable-agent --enable-proxy --with-mysql=/usr/local/webserver/mysql/bin/mysql_config --with-net-snmp --with-libcurl

#make install

(编译 zabbix 如果报下面错误,就做以下操作

configure: error: Not found mysqlclient library

cd /usr/lib/mysql/

# ln -s libmysqlclient.so.15.0.0 libmysqlclient.so

# ln -s libmysqlclient_r.so.15.0.0 libmysqlclient_r.so)


5.修改PHP配置文件php.ini内容使其满足zabbix安装配置需求

sed -i 's/^\(.*\)date.timezone =.*$/date.timezone = Asia\/Shanghai/g' /usr/local/webserver/php/etc/php.ini

sed -i 's/^\(.*\)post_max_size =.*$/post_max_size = 16M/g' /usr/local/webserver/php/etc/php.ini

sed -i 's/^\(.*\)max_execution_time =.*$/max_execution_time = 300/g' /usr/local/webserver/php/etc/php.ini

sed -i 's/^\(.*\)max_input_time =.*$/max_input_time = 300/g' /usr/local/webserver/php/etc/php.ini

mbstring.func_overload = 2

6.添加zabbix服务对应的端口

#vim /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

7.拷贝zabbix的配置文件到etc下,web相关文件拷贝到web目录下

#cd zabbix-1.8.2

#mkdir /etc/zabbix

#cp misc/conf/* etc/zabbix

#cp -r frontends/php /data/www/wwwroot/zabbix

修改zabbix连接的数据库的用户名和密码

#vi /etc/zabbix/zabbix_server.conf

DBName=zabbix

DBUser=zabbix

DBUDBPassword=zabbix

8.在nginx配置文件中建立zabbix虚拟机的配置文件

#vim /usr/local/webserver/nginx/conf/vhosts/zabbix.conf

server {

listen 80;

server_name 192.168.1.125;

#access_log logs/zabbix_access.log main;

location / {

root /data/www/wwwroot/zabbix;

index index.html index.htm index.php;

}

location ~ \.php$ {

root /data/www/wwwroot/zabbix;

fastcgi_pass 127.0.0.1:9000;

fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

fastcgi_index index.php;

include fastcgi_params;

}

}

9.启动时提示错误:

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

# /etc/init.d/zabbix-agentd start

Starting zabbix_agentd: /usr/local/zabbix/sbin/zabbix_agentd: error while loading shared libraries: libiconv.so.2: cannot open shared object file: No such fileor directory

用下面方法解决:

# echo /usr/local/lib/ >> /etc/ld.so.conf

# ldconfig

10.进行zabbix的安装

在地址栏里输入http://192.168.0.125,我的zabbix安装在192.168.1.125的服务器上 此后一步步进行即可……

本文出自 “大花猫博客” 博客,请务必保留此出处http://bighuamao.blog.51cto.com/1995527/772428
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: