天天看點

CentOS6.5 編譯安裝zabbix3.0.5,編譯安裝zabbix_agent用戶端

1、環境準備:

CentOS6.5 目前位址為192.168.137.30

搭建LAMP環境,YUM安裝方式也可以,但是zabbix3.0要求提供PHP5.5以上版本。

還需要重新編譯PHP5.5,主要是提供最後三個參數。

#編譯前先安裝如下開發元件

<code># yum groupinstall "Development tools" "Server Platform Development"</code>

<code># yum install -y curl-devel mysql-devel net-snmp-devel ##編譯zabbix是需要提供的3個包</code>

<code># yum -y install libjpeg-devel libpng-devel freetype-devel  ##PHP編譯需要這3個包</code>

<code># tar zxf php-5.5.38.tar.gz</code>

<code># cd php-5.5.38</code>

<code># ./configure --prefix=/usr/local/php --with-mysql=/usr/local/mysql --with-openssl --with-mysqli=/usr/local/mysql/bin/mysql_config --enable-mbstring --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml  --enable-sockets --with-apxs2=/usr/local/apache/bin/apxs --with-mcrypt  --with-config-file-path=/etc --with-config-file-scan-dir=/etc/php.d --with-bz2  --enable-maintainer-zts --enable-bcmath --with-gd  --with-gettext</code>

<code>###--enable-bcmath --with-gd  --with-gettext 需要加這幾項,否則滿足不了zabbix3.0的最低需求。</code>

<code># make &amp;&amp; make install </code>

<code># cp php.ini-production /etc/php.ini</code>

##配置PHP參數,滿足zabbix_server最低配置需求。

<code># vim /etc/php.ini</code>

<code>date</code><code>.timezone = Asia</code><code>/Shanghai</code> <code>##時區</code>

<code>max_execution_time = 300</code>

<code>post_max_size = 16M</code>

<code>max_input_time = 300</code>

<code>mbstring.func_overload = 0</code>

2、編譯安裝zabbix3.0

下載下傳zabbix3.0.5

1)建立系統組,使用者:

<code># groupadd -g 201 zabbix</code>

<code># useradd -g zabbix -u 201 -s /sbin/nologin zabbix</code>

2)編譯安裝

<code># tar zxf zabbix-3.0.5.tar.gz</code>

<code># cd zabbix-3.0.5</code>

<code># ./configure --prefix=/usr/local/zabbix --enable-server --enable-proxy --enable-agent --with-mysql=/usr/bin/mysql_config --with-net-snmp --with-libcurl</code>

<code># make &amp;&amp; make install</code>

3)建立 zabbix 資料庫以及相關表

<code>## 登陸資料庫</code>

<code># create database zabbix default charset utf8;</code>

<code># grant all on zabbix.* to zabbix@localhost identified by 'zabbix';</code>

<code>##導入zabbix的表資料結構</code>

<code># mysql -uzabbix -pzabbix zabbix&lt;./database/mysql/schema.sql</code>

<code># mysql -uzabbix -pzabbix zabbix&lt;./database/mysql/images.sql</code>

<code># mysql -uzabbix -pzabbix zabbix&lt;./database/mysql/data.sql</code>

4)連結zabbix配置檔案

<code># mkdir /var/log/zabbix</code>

<code># chown zabbix.zabbix /var/log/zabbix</code>

<code># ln -s /usr/local/zabbix/etc/ /etc/zabbix</code>

<code># ln -s /usr/local/zabbix/bin/* /usr/bin/</code>

<code># ln -s /usr/local/zabbix/sbin/* /usr/sbin/</code>

<code># cp -a /root/zabbix-3.0.5/misc/init.d/fedora/core/zabbix_* /etc/init.d</code>

<code># chmod 755 /etc/init.d/zabbix_*</code>

5)修改zabbix配置檔案

#修改/etc/init.d 目錄下的 zabbix_server 和 zabbix_agentd 啟動檔案

<code># vim /etc/init.d/zabbix_server</code>

<code>  </code><code>BASEDIR=</code><code>/usr/local/zabbix</code>

<code># vim /etc/init.d/zabbix_agentd </code>

<code>##也可以使用sed替換</code>

<code># sed -i "s@BASEDIR=/usr/local@BASEDIR=/usr/local/zabbix@g" /etc/init.d/zabbix_server</code>

<code># sed -i "s@BASEDIR=/usr/local@BASEDIR=/usr/local/zabbix@g" /etc/init.d/zabbix_agentd</code>

#修改zabbix主配置檔案

<code># vim /etc/zabbix/zabbix_server.conf</code>

<code>DBUser=zabbix</code>

<code>DBPassword=zabbix</code>

<code>DBSocket=</code><code>/tmp/mysql</code><code>.sock </code><code>#去掉前面;開啟,預設不啟用</code>

#修改zabbix_agentd.conf配置檔案,192.168.137.30為zabbix_server伺服器。

<code># vim /etc/zabbix/zabbix_agentd.conf</code>

<code>LogFile=</code><code>/var/log/zabbix/zabbix_agentd</code><code>.log</code>

<code>Server=127.0.0.1,192.168.137.30</code>

<code>ServerActive=192.168.137.30:10051 </code><code>##在主動模式下,ServerActive為二級代理伺服器或伺服器,預設端口為10051</code>

<code>Hostname= 192.168.137.30</code>

<code>UnsafeUserParameters=1 </code><code>##是否啟用使用者自定義監控腳本,1啟用,0不啟用</code>

6)複制zabbix安裝程式到apache的DocumentRoot目錄下。設定自啟動,并啟動服務

<code># cp -a ~/zabbix-3.0.5/frontends/php/ /usr/local/apache/htdocs/zabbix</code>

<code># chown -R apache.apache /usr/local/apache/htdocs/zabbix</code>

<code># chkconfig zabbix_server on</code>

<code># chkconfig zabbix_agentd on</code>

<code># service zabbix_server start</code>

<code>Starting zabbix_server: [ OK ]</code>

<code># service zabbix_agentd start</code>

<code>Starting zabbix_agentd: [ OK ]</code>

#如圖:ss-LISTEN 啟動成功

<a href="http://s3.51cto.com/wyfs02/M02/89/C1/wKioL1gb8tyCXxUcAABuuN8hDEU386.png" target="_blank"></a>

3、接下來web端配置zabbix

浏覽器輸入:http://192.168.137.30/zabbix/setup.php

第一步:歡迎界面Next step

<a href="http://s5.51cto.com/wyfs02/M02/89/C1/wKioL1gb82WzEwdWAACJsY8HlrY711.png" target="_blank"></a>

第二步:檢查先決條件,必須要滿足,否則無法Next step

<a href="http://s5.51cto.com/wyfs02/M02/89/C4/wKiom1gb9M6BqlRYAACFNU31Rhk300.png" target="_blank"></a>

第三步:配置資料庫,輸入密碼

登陸位址  http://192.168.137.30/zabbix/index.php

如圖First_page 

<a href="http://s1.51cto.com/wyfs02/M01/89/C1/wKioL1gb9s3QQvXyAADOr4uFm4I177.png" target="_blank"></a>

#注釋,PHP gettest擴充功能,重新編譯一下PHP加上參數:--with-gettext

中文設定:Chinese_set

<a href="http://s1.51cto.com/wyfs02/M02/89/C4/wKiom1gb99OS_uvPAACOpmYKWL0165.png" target="_blank"></a>

至此zabbix安裝已經結束,現在來看看自動發現的本機

如圖:

<a href="http://s5.51cto.com/wyfs02/M00/89/C1/wKioL1gb-HWyVXzKAADZIUAQIzo823.png" target="_blank"></a>

<a href="http://s3.51cto.com/wyfs02/M01/89/C1/wKioL1gb-HaCJ18gAADadusk3bY167.png" target="_blank"></a>

zabbix_agent3.0用戶端編譯安裝,及裝置添加

本文轉自 ljohnmail 51CTO部落格,原文連結:http://blog.51cto.com/ljohn/1869257,如需轉載請自行聯系原作者