Linux教程網
Linux教程網
Linux教程網
您现在的位置: Linux教程網 >> UnixLinux >  >> Linux管理 >> Linux 設定

Zabbix 2.0 服務端與 Agent 安裝配置全流程

一、安裝依賴並建立帳號

yum install make mysql-server httpd php mysql-devel gcc net-snmp-devel \
 curl-devel perl-DBI php-gd php-mysql php-bcmath php-mbstring php-xml -y
useradd zabbix

二、啟動 MySQL 並建立資料庫

service mysqld start
mysqladmin -uroot password root
mysql -uroot -proot

create database zabbix character set utf8;
grant all on zabbix.* TO zabbix@'localhost' identified by 'zabbixpass';
flush privileges;

三、匯入初始資料

cd zabbix-2.0.3/database/mysql
mysql -h localhost -uroot -proot zabbix <schema.sql
mysql -h localhost -uroot -proot zabbix <images.sql
mysql -h localhost -uroot -proot zabbix <data.sql

四、編譯安裝

./configure --with-mysql --with-net-snmp --with-libcurl \
 --enable-server --enable-agent --enable-proxy --prefix=/usr/local/zabbix
make && make install

五、補充服務埠定義

vi /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

六、配置文件與啟動腳本

cp -a frontends/php/* /var/www/html/

修改 /etc/httpd/conf/httpd.conf,讓 DirectoryIndex 包含 index.php:

DirectoryIndex index.html index.html.var index.php

修改 /usr/local/zabbix/etc/zabbix_server.conf:

DBName=zabbix
DBUser=zabbix
DBPassword=zabbix

安裝 init 腳本並修正二進位路徑:

cp misc/init.d/fedora/core5/zabbix_server /etc/init.d/
cp misc/init.d/fedora/core5/zabbix_agentd /etc/init.d/
chmod 700 /etc/init.d/zabbix_*

# 兩個腳本中的 ZABBIX_BIN 需由 /usr/local/sbin/ 改為 /usr/local/zabbix/sbin/
vim /etc/init.d/zabbix_server
vim /etc/init.d/zabbix_agentd

七、啟動與開機自啟

/etc/init.d/zabbix_server start
/etc/init.d/zabbix_agentd start
chkconfig zabbix_server on
chkconfig zabbix_agentd on

八、調整 PHP 參數

vi /etc/php.ini
max_execution_time = 300
max_input_time = 300
date.timezone = PRC
post_max_size = 32M
/etc/init.d/httpd restart

注意前面若有分號註解需刪除。

九、圖形化安裝

瀏覽器訪問伺服器,精靈會把配置寫入 /var/www/html/zabbix/conf/zabbix.conf.php,看到 created: OK 即完成。預設帳號密碼均為 zabbix,登入後點右上角 profile 可把語言切換為中文。

常見問題:圖表中文亂碼

這是字型缺失造成,替換字型即可:

cd /var/www/html/zabbix/fonts/
cp -frp DejaVuSans.ttf DejaVuSans.ttf.old
cp /tmp/simhei.ttf DejaVuSans.ttf

Agent 端配置

useradd zabbix -s /sbin/nologin
cd /opt && mkdir zabbixagent
mv /opt/src/zabbix_agents_2.0.3.linux2_6.amd64.tar.gz /opt/zabbixagent
cd /opt/zabbixagent
tar xvf zabbix_agents_2.0.3.linux2_6.amd64.tar.gz
mkdir logs etc
chown zabbix:zabbix /opt/zabbixagent

從 Server 端複製 zabbix_agentd.conf 到 etc 目錄後修改:

LogFile=/opt/zabbixagent/logs/zabbix_agentd.log
Server=172.16.8.82
#ServerActive=172.16.8.82
Hostname=web81

關鍵提醒:Agent 端的 Hostname 必須與 Server 上新增主機時填的名稱完全一致,否則日誌會出現 host {主機名} not found。

/opt/zabbixagent/sbin/zabbix_agentd -c /opt/zabbixagent/etc/zabbix_agentd.conf &
Copyright © Linux教程網 All Rights Reserved