码迷,mamicode.com
首页 > 其他好文 > 详细

centos6.5编译安装zabbix3.0和中文支持整理文档

时间:2016-05-04 17:20:30      阅读:468      评论:0      收藏:0      [点我收藏+]

标签:

编者按:

  最近公司部分业务迁移机房,为了更方便的监控管理主机资源,决定上线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;
      		include		fastcgi_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-devel
2.wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.14.tar.gz
tar 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 16M
PHP option max_execution_time 300
PHP option max_input_time 300
PHP 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/services
zabbix-agent 10050/tcp # Zabbix Agent
zabbix-agent 10050/udp # Zabbix Agent
zabbix-trapper 10051/tcp # Zabbix Trapper
zabbix-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.sql
mysql -uroot -p zabbix < /usr/local/src/zabbix-3.0.0/database/mysql/images.sql
mysql -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/functions

RETVAL=0
prog="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 5
fi

start() {
        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 1
esac

exit $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/functions

RETVAL=0
prog="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 5
fi

start() {
        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 1
esac

exit $RETVAL

  其他相关配置参考:

http://www.tuicool.com/articles/JRVVniM 
http://www.mamicode.com/info-detail-1223031.html
http://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].d


SERVICE="Zabbix proxy"
DAEMON=/usr/local/zabbix3.0/sbin/zabbix_proxy
PIDFILE=/tmp/zabbix_agentd.pid
BASEDIR=/usr/local/zabbix3.0
ZABBIX_AGENTD=$BASEDIR/sbin/zabbix_proxy
case $1 in
	‘start‘)
		if [ -x ${DAEMON} ]
		then
			$DAEMON
		# Error checking here would be good...
			echo "${SERVICE} started."
		else
			echo "Can‘t find file ${DAEMON}."
			echo "${SERVICE} NOT started."
		fi
		;;
	‘stop‘)
		if [ -s ${PIDFILE} ]
		then
			if kill `cat ${PIDFILE}` >/dev/null 2>&1
			then
				echo "${SERVICE} terminated."
				rm -f ${PIDFILE}
			fi
		fi
		;;
	‘restart‘)
		$0 stop
		sleep 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和中文支持整理文档

标签:

原文地址:http://www.cnblogs.com/songqingbo/p/5458812.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!