centos6.5編譯安裝zabbix3.0和中文支援整理文檔

來源:互聯網
上載者:User

標籤:

編者按:

  最近公司部分業務遷移機房,為了更方便的監控管理主機資源,決定上線zabbix監控平台。營運人員使用2.4版本的進行部署,個人在業餘時間嘗鮮,使用zabbix3.0進行部署,整理文檔如下,僅供參考!

1. LNMP基礎環境搭建:

  nginx-1.9.11環境編譯安裝:參考 http://www.cnblogs.com/songqingbo/articles/5355025.html  

  

    location / {      root   html;      index  index.php index.html index.htm;    }    error_page   500 502 503 504  /50x.html;    location = /50x.html {      root   html;    }    location ~ \.(php|php5)?$ {      root   /usr/local/nginx/html/zabbix;      fastcgi_pass   127.0.0.1:9000;      fastcgi_index  index.php;       # fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;      fastcgi_param  SCRIPT_FILENAME  /usr/local/nginx/html$fastcgi_script_name;      includefastcgi_params;      }    

  mysql-5.6.20編譯安裝:參考 http://www.cnblogs.com/songqingbo/articles/5355025.html 

  php-5.6編譯安裝:

   依賴環境 

1.yum -y install zlib-devel libxml2-devel libjpeg-devel libiconv-devel freetype-devel libpng-devel gd-devel curl-devel libxslt-devel2.wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.14.tar.gztar zxf libiconv-1.14.tar.gz && cd libiconv-1.14 && ./configure --prefix=/usr/local/libiconv && make && make install && cd ../3.yum -y install libmcrypt-devel mhash mcrypt

  編譯安裝:

./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --with-mysql=/usr/local/mysql/ --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-iconv-dir=/usr/local/libiconv --with-freetype-dir --with-bz2 --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --with-xmlwriter-dir=/usr --with-xmlreader-dir=/usr --with-libdir=lib64 --with-gettext --enable-xml --disable-rpath --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --enable-mbregex --enable-fpm --enable-mbstring --with-mcrypt --with-gd --enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-soap --enable-short-tags --enable-static --with-xsl --with-fpm-user=nginx --with-fpm-group=nginx --enable-ftp --enable-opcache=no 

make && make install

  配置php設定檔:

vim /application/php/lib/php.ini 主要為下面幾個參數PHP option post_max_size 16MPHP option max_execution_time 300PHP option max_input_time 300PHP time zone Asia/Shanghai

  配置啟動指令碼: /etc/init.d/php-fpm   chmod +x  /etc/init.d/php-fpm && chkconfig php-fpm on

#!/bin/sh  # DateTime: 2013-09-16# Author: lianbaikai# site:http://www.ttlsa.com/html/3039.html# chkconfig:   - 84 16   # Source function library.  . /etc/rc.d/init.d/functions   # Source networking configuration.  . /etc/sysconfig/network   # Check that networking is up.  [ "$NETWORKING" = "no" ] && exit 0   phpfpm="/usr/local/php/sbin/php-fpm"  prog=$(basename ${phpfpm})   lockfile=/var/lock/subsys/phpfpm start() {      [ -x ${phpfpm} ] || exit 5      echo -n $"Starting $prog: "      daemon ${phpfpm}    retval=$?      echo      [ $retval -eq 0 ] && touch $lockfile      return $retval  }   stop() {      echo -n $"Stopping $prog: "      killproc $prog -QUIT      retval=$?      echo      [ $retval -eq 0 ] && rm -f $lockfile      return $retval  }   restart() {      configtest || return $?      stop      start  }   reload() {      configtest || return $?      echo -n $"Reloading $prog: "      killproc ${phpfpm} -HUP      RETVAL=$?      echo  }   force_reload() {      restart  }   configtest() {    ${phpfpm} -t}   rh_status() {      status $prog  }   rh_status_q() {      rh_status >/dev/null 2>&1  }   case "$1" in      start)          rh_status_q && exit 0          $1          ;;      stop)          rh_status_q || exit 0          $1          ;;      restart|configtest)          $1          ;;      reload)          rh_status_q || exit 7          $1          ;;      status)          rh_status          ;;      *)          echo $"Usage: $0 {start|stop|status|restart|reload|configtest}"          exit 2  esac

2. 編譯安裝zabbix_server

 源碼包下載

cd /usr/local/src && wget http://jaist.dl.sourceforge.net/project/zabbix/ZABBIX%20Latest%20Stable/3.0.0/zabbix-3.0.0.tar.gz 

 依賴環境

yum install net-snmp-devel OpenIPMI-devel openssl-devel fping-devel libcurl-devel perl-DBI gcc -y

 添加使用者

mkdir -p /usr/local/zabbix3.0/lib/useradd -d /usr/local/zabbix3.0/lib/zabbix -s /sbin/nologin zabbix

  編譯安裝

./configure --prefix=/usr/local/zabbix3.0 --enable-server  --enable-agent --with-mysql --enable-ipv6 --with-net-snmp--with-libcurl --with-libxml2 && make install

  許可權

chown –R zabbix.zabbix /usr/local/zabbix3.0

  增加連接埠

vim /etc/serviceszabbix-agent 10050/tcp # Zabbix Agentzabbix-agent 10050/udp # Zabbix Agentzabbix-trapper 10051/tcp # Zabbix Trapperzabbix-trapper 10051/udp # Zabbix Trapper

  資料庫初始化

mysql> create database zabbix characterset utf8;mysql> grant all on zabbix.* to ‘zabbix‘@‘127.0.0.1‘ identified by ‘zabbixtest‘ with grant option;mysql> flush privileges;mysql -uroot -p zabbix < /usr/local/src/zabbix-3.0.0/database/mysql/schema.sqlmysql -uroot -p zabbix < /usr/local/src/zabbix-3.0.0/database/mysql/images.sqlmysql -uroot -p zabbix < /usr/local/src/zabbix-3.0.0/database/mysql/data.sql

  設定檔識別:/usr/local/zabbix3.0/etc/zabbix_server.conf   zabbix_agentd.conf

  配置啟動指令碼:

zabbix_server

#!/bin/bash##       /etc/rc.d/init.d/zabbix_server## Starts the zabbix_server daemon## chkconfig: - 95 5# description: Zabbix Monitoring Server# processname: zabbix_server# pidfile: /tmp/zabbix_server.pid# Modified for Zabbix 2.0.0# May 2012, Zabbix SIA# Source function library.. /etc/init.d/functionsRETVAL=0prog="Zabbix Server"ZABBIX_BIN="/usr/local/zabbix3.0/sbin/zabbix_server"if [ ! -x ${ZABBIX_BIN} ] ; then        echo -n "${ZABBIX_BIN} not installed! "        # Tell the user this has skipped        exit 5fistart() {        echo -n $"Starting $prog: "        daemon $ZABBIX_BIN        RETVAL=$?        [ $RETVAL -eq 0 ] && touch /var/lock/subsys/zabbix_server        echo}stop() {        echo -n $"Stopping $prog: "        killproc $ZABBIX_BIN        RETVAL=$?        [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/zabbix_server        echo}case "$1" in  start)        start        ;;  stop)        stop        ;;  reload|restart)        stop        sleep 10        start        RETVAL=$?        ;;  condrestart)        if [ -f /var/lock/subsys/zabbix_server ]; then            stop            start        fi        ;;  status)        status $ZABBIX_BIN        RETVAL=$?        ;;  *)        echo $"Usage: $0 {condrestart|start|stop|restart|reload|status}"        exit 1esacexit $RETVAL

  zabbix_agentd

#!/bin/bash##       /etc/rc.d/init.d/zabbix_agentd## Starts the zabbix_agentd daemon## chkconfig: - 95 5# description: Zabbix Monitoring Agent# processname: zabbix_agentd# pidfile: /tmp/zabbix_agentd.pid# Modified for Zabbix 2.0.0# May 2012, Zabbix SIA# Source function library.. /etc/init.d/functionsRETVAL=0prog="Zabbix Agent"ZABBIX_BIN="/usr/local/zabbix3.0/sbin/zabbix_agentd"if [ ! -x ${ZABBIX_BIN} ] ; then        echo -n "${ZABBIX_BIN} not installed! "        # Tell the user this has skipped        exit 5fistart() {        echo -n $"Starting $prog: "        daemon $ZABBIX_BIN        RETVAL=$?        [ $RETVAL -eq 0 ] && touch /var/lock/subsys/zabbix_agentd        echo}stop() {        echo -n $"Stopping $prog: "        killproc $ZABBIX_BIN        RETVAL=$?        [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/zabbix_agentd        echo}case "$1" in  start)        start        ;;  stop)        stop        ;;  reload|restart)        stop        sleep 10        start        RETVAL=$?        ;;  condrestart)        if [ -f /var/lock/subsys/zabbix_agentd ]; then            stop            start        fi        ;;  status)        status $ZABBIX_BIN        RETVAL=$?        ;;  *)        echo $"Usage: $0 {condrestart|start|stop|restart|reload|status}"        exit 1esacexit $RETVAL

  其他相關配置參考:

http://www.tuicool.com/articles/JRVVniM http://www.mamicode.com/info-detail-1223031.htmlhttp://www.360doc.com/content/14/0330/19/8085797_364996162.shtml

  配置中文支援參考:http://www.ttlsa.com/zabbix/zabbix-display-chinese/ 

 

3.zabbix_proxy安裝配置:

  編譯安裝同server,增加一個新的參數--enable-proxy

  zabbix_proxy啟動指令碼

#!/bin/sh# chkconfig: 345 95 95# desctription: Zabbix Proxy# Zabbix# Copyright (C) 2001-2013 Zabbix SIA## This program is free software; you can redistribute it and/or modify# it under the terms of the GNU General Public License as published by# the Free Software Foundation; either version 2 of the License, or# (at your option) any later version.## This program is distributed in the hope that it will be useful,# but WITHOUT ANY WARRANTY; without even the implied warranty of# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the# GNU General Public License for more details.## You should have received a copy of the GNU General Public License# along with this program; if not, write to the Free Software# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.# Start/Stop the Zabbix agent daemon.# Place a startup script in /sbin/init.d, and link to it from /sbin/rc[023].dSERVICE="Zabbix proxy"DAEMON=/usr/local/zabbix3.0/sbin/zabbix_proxyPIDFILE=/tmp/zabbix_agentd.pidBASEDIR=/usr/local/zabbix3.0ZABBIX_AGENTD=$BASEDIR/sbin/zabbix_proxycase $1 in‘start‘)if [ -x ${DAEMON} ]then$DAEMON# Error checking here would be good...echo "${SERVICE} started."elseecho "Can‘t find file ${DAEMON}."echo "${SERVICE} NOT started."fi;;‘stop‘)if [ -s ${PIDFILE} ]thenif kill `cat ${PIDFILE}` >/dev/null 2>&1thenecho "${SERVICE} terminated."rm -f ${PIDFILE}fifi;;‘restart‘)$0 stopsleep 10$0 start;;*)echo "Usage: $0 start|stop|restart";;esac

  相關詳細配置請參考: 

http://www.2cto.com/os/201401/273888.html
http://www.tuicool.com/articles/zMZrUjU
http://blog.chinaunix.net/uid-23500957-id-4919835.html

 

4.常見問題匯總:

  Error connecting to database: No such file or directory

  解決辦法:http://www.bubuko.com/infodetail-1149825.html

  Zabbix 中文漢化及出現亂碼解決辦法

  解決辦法:http://www.linuxidc.com/Linux/2015-05/117208.htm

5.監控平台接入

  http://www.onealert.com/open/alert/overview.jsp 

 

6.zabbix編譯安裝自動化指令碼:

  http://www.dwhd.org/20150519_162243.html 

centos6.5編譯安裝zabbix3.0和中文支援整理文檔

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.