首页 > 系统应用 > 监控 > Zabbix从2.2.3升级到最新稳定版3.2.1
2018
04-26

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

在升级期间为了减少宕机时间和历史数据的丢失,官方推荐先停止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做备份。

[root@monitor ~]# mv /etc/zabbix /etc/zabbix_version_2.2.3
[root@monitor ~]# mv /usr/local/zabbix /usr/local/zabbix_version_2.2.3
[root@monitor ~]# mv /data/www/zabbix /data/www/zabbix_version_2.2.3

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

[root@monitor software]# tar -zxvf zabbix-3.2.1.tar.gz
[root@monitor software]# cd zabbix-3.2.1
[root@monitor 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
[root@monitor 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做备份。

[root@proxy01 ~]# mv /etc/zabbix /etc/zabbix_version_2.2.3
[root@proxy01 ~]# mv /usr/local/zabbix /usr/local/zabbix_version_2.2.3

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

[root@proxy01 software]# tar -zxvf zabbix-3.2.1.tar.gz
[root@proxy01 software]# cd zabbix-3.2.1
[root@proxy01 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
[root@proxy01 zabbix-3.2.1]# make && make install

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

[root@proxy01 zabbix-3.2.1]# /usr/local/zabbix/sbin/zabbix_proxy
[root@proxy01 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升级成功。

[root@monitor ~]# /usr/local/zabbix/sbin/zabbix_server
[root@monitor ~]# 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服务,一切都很顺利。
总结:
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是否有写的权限,如果没有写的权限,前端页面也会出错。

最后编辑:
作者:saunix
大型互联网公司linux系统运维攻城狮,专门担当消防员