在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 Latest Stable/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://lvzili.blog.51cto.com/1995527/772428
[火星人 ] Linux LNMP環境下安裝 zabbix已經有636次圍觀