歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
您现在的位置: Linux教程網 >> UnixLinux >  >> Linux基礎 >> 關於Linux

編譯安裝zabbix 3.0及分開部署配置詳解

實驗系統:CentOS 6.6_x86_64   實驗前提:提前准備好編譯環境,防火牆和selinux都關閉   實驗說明:本實驗共有4台主機,IP及角色分配如拓撲   下載地址:試驗中用到mariadb軟件的下載地址,http://pan.baidu.com/s/1bnnYiMr   實驗拓撲: 一、准備工作   1.修改hostname和hosts文件為如下表格中內容: 說明:mysql是zabbix數據存放主機,server是zabbix主服務主機,web是zabbix前端展示主機,agent是被監控主機。通常情況下這四個角色可以搭建在同一個主機上,在這個實驗裡是分開部署了。   2.同步時間:   ntpdate 192.168.70.21         //地址寫你自己的時間服務器 二、安裝mysql服務器   1.在mysql.jason.com主機上安裝mysql:  
tar xf mariadb-10.0.20-linux-x86_64.tar.gz  -C /usr/local/
cd /usr/local/
ln -sv mariadb-10.0.20-linux-x86_64 mysql
useradd -r mysql
mkdir -pv /mydata/data
chown -R mysql.mysql /mydata/data/
cd mysql/
chown -R root.mysql .
scripts/mysql_install_db --user=mysql --datadir=/mydata/data/
cp support-files/my-large.cnf /etc/my.cnf
cp support-files/mysql.server /etc/init.d/mysqld
chkconfig --add mysqld
chkconfig mysqld on

 

2.編輯配置文件並啟動:  
vim /etc/my.cnf
----------------------------------------------->
[mysqld]
datadir = /mydata/data            //增加此行
<-----------------------------------------------
service mysqld start

 

  3.創建zabbix數據庫和授權用戶:  
/usr/local/mysql/bin/mysql
------------------------------------>
CREATE DATABASE zabbix;
GRANT ALL ON zabbix.* TO 'zabbix'@'192.168.19.%' IDENTIFIED BY '123456';
GRANT ALL ON zabbix.* TO 'zabbix'@'localhost' IDENTIFIED BY '123456';
GRANT ALL ON zabbix.* TO 'zabbix'@'mysql.jason.com' IDENTIFIED BY '123456';
FLUSH PRIVILEGES;

 

  4.導入數據庫文件:  
wget http://iweb.dl.sourceforge.net/project/zabbix/ZABBIX%20Latest%20Development/3.0.0alpha2/zabbix-3.0.0alpha2.tar.gz
tar xf zabbix-3.0.0alpha2.tar.gz
cd zabbix-3.0.0alpha2/database/mysql/
/usr/local/mysql/bin/mysql -uzabbix -p123456 zabbix < schema.sql           //導入順序不能錯
/usr/local/mysql/bin/mysql -uzabbix -p123456 zabbix < images.sql
/usr/local/mysql/bin/mysql -uzabbix -p123456 zabbix < data.sql

 

  三、安裝Zabbix-Server服務器   1.在server.jason.com主機上編譯安裝zabbix:  
yum -y install mysql-devel libxml2-devel net-snmp-devel libcurl-devel
wget http://iweb.dl.sourceforge.net/project/zabbix/ZABBIX%20Latest%20Development/3.0.0alpha2/zabbix-3.0.0alpha2.tar.gz
tar xf zabbix-3.0.0alpha2.tar.gz
cd zabbix-3.0.0alpha2
groupadd zabbix
useradd -g zabbix zabbix
./configure --prefix=/usr/local/zabbix-server --enable-server --with-mysql --with-net-snmp --with-libcurl --with-libxml2
make install

 

  2.編輯配置文件並啟動:  
mkdir /var/log/zabbix
chown -R zabbix:zabbix /var/log/zabbix
vim /usr/local/zabbix-server/etc/zabbix_server.conf
------------------------------------------------------------->
LogFile=/var/log/zabbix/zabbix_server.log
DBHost=192.168.19.66
DBName=zabbix
DBUser=zabbix
DBPassword=123456
ListenIP=127.0.0.1,192.168.19.74
<-------------------------------------------------------------
/usr/local/zabbix-server/sbin/zabbix_server -c /usr/local/zabbix-server/etc/zabbix_server.conf       //啟動服務

 

查看端口,已經開始監聽了: 四、安裝Zabbix-Web服務器   1.在web.jason.com主機上安裝httpd和php:  
yum -y install httpd php php-mysql libXpm php-bcmath php-gd php-mbstring php-xml t1lib
mkdir /var/www/html/zabbix
wget http://iweb.dl.sourceforge.net/project/zabbix/ZABBIX%20Latest%20Development/3.0.0alpha2/zabbix-3.0.0alpha2.tar.gz
tar xf zabbix-3.0.0alpha2.tar.gz
cd zabbix-3.0.0alpha2/frontends/php/
cp -a . /var/www/html/zabbix/

 

  2.配置php並啟動httpd:    
vim /etc/php.ini
----------------------------------------->
date.timezone = Asia/Shanghai
post_max_size = 16M
max_execution_time = 300
max_input_time = 300
----------------------------------------->
service httpd start

 

  用浏覽器訪問http://192.168.19.76/zabbix,並按照提示安裝:

這裡出現權限報錯,將配置文件下載下來保存到/var/www/html/zabbix/conf/zabbix.conf.php文件中。如果手動寫入配置文件之後如果還報錯,可以忽略,將浏覽器關閉並重新打開連接即可。登錄賬號admin,登錄密碼zabbix:
vim /var/www/html/zabbix/conf/zabbix.conf.php     //手動寫入配置
---------------------------------------------------------->
<?php
// Zabbix GUI configuration file.
global $DB;

$DB['TYPE']     = 'MYSQL';
$DB['SERVER']   = '192.168.19.66';
$DB['PORT']     = '0';
$DB['DATABASE'] = 'zabbix';
$DB['USER']     = 'zabbix';
$DB['PASSWORD'] = '123456';

// Schema name. Used for IBM DB2 and PostgreSQL.
$DB['SCHEMA'] = '';

$ZBX_SERVER      = '192.168.19.74';
$ZBX_SERVER_PORT = '10051';
$ZBX_SERVER_NAME = '';

$IMAGE_FORMAT_DEFAULT = IMAGE_FORMAT_PNG;
?>

 

五、安裝Zabbix-Agent端   1.在agent.jason.com主機上安裝:    
wget http://iweb.dl.sourceforge.net/project/zabbix/ZABBIX%20Latest%20Development/3.0.0alpha2/zabbix-3.0.0alpha2.tar.gz
tar xf zabbix-3.0.0alpha2.tar.gz 
cd zabbix-3.0.0alpha2
groupadd zabbix-agent
useradd -g zabbix-agent zabbix-agent
./configure --prefix=/usr/local/zabbix-agent --enable-agent
make install

 

  2.編輯配置文件:    
mkdir /var/log/zabbix
chown -R zabbix-agent:zabbix-agent /var/log/zabbix/
vim /usr/local/zabbix-agent/etc/zabbix_agentd.conf
------------------------------------------------------------>
LogFile=/var/log/zabbix/zabbix_agentd.log
Server=192.168.19.74
ServerActive=192.168.19.74
Hostname=agent.jason.com
User=zabbix-agent
<------------------------------------------------------------
/usr/local/zabbix-agent/sbin/zabbix_agentd -c /usr/local/zabbix-agent/etc/zabbix_agentd.conf

 

 六、添加主機   這裡我就大體截圖一下來演示了,過程可能並不詳細:



Copyright © Linux教程網 All Rights Reserved