特殊注明:安裝zabbix 2.4.8和2.4.6遇到2個問題,如下:找了很多解決辦法,實在無解,只能換版本,嘗試換(2.2.2正常 | 3.0.3正常)都正常,最后決定換3.0.3
1、Error connecting to database: No such file or directory
2、如圖

=========================================================
正文開始
1、安裝mysql(略過,參考mysql5.1安裝)
2、安裝php-pfm (略過,參考php-5-5-36安裝)
3、准備zabbix環境
yum -y install gcc net-snmp-devel curl-devel perl-DBI php-gd php-mysql php-bcmath php-mbstring php-xm
4、安裝zabbix
groupadd zabbix
useradd zabbix -g zabbix -s /bin/false
下載最新安裝包zabbix-3.0.3.tar.gz,解壓
cd /home/work/software/zabbix-3.0.3/database/mysql
創建和導入初始化數據庫
create database zabbix character set utf8;
grant all privileges on zabbix.* to 'zabbix'@'localhost' identified by 'zabbix' with grant option;
mysql -uroot -p zabbix < schema.sql
mysql -uroot -p zabbix < images.sql
mysql -uroot -p zabbix < data.sql
導入sql必須按照以上順序
編譯zabbix
./configure --prefix=/usr/local/zabbix --enable-server --enable-agent --with-net-snmp --with-libcurl --with-libxml2 -enable-proxy --with-mysql=/usr/local/mysql/bin/mysql_config
make ** make install
ln -s /usr/local/zabbix/sbin/* /usr/local/sbin/
添加系統啟動方式
cd /home/work/software/zabbix-3.0.3/misc/init.d/fedora/core5/
cp zabbix_* /etc/rc.d/init.d/
/etc/init.d/zabbix_server start
/etc/init.d/zabbix_agentd start
查看系統是否開放對應端口,沒有則添加zabbix服務對應的端口
vi /etc/services #編輯,在最后添加以下代碼
# Zabbix
zabbix-agent 10050/tcp # Zabbix Agent
zabbix-agent 10050/udp # Zabbix Agent
zabbix-trapper 10051/tcp # Zabbix Trapper
zabbix-trapper 10051/udp # Zabbix Trapper
配置zabbix server配置文件
vim /usr/localo/zabbix/etc/zabbix_server.conf
ListenPort=10051
SourceIP=
serveripaddr
### Option: Mysql
DBHost=localhost
DBName=zabbix
DBUser=zabbix
DBPassword=zabbix
DBSocket=/var/run/mysqld/mysql.socket
DBPort=3306
AlertScriptsPath=${datadir}/zabbix/alertscripts #腳本存放路徑
修改php配置文件參數
vim /etc/php.ini #編輯修改
post_max_size =16M
max_execution_time =300
max_input_time =300
date.timezone = "Asia/Shanghai"
准備web站點
cp -r /usr/local/src/zabbix-3.0.3/frontends/php /data/web/zabbix.gvppp.com/zabbix
chown nginx.nginx -R /data/web/zabbix.gvppp.com/zabbix
5、nginx安裝
下載pcre
wget http://jaist.dl.sourceforge.net/project/pcre/pcre/8.34/pcre-8.34.zip
安裝
./configure --prefix=/usr/local/pcre
make && make install
tar xf nginx-1.6.2.tar.gz
./configure --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-http_gzip_static_module --with-http_ssl_module --with-pcre=../pcre-8.34 --user=nginx --group=nginx
make && make install
nginx設置
vim nginx.conf
user nginx;
worker_processes 4;
#error_log logs/error.log warning;
#error_log logs/error.log notice;
error_log logs/error.log info;
pid logs/nginx.pid;
events {
use epoll;
worker_connections 65535;
}
http {
include mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
#access_log logs/access.log main;
sendfile on;
tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 60;
gzip on;
gzip_min_length 1k;
gzip_buffers 4 16k;
gzip_http_version 1.0;
gzip_comp_level 2;
gzip_types text/plain application/x-javascript text/css application/xml;
gzip_vary on;
include /usr/local/nginx/vhosts/*.conf;
}
虛擬主機配置文件
vim zabbix.conf
server {
listen 8001;
server_name zabbix.gvppp.com;
access_log /data/logs/zabbix/zabbix.gvppp.com.access.log main;
index index.html index.php index.html;
root /data/web/zabbix.gvppp.com;location /{
try_files $uri $uri/ /index.php?$args;
}location ~ ^(.+.php)(.*)$ {
fastcgi_split_path_info ^(.+.php)(.*)$;
include fastcgi.conf;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param PATH_INFO $fastcgi_path_info;
}}
server {
listen 8001;
server_name zabbix.gvppp.com;
access_log /data/logs/zabbix/zabbix.gvppp.com.access.log main;
index index.html index.php index.html;
root /data/web/zabbix.gvppp.com;location /{
try_files $uri $uri/ /index.php?$args;
}location ~ ^(.+.php)(.*)$ {
fastcgi_split_path_info ^(.+.php)(.*)$;
include fastcgi.conf;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param PATH_INFO $fastcgi_path_info;
}}
記得修改linux系統打開文件數
ulimt -n #臨時修改
6、zabbxi客戶端安裝
下載zabbix-3.0.3.tar.gz
./configure --divfix=/usr/local/zabbix --sysconfdir=/usr/local/zabbix/etc --enable-agent --with-net-snmp
make && make install
cp misc/init.d/fedora/core5/zabbix_agentd /etc/rc.d/init.d/zabbix_agentd
ln -s /usr/local/zabbix/sbin/* /usr/local/sbin
7、zabbix代理安裝
./configure --prefix=/usr/local/zabbix --enable-agent -enable-proxy --with-mysql --with-net-snmp --with-libcurl --sysconfdir=/usr/local/zabbix/etc
make && make install
vim zabbix_proxy.conf
ProxyMode=0 #0代理使用主動模式
Server=ipaddr
serveripaddr #zabbix server ipaddr
ServerPort=10051 #zabbix server port
ListenPort=10051 #監控port
DBHost=
DBName=
DBUser=
DBPassword=
DBSocket=
DBPort=
proxy連接的mysql的配置信息
ConfigFrequency=300 #proxy從server獲取配置數據的頻率,秒
DataSenderFrequency=60 #proxy將監控到的數據發送給server的頻率,秒
AllowRoot=1 #允許root執行
=======================================================
zabbix部署過程中遇到的問題以及排錯:
1、遇到打開setup.php安裝頁面 next step 操作無法調整到下一個頁面時
網絡解決辦法:
修改/var/lib/php/session/ 屬組[nginx]和添加777權限
修改php.ini 更改 session.save_path = "/var/lib/php/session"
然后再刷新頁面即可
2、Error connecting to database: No such file or directory

將 Database host 的localhost改為127.0.0.1
3、Unable to create the configuration file.

點擊 Download the configuration file 進行下載配置文件
在上傳到web站點下
/opt/www/zabbix/conf
4、date.timezone 找不到
vim php.ini
date.timezone = "Asia/Shanghai"
5、web里面顯示“zabbix server is not running”
1). selinux是否關閉
執行命令setenforce 0
2). zabbix web目錄下面 $ZBX_SERVER 是否為ip,如果是localhost,ping下localhost是否能解析。如果不能,需要在/etc/hosts文件里增加相應的項目
3). 查看php的fsockopen模塊是否啟用
php.ini文件中查找
allow_url_fopen = On
使其值為On
讓你的php支持 opensll擴展。
默認,是沒有openssl擴展的,只能重新編譯安裝。
yum install openssl openssl-devel
cd /usr/local/src/php-5.2.14/ext/openssl
/usr/local/php/bin/phpize
------------
/usr/local/php/bin/phpize 執行報錯
Cannot find config.m4.
Make sure that you run '/usr/local/php/bin/phpize' in the top level source directory of the module
解決辦法
cp config0.m4 config.m4 即可
------------
./configure –with-openssl –with-php-config=/usr/local/bin/php-config
make && make install
看提示,把編譯成的openssl.so 拷貝到你在php.ini 中指定的 extension_dir 下
php.ini加入
extension=openssl.so
重啟web server
6、[Z3001] connection to database 'zabbix' failed: [1045] Access denied for use
插件zabbix_server.conf mysql配置項是否正確
7、Received empty response from Zabbix Agent at [127.0.0.1]. Assuming that agent dropped connection because of access permissions
如果服務端是多個IP,需要修改zabbix_agentd.conf
server為多個IP,用逗號隔開
8、zabbix_agentd [9131]: cannot run as root!
修改zabbix_agentd.conf中的
AllowRoot=1
1表示允許root 0表示不允許root
9、Zabbix discoverer processes more than 75% busy
修改zabbix_server.conf里面的,根據系統性能修改,這里我改為10
StartDiscoverers=10
10、

首先檢查selinux是否關閉
再修改zabbix_conf.php 把localhost改成IP即可
$ZBX_SERVER = '
serveripaddr';
11、Zabbix poller processes more than 75% busy
StartPollers=50 可以改大這個值
12、Lack of free swap space on hostname
修改temp模版觸發器的判斷參數
{Base_OS Linux:system.swap.size[,pfree].last(0)}<10
修改為
{Base_OS Linux:system.swap.size[,pfree].last(0)}<10 and {Base_OS Linux:system.swap.size[,free].last(0)}<>0
13、agent安裝編譯錯誤 configure: error: cannot run C compiled programs.
GCC編譯環境有問題
14、failed: first network error, wait for 15 seconds
服務器性能處理不過來,修改zabbix_server.conf
Timeout=30或者小於30
15、zabbix graph 中文顯示亂碼
先從window系統拷貝ttf字體到zabbix web
/www/zabbix/fonts/
再修改web代碼
vim /www/zabbix/include/defines.inc.php
vim /www/zabbix/include/defines.inc.php
找到DejaVuSans,並改成上傳的字體文件名,不加ttf 即可
//define('ZBX_GRAPH_FONT_NAME', 'DejaVuSans'); // font file name
//define('ZBX_FONT_NAME', 'DejaVuSans');
16、zabbix 自動發現遇到模版不自動連接,最后發現是因為
有一個item監控項在兩個模版里面沖突了,刪掉一個即可
另:客戶端設置主動模式,不用在configuration 配置discovery
17、報警郵件無法發送,日志報錯:Support for SMTP authentication was not compiled in
網上查找原因:libcurl版本過低,需要7.20.0或者更高版本的curl
rpm -Uvh
http://www.city-fan.org/ftp/contrib/yum-repo/rhel6/x86_64/city-fan.org-release-1-13.rhel6.noarch.rpm
yum install libcurl
安裝完以后需要重新編譯zabbix server
帶上--with-libcurl參數
然后重啟服務器恢復正常
18、More than 100 items having missing data for more than 10 minutes
可以查看Queue是不是厲害很大,徹底解決還需要優化zabbix
希望能對遇到同樣問題的童鞋有所幫助,也是自己對zabbix研究的一個總結,后續持續更新......
如果有什么錯誤的地方還請大家指出!!!共同學習...