Zabbix2.2.xではVMware監視機能が強化されました。いちいちゲストOSの監視設定を手作業で追加することなく自動で追加してくれる機能(LLD: Low Level Discovery)を利用したかったので、2.0.9からアップグレードすることにしました。
Zabbixを利用したのは2系からとなるので昔のことは知らないのですが、これまではメジャーバージョンアップ時のDBアップデートは手動だった様子。自動になって楽になったのでしょうが、それでもテンプレート機能は差分を修正する必要があったりとやや面倒です。
以下、アップグレード手順を記します。
アップグレード作業前の準備
稼働中Zabbixサービスを停止する
稼働中のサービスを停止する。
service zabbix-server stop
service zabbix-agent stop
Zabbixデータベースのバックアップ
mysqldump --opt --no-autocommit -uroot -p -B ZABBIX_DATABASE_NAME > ~/tmp/zabbix.dump
Zabbix定義ファイルのバックアップ
後ほどConfigの差分を比較するために必ずバックアップします。
cp -a /etc/zabbix ~/tmp/
レポジトリも変更されるので念のため。
cp /etc/yum.repos.d/zabbix.repo ~/tmp/
PHP各種ファイルは万一失ってもそこまでリスクは無いと思いますので、取得しなくても問題ないでしょう。
アップデート
zabbixをアップデートしますが、先に注意点。
- PHPのバージョンが古い方は注意(5.3以上が要件なので新しくもないですが)
- 事前に yum update をしておくこと
- zabbixとして構成されるパッケージのうち、一部が2.0.10で、その他2.0.9が残っているような混在環境の場合はまずバージョンを揃える必要がある。
- といいつつ先にレポジトリ登録をしてしまった場合、baseurlのバージョン部分を2.0に書き換えれば何とか先に進めます。
先ずZabbix2.2のレポジトリ登録
rpm -Uvh http://repo.zabbix.com/zabbix/2.2/rhel/6/x86_64/zabbix-release-2.2-1.el6.noarch.rpm
標準はenabled=1(yum時にデフォルトで利用してしまう状態)になっているので好みに応じて無効化します。
sed -i -e "s/enabled=1/enabled=0/" /etc/yum.repos.d/zabbix.repo
差分(enabled=0にした後)。baseurlだけが変わっていることを確認します。
@@ -1,6 +1,6 @@
[zabbix]
name=Zabbix Official Repository - $basearch
-baseurl=http://repo.zabbix.com/zabbix/2.0/rhel/6/$basearch/
+baseurl=http://repo.zabbix.com/zabbix/2.2/rhel/6/$basearch/
enabled=0
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX
いよいよアップデート
yum clean all
yum --enablerepo=zabbix update
結果は以下の通り。
Updated:
zabbix.x86_64 0:2.2.1-1.el6
zabbix-agent.x86_64 0:2.2.1-1.el6
zabbix-get.x86_64 0:2.2.1-1.el6
zabbix-server.x86_64 0:2.2.1-1.el6
zabbix-server-mysql.x86_64 0:2.2.1-1.el6
zabbix-web.noarch 0:2.2.1-1.el6
zabbix-web-mysql.noarch 0:2.2.1-1.el6
Complete!
Config(zabix_server.conf)を修正する
追加・削除のあったオプションは以下の通り。いずれも不要であれば今までのコンフィグで動作します。目的に応じて追加してください。参考までに、新旧コンフィグのDiffを本文末尾に載せています。
- Option: StartTimers
- Option: StartVMwareCollectors
- Option: ValueCacheSize
- Option: AllorRoot (Default: 0)
VMware監視の為には VMwareCokkector が必須。
- Option: VMwareFrequenct
- Option: VMwareCacheSize
ローダブルモジュール。機能拡張ができるようだが直近は利用予定がないので触れない。
- Option: LoadModulePath
- Option: LoadModule
HouseKeepingはWEB-GUIからの設定に変わったためconfから削除してしまって良い。
- Option: DisableHousekeeping
再起動とDBのアップグレード
service zabbix-server start
start zabbix-server によりDBがアップグレードされる。ログファイルに以下出力があることを確認する。
database upgrade fully completed
先にagentを起動しておかないと(1)が表示される。(2)は未確認。
(1)Zabbix agent item "system.users.num" on host "Zabbix server" failed: first network error, wait for 15 seconds
(2)item [xxx] became not supported: Not supported by Zabbix Agent
新Webインタフェースの設定
Webインタフェースが変更されているのでファイル群の修正が必要となりますが、Webフロントエンドのファイル(/usr/share/zabbix)に対してシンボリックリンクを張って入れば特に作業は必要ありません。
テンプレートの追加
Zabbix-serverのDBアップグレードはスキーマ変更しかされません。VMwareテンプレートをはじめとしていくつか追加があるため、その差分をインポートする必要があります。
本エントリでは、目的のVMwareテンプレートのみ追加します。
エラー発生
Template_Virt_VMware-2.2.0 をImportしようとしたところエラーが発生しました。
Error:
Cannot find value map "VMware status" used for item prototype "Status of "$2" cluster" of discovery rule "Discover VMware clusters" on "Template Virt VMware".
どうも2.0.xから2.2.1へアップグレードした時にレコードが不足しているようです。(公式Forumでそのようなやりとりを発見)
以下のレコードを追加すればよいとのこと。
mysql -u DB_USER_NAME -p
mysql> use ZABBIX_DATABASE_NAME;
INSERT INTO `valuemaps` (`valuemapid`,`name`) values ('13','VMware status');
INSERT INTO `valuemaps` (`valuemapid`,`name`) values ('12','VMware VirtualMachinePowerState');
INSERT INTO `mappings` (`mappingid`,`valuemapid`,`value`,`newvalue`) values ('72','12','0','poweredOff');
INSERT INTO `mappings` (`mappingid`,`valuemapid`,`value`,`newvalue`) values ('73','12','1','poweredOn');
INSERT INTO `mappings` (`mappingid`,`valuemapid`,`value`,`newvalue`) values ('74','12','2','suspended');
INSERT INTO `mappings` (`mappingid`,`valuemapid`,`value`,`newvalue`) values ('75','13','0','gray');
INSERT INTO `mappings` (`mappingid`,`valuemapid`,`value`,`newvalue`) values ('76','13','1','green');
INSERT INTO `mappings` (`mappingid`,`valuemapid`,`value`,`newvalue`) values ('77','13','2','yellow');
INSERT INTO `mappings` (`mappingid`,`valuemapid`,`value`,`newvalue`) values ('78','13','3','red');
その後、以下の順番でテンプレートをインポートします。
- Template_Virt_VMware_Hypervisor-2.2.0
- Template_Virt_VMware_Guest-2.2.0
- Template_Virt_VMware-2.2.0
1と2の順番は逆でも問題ないかもしれませんが、Template_Virt_VMware は先に入れてしまうと以下のエラーが発生します。
Error:
Cannot find template "Template Virt VMware Hypervisor" for host prototype "{#HV.NAME}" of discovery rule "Discover VMware hypervisors" on "Template Virt VMware".
以上でアップデート作業は終了。
References
Links
zabbix_server.confの差分
--- zabbix_server.conf 2013-10-30 01:54:44.127844647 +0900
+++ zabbix_server.conf.rpmnew 2013-12-11 14:14:33.000000000 +0900
@@ -114,8 +114,6 @@
# Default:
# DBPassword=
-DBPassword=password
-
### Option: DBSocket
# Path to MySQL socket.
#
@@ -193,6 +191,16 @@
# Default:
# StartHTTPPollers=1
+### Option: StartTimers
+# Number of pre-forked instances of timers.
+# Timers process time-based trigger functions and maintenance periods.
+# Only the first timer process handles the maintenance periods.
+#
+# Mandatory: no
+# Range: 1-1000
+# Default:
+# StartTimers=1
+
### Option: JavaGateway
# IP address (or hostname) of Zabbix Java gateway.
# Only required if Java pollers are started.
@@ -217,6 +225,32 @@
# Default:
# StartJavaPollers=0
+### Option: StartVMwareCollectors
+# Number of pre-forked vmware collector instances.
+#
+# Mandatory: no
+# Range: 0-250
+# Default:
+# StartVMwareCollectors=0
+
+### Option: VMwareFrequency
+# How often Zabbix will connect to VMware service to obtain a new data.
+#
+# Mandatory: no
+# Range: 10-86400
+# Default:
+# VMwareFrequency=60
+
+### Option: VMwareCacheSize
+# Size of VMware cache, in bytes.
+# Shared memory size for storing VMware data.
+# Only used if VMware collectors are started.
+#
+# Mandatory: no
+# Range: 256K-2G
+# Default:
+# VMwareCacheSize=8M
+
### Option: SNMPTrapperFile
# Temporary file used for passing data from SNMP trap daemon to the server.
# Must be the same as in zabbix_trap_receiver.pl or SNMPTT configuration file.
@@ -267,14 +301,6 @@
# Default:
# MaxHousekeeperDelete=500
-### Option: DisableHousekeeping
-# If set to 1, disables housekeeping.
-#
-# Mandatory: no
-# Range: 0-1
-# Default:
-# DisableHousekeeping=0
-
### Option: SenderFrequency
# How often Zabbix will try to send unsent alerts (in seconds).
#
@@ -335,6 +361,16 @@
# Default:
# HistoryTextCacheSize=16M
+### Option: ValueCacheSize
+# Size of history value cache, in bytes.
+# Shared memory size for caching item history data requests
+# Setting to 0 disables value cache.
+#
+# Mandatory: no
+# Range: 0,128K-64G
+# Default:
+# ValueCacheSize=8M
+
### Option: NodeNoEvents
# If set to '1' local events won't be sent to master node.
# This won't impact ability of this node to propagate events from its child nodes.
@@ -431,7 +467,7 @@
# Fping6Location=/usr/sbin/fping6
### Option: SSHKeyLocation
-# Location of public and private keys for SSH checks and actions
+# Location of public and private keys for SSH checks and actions.
#
# Mandatory: no
# Default:
@@ -454,17 +490,6 @@
# Default:
# TmpDir=/tmp
-### Option: Include
-# You may include individual files or all files in a directory in the configuration file.
-# Installing Zabbix will create include directory in /usr/local/etc, unless modified during the compile time.
-#
-# Mandatory: no
-# Default:
-# Include=
-
-# Include=/usr/local/etc/zabbix_server.general.conf
-# Include=/usr/local/etc/zabbix_server.conf.d/
-
### Option: StartProxyPollers
# Number of pre-forked instances of pollers for passive proxies.
#
@@ -490,3 +515,44 @@
# Range: 1-3600
# Default:
# ProxyDataFrequency=1
+
+### Option: AllowRoot
+# Allow the server to run as 'root'. If disabled and the server is started by 'root', the server
+# will try to switch to user 'zabbix' instead. Has no effect if started under a regular user.
+# 0 - do not allow
+# 1 - allow
+#
+# Mandatory: no
+# Default:
+# AllowRoot=0
+
+### Option: Include
+# You may include individual files or all files in a directory in the configuration file.
+# Installing Zabbix will create include directory in /usr/local/etc, unless modified during the compile time.
+#
+# Mandatory: no
+# Default:
+# Include=
+
+# Include=/usr/local/etc/zabbix_server.general.conf
+# Include=/usr/local/etc/zabbix_server.conf.d/
+
+####### LOADABLE MODULES #######
+
+### Option: LoadModulePath
+# Full path to location of server modules.
+# Default depends on compilation options.
+#
+# Mandatory: no
+# Default:
+# LoadModulePath=${libdir}/modules
+
+### Option: LoadModule
+# Module to load at server startup. Modules are used to extend functionality of the server.
+# Format: LoadModule=<module.so>
+# The modules must be located in directory specified by LoadModulePath.
+# It is allowed to include multiple LoadModule parameters.
+#
+# Mandatory: no
+# Default:
+# LoadModule=