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

實驗系統:CentOS 6.6_x86_64php

實驗前提:提早準備好編譯環境,防火牆和selinux都關閉html

實驗說明:本實驗共有4臺主機,IP及角色分配如拓撲前端

下載地址:試驗中用到mariadb軟件的下載地址,http://pan.baidu.com/s/1bnnYiMrmysql

實驗拓撲:linux

    

1、準備工做web

  1.修改hostname和hosts文件爲以下表格中內容:sql

        

    說明:mysql是zabbix數據存放主機,server是zabbix主服務主機,web是zabbix前端展現主機,agent是被監控主機。一般狀況下這四個角色能夠搭建在同一個主機上,在這個實驗裏是分開部署了。數據庫

  2.同步時間:vim

ntpdate 192.168.70.21         //地址寫你本身的時間服務器

2、安裝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

3、安裝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 //啓動服務

     查看端口,已經開始監聽了:

    

4、安裝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;
?>

    

5、安裝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

 6、添加主機

  這裏我就大致截圖一下來演示了,過程可能並不詳細:

    

    

    

    

    

  至此,演示過程所有結束,感謝你們的收看!若有問題,請聯繫QQ:82800452.

相關文章
相關標籤/搜索