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和擴展庫的要求以下:
若是上面要求都支持的話就能夠進行升級了,在升級以前要作好數據的備份,方便在升級失敗的時候快速回滾到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作備份。
php
[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作備份。
mysql
[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的軟件包。
sql
[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升級成功。
bash
[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->proce***equest() → 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->proce***equest() → 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->proce***equest() → 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->proce***equest() → 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是否有寫的權限,若是沒有寫的權限,前端頁面也會出錯。
session