SEARU.ORG
当前位置:SEARU.ORG > Linux 教程 > 正文

Zabbix从2.2.3升级到最新稳定版3.2.1

2013年底很幸运进入我现在工作的单位。当时公司用的是zennos监控系统,由于当初zennos架构的设计和本身功能的限制,无法满足公司业务的需求。从2014开始负责zabbix监控系统测试,包括zabbix功能的研究、分布式部署和性能调优等工作。

zabbix功能强大,可以监控包括系统、网络、硬件和应用等,自定义的key可监控到能想到的任何的监控项目。目前最新的稳定版本是3.2,由于3.0之后支持加密通信,趋势预测和更高大上的前端页面,所以打算将zabbix从2.2.3升级到3.2.1。

目前zabbix监控的服务器数据量1000台左右,保存两年的历史数据,后台数据库2T。整个分布式监控系统有一台server,3台proxy和2台MySQL数据库,数据库一主一从,从库主要用作备份。由于zabbix 2.2.3的agent兼容3.2.1的,所有服务器客户端的agent均不需要升级,只需升级server和proxy。

在升级之前首先检查一下zabbix 3.2.1所需要的MySQL数据库、PHP及其扩展库版本的要求。MySQL数据库的版本必须是5.0.3或者更新。前端页面对PHP和扩展库的要求如下:

Zabbix从2.2.3升级到最新稳定版3.2.1

如果上面要求都支持的话就可以进行升级了,在升级之前要做好数据的备份,方便在升级失败的时候快速回滚到2.2.3版本,备份的数据包括zabbix数据库,zabbix server配置文件,二进制文件和php文件,zabbix proxy的配置文件和二进制文件。

在升级期间为了减少宕机时间和历史数据的丢失,官方推荐先停止zabbix server服务并升级zabbix server。然后在停止proxy服务并升级proxy之后启动proxy服务。这样一台proxy升级完在升级另外一台proxy,当所有proxy都升级完之后在启动zabbix server服务。

第一步:升级zabbix server。

1)停止zabbix server服务,确保没有数据insert到zabbix数据里面。

2)备份zabbix数据库,由于数据库我做了MySQL主从同步,我只需要停止主从同步即可,从库就是备库。

3)备份zabbix server的配置文件,前端页面的PHP文件和二进制启动文件。我这里推荐直接使用mv做备份。

[[email protected] ~]# mv /etc/zabbix /etc/zabbix_version_2.2.3
[[email protected] ~]# mv /usr/local/zabbix /usr/local/zabbix_version_2.2.3
[[email protected] ~]# mv /data/www/zabbix /data/www/zabbix_version_2.2.3

4)安装新的zabbix3.2.1的软件包。 

[[email protected] software]# tar -zxvf zabbix-3.2.1.tar.gz
[[email protected] software]# cd zabbix-3.2.1
[[email protected] zabbix-3.2.1]# ./configure –prefix=/usr/local/zabbix –sysconfdir=/etc/zabbix –with-mysql=/usr/local/mysql/bin/mysql_config –with-net-snmp –enable-agent –enable-server –with-libcurl
[[email protected] zabbix-3.2.1]# make && make install

5)参考2.2.3的配置文件修改zabbix server的配置文件。有些参数有变更,大部分参数都是一致的。确保配置文件的里面的数据库用户有足够的权限( create table, drop table, create index, drop index )。

第二步:升级zabbix proxy。

  1)停止zabbix proxy服务。
  2)备份zabbix proxy的配置文件和二进制启动文件。我这里推荐直接使用mv做备份。

[[email protected] ~]# mv /etc/zabbix /etc/zabbix_version_2.2.3
[[email protected] ~]# mv /usr/local/zabbix /usr/local/zabbix_version_2.2.3

3) 安装新的zabbix3.2.1的软件包。 

[[email protected] software]# tar -zxvf zabbix-3.2.1.tar.gz
[[email protected] software]# cd zabbix-3.2.1
[[email protected] zabbix-3.2.1]# ./configure –prefix=/usr/local/zabbix –sysconfdir=/etc/zabbix –with-mysql=/usr/local/mysql/bin/mysql_config –with-net-snmp –enable-agent –enable-proxy –with-libcurl
[[email protected] zabbix-3.2.1]# make && make install

4)参考2.2.3的配置文件修改zabbix proxy的配置文件。有些参数有变更,大部分参数都是一致的。
5)启动zabbix proxy服务,proxy会自动在后台升级数据库。查看proxy日志,直到升级完成。 

[[email protected] zabbix-3.2.1]# /usr/local/zabbix/sbin/zabbix_proxy
[[email protected] zabbix-3.2.1]# tail -f /data/logs/zabbix/zabbix_proxy.log
 47609:20161117:135742.277 Starting Zabbix Proxy (active) [shproxy01]. Zabbix 3.2.1 (revision 62890).
 47609:20161117:135742.277 **** Enabled features ****
 47609:20161117:135742.277 SNMP monitoring:      YES
 47609:20161117:135742.277 IPMI monitoring:        NO
 47609:20161117:135742.277 Web monitoring:        YES
 47609:20161117:135742.277 VMware monitoring:      NO
 47609:20161117:135742.277 ODBC:                  NO
 47609:20161117:135742.277 SSH2 support:          NO
 47609:20161117:135742.277 IPv6 support:          NO
 47609:20161117:135742.277 TLS support:            NO
 47609:20161117:135742.277 **************************
 47609:20161117:135742.277 using configuration file: /etc/zabbix/zabbix_proxy.conf
 47609:20161117:135742.311 current database version (mandatory/optional): 02020000/02020000
 47609:20161117:135742.311 required mandatory version: 03020000
 47609:20161117:135742.311 starting automatic database upgrade
 47609:20161117:135742.312 completed 0% of database upgrade
 ……
 47609:20161117:140415.027 completed 95% of database upgrade
 47609:20161117:140415.149 completed 96% of database upgrade
 47609:20161117:140415.251 completed 97% of database upgrade
 47609:20161117:140415.597 completed 98% of database upgrade
 47609:20161117:140415.815 completed 99% of database upgrade
 47609:20161117:140415.921 completed 100% of database upgrade
 47609:20161117:140415.921 database upgrade fully completed

6)重复上面的1-5在升级其它两台proxy服务。

第三步:所有的proxy服务都升级完成之后重启zabbix server服务。然后查看日志,如果出现database upgrade fully completed说明server升级成功。 

[[email protected] ~]# /usr/local/zabbix/sbin/zabbix_server   
[[email protected] ~]# tail -f /data/logs/zabbix/zabbix_server.log
 19002:20161117:144351.201 Starting Zabbix Server. Zabbix 3.2.1 (revision 62890).
 19002:20161117:144351.201 ****** Enabled features ******
 19002:20161117:144351.201 SNMP monitoring:          YES
 19002:20161117:144351.201 IPMI monitoring:            NO
 19002:20161117:144351.201 Web monitoring:            YES
 19002:20161117:144351.201 VMware monitoring:          NO
 19002:20161117:144351.201 SMTP authentication:        NO
 19002:20161117:144351.201 Jabber notifications:      NO
 19002:20161117:144351.201 Ez Texting notifications:  YES
 19002:20161117:144351.201 ODBC:                      NO
 19002:20161117:144351.201 SSH2 support:              NO
 19002:20161117:144351.201 IPv6 support:              NO
 19002:20161117:144351.201 TLS support:                NO
 19002:20161117:144351.201 ******************************
 19002:20161117:144351.201 using configuration file: /etc/zabbix/zabbix_server.conf
 19002:20161117:144351.213 current database version (mandatory/optional): 02020000/02020001
 19002:20161117:144351.213 required mandatory version: 03020000
 19002:20161117:144351.213 starting automatic database upgrade
 19002:20161117:144351.214 completed 0% of database upgrade
 19002:20161117:144351.501 completed 1% of database upgrade
 19002:20161117:144351.940 completed 2% of database upgrade
 ……
 19002:20161117:144807.873 completed 95% of database upgrade
 19002:20161117:144808.283 completed 96% of database upgrade
 19002:20161117:144808.541 completed 97% of database upgrade
 19002:20161117:144811.410 completed 98% of database upgrade
 19002:20161117:144812.120 completed 99% of database upgrade
 19002:20161117:144812.791 completed 100% of database upgrade
 19002:20161117:144812.791 database upgrade fully completed

第四步:安装zabbix 前端WEB服务,一切都很顺利。

Zabbix从2.2.3升级到最新稳定版3.2.1

总结:
1)官方上虽然说zabbix 3.2.1的版本对php的要求是5.4.0或者更新,但发现如果PHP是5.4.24版本,会出现Last 20 issues不显示数据和前端页面有报错,但不影响功能,最后升级PHP到5.5.38版本解决了这个问题。

array_map() expects parameter 1 to be a valid callback, no array or string given [zabbix.php:21 → require_once() → ZBase->run() → ZBase->processRequest() → CView->getOutput() → include() → make_system_status() → makeTriggersPopup() → CMacrosResolverHelper::resolveEventDescription() → CMacrosResolver->resolveTriggerNames() → CMacrosResolverGeneral->findFunctions() → CMacroParser->__construct() → array_map() in include/classes/parsers/CMacroParser.php:60]
Argument 1 passed to CSetParser::__construct() must be of the type array, null given, called in /data/online/zabbix/include/classes/parsers/CMacroParser.php on line 60 and defined [zabbix.php:21 → require_once() → ZBase->run() → ZBase->processRequest() → CView->getOutput() → include() → make_system_status() → makeTriggersPopup() → CMacrosResolverHelper::resolveEventDescription() → CMacrosResolver->resolveTriggerNames() → CMacrosResolverGeneral->findFunctions() → CMacroParser->__construct() → CSetParser->__construct() in include/classes/parsers/CSetParser.php:43]
array_flip() expects parameter 1 to be array, null given [zabbix.php:21 → require_once() → ZBase->run() → ZBase->processRequest() → CView->getOutput() → include() → make_system_status() → makeTriggersPopup() → CMacrosResolverHelper::resolveEventDescription() → CMacrosResolver->resolveTriggerNames() → CMacrosResolverGeneral->findFunctions() → CMacroParser->__construct() → CSetParser->__construct() → array_flip() in include/classes/parsers/CSetParser.php:44]
implode(): Argument must be an array [zabbix.php:21 → require_once() → ZBase->run() → ZBase->processRequest() → CView->getOutput() → include() → make_system_status() → makeTriggersPopup() → CMacrosResolverHelper::resolveEventDescription() → CMacrosResolver->resolveTriggerNames() → CMacrosResolverGeneral->findFunctions() → CMacroParser->__construct() → CSetParser->__construct() → implode() in include/classes/parsers/CSetParser.php:45]

2)检查php session是否有写的权限,如果没有写的权限,前端页面也会出错。

一些Zabbix相关教程集合

CentOS 7.2 安装部署 Zabbix 3.0.4 详解  http://www.searu.org/2016-11/137671.htm

Ubuntu 14.04下Zabbix2.4.5 源码编译安装  http://www.linuxidc.com/Linux/2015-05/117657.htm

安装部署分布式监控系统Zabbix 2.06 http://www.searu.org/2013-07/86942.htm

《安装部署分布式监控系统Zabbix 2.06》 http://www.searu.org/2013-07/86942.htm

CentOS 7.0 x64下Zabbix 3.0 安装笔记  http://www.searu.org/2016-11/137044.htm

Zabbix分布式监控系统实践 http://www.searu.org/2013-06/85758.htm

CentOS 6.3下Zabbix监控apache server-status http://www.searu.org/2013-05/84740.htm

CentOS 6.3下Zabbix监控MySQL数据库参数 http://www.searu.org/2013-05/84800.htm

64位CentOS 6.2下安装Zabbix 2.0.6   http://www.searu.org/2014-11/109541.htm

ZABBIX 的详细介绍请点这里
ZABBIX 的下载地址请点这里

未经允许不得转载:SEARU.ORG » Zabbix从2.2.3升级到最新稳定版3.2.1

赞 (0)
分享到:更多 ()

评论 0