Zabbix 1.8 安裝詳解
Zabbix 1.8 安裝過(guò)程還是比較漫長(zhǎng)的!
本文只記錄我的 Zabbix 1.8 的安裝過(guò)程。
以下我要在同一臺(tái)服務(wù)器上安裝 Zabbix Server、Zabbix Proxy 和 Zabbix Agent。
安裝前先配置好PHP,要求支持 php-gd、php-bcmath、php-xml、php-mysql、php-net-socket、php-mbstring,即 configure 參數(shù)中加上 --with-gd --enable-bcmath --enable-xml --with-mysql --enable-sockets --enable-mbstring。
我的配置參數(shù)如下:
- ./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
下面開(kāi)始安裝 Zabbix:
* 下載并解壓:
- wget http://prdownloads.sourceforge.net/zabbix/zabbix-1.8.tar.gz?download
- tar zxf zabbix-1.8.tar.gz
- cd zabbix-1.8
* 創(chuàng)建 zabbix 用戶組和用戶:
- groupadd zabbix
- useradd zabbix -g zabbix
* 創(chuàng)建 mysql 數(shù)據(jù)庫(kù):
- create database zabbix character set utf8;
* 創(chuàng)建 mysql 用戶:
- grant all on zabbix.* to zabbix@localhost identified by 'zabbix';
* 導(dǎo)入表和數(shù)據(jù):
- 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
#p#
* 配置編譯:
- ./configure --enable-server --enable-proxy --enable-agent --with-mysql=/usr/local/mysql/bin/mysql_config --with-net-snmp --with-libcurl
- make && make install
配置參數(shù)說(shuō)明:
--enable-server 安裝 Zabbix Server
--enable-proxy 安裝 Zabbix Proxy
--enable-agent 安裝 Zabbix Agent
--with-mysql 使用 mysql 做數(shù)據(jù)庫(kù)服務(wù)器
--with-net-snmp 支持 SNMP
--with-libcurl 支持 curl,用于 web 監(jiān)控
* 服務(wù)端口定義:
編輯 /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
* 復(fù)制配置文件:
- 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 中的數(shù)據(jù)庫(kù)用戶名和密碼:
- DBUser=zabbix
- DBPassword=zabbix
* 安裝啟動(dòng)腳本
- cp misc/init.d/gentoo/zabbix-server /etc/init.d/
- cp misc/init.d/gentoo/zabbix-agentd /etc/init.d/
添加可執(zhí)行權(quán)限:
- 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
#p#
* 添加到啟動(dòng)服務(wù):
- rc-update add zabbix-server default
- rc-update add zabbix-agentd default
* 啟動(dòng) Zabbix Server:
- /etc/init.d/zabbix-server start
我啟動(dòng)時(shí)提示錯(cuò)誤:
- zabbix_server: error while loading shared libraries: libmysqlclient.so.16: cannot open shared object file: No such file or directory
因?yàn)槲业?mysql client 庫(kù)不在系統(tǒng)默認(rèn)庫(kù)中,做以下修改后重新啟動(dòng)就可以了:
- echo /usr/local/mysql/lib/mysql/ >> /etc/ld.so.conf
- ldconfig
* 啟動(dòng) Zabbix Agentd
- /etc/init.d/zabbix-agentd start
* 復(fù)制 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;
- }
#p#
* 開(kāi)始安裝 Zabbix Web Interface
打開(kāi) http://zabbix.local/,看到提示:
Timezone for PHP is not set. Please set "date.timezone" option in php.ini.
按照提示,修改 php.ini 中時(shí)區(qū)設(shè)置:
date.timezone = Asia/Shanghai
重啟 PHP-FPM:
/etc/init.d/php-fpm restart
監(jiān)測(cè)環(huán)境時(shí)提示:
再次修改 php.ini:
post_max_size = 16M
max_execution_time = 300
mbstring.func_overload = 2
解決后按提示繼續(xù)安裝即可。
* 結(jié)束:
安裝完后直接訪問(wèn):
http://zabbix.local/
默認(rèn)用戶名和密碼是:
Admin/zabbix
到此安裝完成!
看完上面,我們都松了一個(gè)氣,Zabbix 1.8 安裝過(guò)程確實(shí)比較繁瑣,但是物有所值!
【編輯推薦】