zabbix 2.4.7 proxy代理端升级到zabbix 3.2.3 (三)

zabbix server端升级到3.2.3以后,windows下agent端还可以使用2.4.7的agent程序,proxy端需要升级到3.2.3。下面是记录zabbix proxy端从2.4.7升级到3.2.3的过程。

1、暂停zabbix proxy

    /etc/init.d/zabbix_proxy stop
    /etc/init.d/zabbix_agentd stop

2、备份2.4.7的配置文件

    mv /usr/local/zabbix /usr/local/zabbix-2.4.7bak

3、安装zabbix 3.2.3

    

tar zxvf zabbix-3.2.3.tar.gz
cd zabbix-3.2.3
ln -s /usr/local/curl/bin/curl* /usr/local/bin #方便--with-libcurl使用
groupadd zabbix
useradd -g zabbix zabbix -s /sbin/nologin
./configure --prefix=/usr/local/zabbix --enable-agent --enable-proxy \
--sysconfdir=/etc/zabbix \
--with-mysql=/usr/local/mysql/bin/mysql_config \
--with-net-snmp --with-libcurl --with-libxml2
make && make install

4、修改下配置文件:

egrep -v "^#|^$" /etc/zabbix/zabbix_agentd.conf
LogFile=/tmp/zabbix_agentd.log
Server=zabbix server IP
ServerActive=zabbix server IP
Hostname=HKproxy #定义Proxy的名字,Server端直接填写名字即可
 RefreshActiveChecks=60
Include=/etc/zabbix/zabbix_agentd.conf.d/
 UnsafeUserParameters=1

# egrep -v "^#|^$" /etc/zabbix/zabbix_proxy.conf
Server=zabbix server IP
Hostname=HKproxy #定义Proxy的名字,Server端直接填写名字即可
LogFile=/tmp/zabbix_proxy.log
 PidFile=/tmp/zabbix_proxy.pid
DBName=zabbix
DBUser=zabbix
 DBPassword=password
 ProxyLocalBuffer=24
 ProxyOfflineBuffer=24
 HeartbeatFrequency=60
 ConfigFrequency=100
 DataSenderFrequency=1
 StartPollers=25
 StartIPMIPollers=10
 StartPollersUnreachable=2
 StartTrappers=10
 StartPingers=20
 StartDiscoverers=20
 StartHTTPPollers=20
 StartVMwareCollectors=10
 VMwareCacheSize=20M
 CacheSize=100M
 HistoryCacheSize=100M
 HistoryIndexCacheSize=200M
Timeout=4
 FpingLocation=/usr/sbin/fping
LogSlowQueries=3000
 Include=/etc/zabbix/zabbix_proxy.conf.d/

5、启动agentd和proxy就行。

启动proxy时会自动升级数据库。启动proxy以后可以看到以下日志:

tail -f zabbix_proxy.log
25873:20170130:202334.716 required mandatory version: 03020000
 25873:20170130:202334.716 starting automatic database upgrade
 25873:20170130:202334.737 completed 0% of database upgrade
 25873:20170130:202334.739 completed 1% of database upgrade
 25873:20170130:202338.428 slow query: 3.688917 sec, "alter table proxy_history add lastlogsize bigint unsigned default '0' not null"
 25873:20170130:202342.190 slow query: 3.754072 sec, "alter table proxy_history add mtime integer default '0' not null"
 25873:20170130:202342.192 completed 2% of database upgrade
 25873:20170130:202345.832 slow query: 3.640205 sec, "alter table proxy_history add meta integer default '0' not null"
 25873:20170130:202345.851 completed 3% of database upgrade
 25873:20170130:202345.938 completed 4% of database upgrade
 25873:20170130:202346.060 completed 5% of database upgrade
 25873:20170130:202346.127 completed 6% of database upgrade
 25873:20170130:202346.140 completed 7% of database upgrade
 25873:20170130:202346.146 completed 8% of database upgrade
 25873:20170130:202346.249 completed 9% of database upgrade
......
......
......
 25873:20170130:202352.547 completed 98% of database upgrade
 25873:20170130:202352.594 completed 99% of database upgrade
 25873:20170130:202352.596 completed 100% of database upgrade
 25873:20170130:202352.596 database upgrade fully completed

6、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/zabbix/sbin/zabbix_proxy
PIDFILE=/tmp/zabbix_agentd.pid
BASEDIR=/usr/local/zabbix/
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

查看日志数据库升级完成以后就可以使用新版本的代理来进行监控了。