1. 程式人生 > >CentOS 7.1安裝zabbix

CentOS 7.1安裝zabbix

create quit gen name 主機名 bpa ase .tar.gz localhost

# yum install zabbix-2.4.6-1.el7.x86_64.rpm zabbix-server-2.4.6-1.el7.x86_64.rpm zabbix-server-mysql-2.4.6-1.el7.x86_64.rpm zabbix-agent-2.4.6-1.el7.x86_64.rpm zabbix-sender-2.4.6-1.el7.x86_64.rpm zabbix-web-2.4.6-1.el7.noarch.rpm zabbix-get-2.4.6-1.el7.x86_64.rpm zabbix-web-mysql-2.4.6-1.el7.noarch.rpm trousers-0.3.11.2-4.el7_1.x86_64.rpm

說明:CentOS 7.1安裝zabbix-2.4.6-1.el7,其與trousers-0.3.11.2-3不兼容,需要升級trousers至0.3.11.2-4.el7_1。


創建數據庫:
server和proxy
shell> mysql -uroot -p<password>
mysql> create database zabbix character set utf8 collate utf8_bin;
mysql> grant all privileges on zabbix.* to [email protected]

/* */ identified by ‘<password>‘;
mysql> quit;
shell> mysql -uzabbix -p<password> zabbix < database/mysql/schema.sql
# stop here if you are creating database for Zabbix proxy
shell> mysql -uzabbix -p<password> zabbix < database/mysql/images.sql
shell> mysql -uzabbix -p<password> zabbix < database/mysql/data.sql


配置zabbix:
(1) zabbix_server
server的配置文件為zabbix_server.conf,至少應該為其配置數據庫等相關的信息;例如:
LogFile=/var/log/zabbix/zabbix_server.log
LogFileSize=0
PidFile=/var/run/zabbix/zabbix_server.pid
DBHost=172.16.100.67
DBName=zabbix
DBUser=zbxuser
DBPassword=zbxpass
DBSocket=/var/lib/mysql/mysql.sock
SNMPTrapperFile=/var/log/snmptt/snmptt.log
AlertScriptsPath=/usr/lib/zabbix/alertscripts
ExternalScripts=/usr/lib/zabbix/externalscripts



(2) 配置php環境
編輯/etc/httpd/conf.d/zabbix.conf,添加如下項。
php_value date.timezone Asia/Shanghai

啟動httpd服務:systemctl start httpd.service

訪問zabbix web
http://your_host/zabbix
登錄:Admin/zabbix

(3) 配置zabbix_agent
agent的配置文件為zaabix_agentd.conf,至少應該為其指定server的IP地址;

源碼安裝:
下載地址:http://www.zabbix.com/download.php

# tar -zxvf zabbix-2.0.0.tar.gz

創建用戶:
# groupadd zabbix
# useradd -g zabbix zabbix

註意:同時安裝了server和agent的節點上,建議其運行用戶不要相同。

創建數據庫:
server和proxy的運行都依賴於數據庫,agent則不需要。
以MySQL數據庫為例:
mysql> CREATE DATABASE zabbix CHARACTER SET utf8 COLLATE utf8_bin;
mysql> GRANT ALL ON zabbix.* TO [email protected]
/* */%‘ IDENTIFIED BY ‘zbpass‘;
# 請按需要修改用戶名和密碼;
shell> mysql -u<username> -p<password> zabbix < database/mysql/schema.sql
# 如果僅為proxy創建數據庫,只導入schema.sql即可;否則,請繼續下面的步驟;

shell> mysql -u<username> -p<password> zabbix < database/mysql/images.sql
shell> mysql -u<username> -p<password> zabbix < database/mysql/data.sql

編譯安裝zabbix:
同時安裝server和agent,並支持將數據放入mysql數據中,可使用類似如下配置命令:
./configure --enable-server --enable-agent --with-mysql --enable-ipv6 --with-net-snmp --with-libcurl --with-ssh2

如果僅安裝server,並支持將數據放入mysql數據中,可使用類似如下配置命令:
./configure --enable-server --with-mysql --with-net-snmp --with-libcurl

如果僅安裝proxy,並支持將數據放入mysql數據中,可使用類似如下配置命令:
./configure --prefix=/usr --enable-proxy --with-net-snmp --with-mysql --with-ssh2

如果僅安裝agent,可使用類似如下配置命令:
./configure --enable-agent


而後編譯安裝zabbix即可:
# make
# make install


配置zabbix:
server的配置文件為zabbix_server.conf,至少應該為其配置數據庫等相關的信息;
agent的配置文件為zaabix_agentd.conf,至少應該為其指定server的IP地址;
proxy的配置文件為zabbix_proxy.conf,至少應該為其指定proxy的主機名和server的IP,以及數據庫等相關的配置信息;


啟動zabbix:
server: zabbix_server
agent: zabbix_agentd
proxy: zabbix_proxy

CentOS 7.1安裝zabbix