本章节提供了使用 Zabbix 官方源代码包,从 Zabbix 3.4.x 成功 升级 至 Zabbix 4.0 所需的步骤。
This section provides the steps required for a successful upgrade from Zabbix 3.4.x to Zabbix 4.0.x using official Zabbix sources.
虽然升级 Zabbix agent 不是强制性的,但建议将其升级,而 Zabbix server 和 Zabbix proxy 必须具有相同的主要版本。因此,在 Zabbix server 和 Zabbix proxy 的架构升级时,Zabbix server 和所有的 Zabbix proxy 必须停止并升级。
While upgrading Zabbix agents is not mandatory (but recommended), Zabbix server and proxies must be of the same major version. Therefore, in a server-proxy setup, Zabbix server and all proxies have to be stopped and upgraded.
为了最大限度地减少升级期间的停机时间和数据丢失的几率,建议先停机并升级 Zabbix server,然后再逐个停机并升级 Zabbix proxy,待升级完毕后,先启动 Zabbix proxy,再启动 Zabbix server。在 Zabbix server 停机期间,运行中的 Zabbix Proxy 将继续采集和存储数据,并在 Zabbix server 启动并运行后,将数据传递给 Zabbix server。 只有在升级的 Zabbix server 启动后,才会生成 Zabbix server停机期间出现问题的任何通知。
To minimize downtime and data loss during the upgrade, it is recommended to stop and upgrade Zabbix server and then stop, upgrade and start Zabbix proxies one after another. When all proxies are upgraded, start Zabbix server. During the Zabbix server downtime, running proxies will keep collecting and storing data and will pass the data to Zabbix server when the server is up and running. Any notifications for problems during Zabbix server downtime will be generated only after the upgraded server is started.
众所周知,仅升级 Zabbix server 而不升级 Zabbix proxy ,并且未升级的 Zabibx proxy 将数据发送至升级后的 Zabbix server 是可能的(Zabbix proxy 无法其刷新配置)。但是,不建议这样,Zabbix 不支持这样,选择这样做您需为其独自承担风险。
It is known to be possible to start the upgraded server and have older, yet unupgraded proxies report data to a newer server (the proxies can't refresh their configuration though). This approach, however, is not recommended and not supported by Zabbix and choosing it is entirely at your own risk.
请注意,对于 Zabbix proxy 上的 SQLite 数据库,升级前 Zabbix proxy 的历史数据将丢失,因为不支持 SQLite 数据库升级,而且必须手动删除 SQLite 数据库文件。 当第一次启动 Zabbix proxy 并且缺少 SQLite 数据库文件时,Zabibx proxy 会自动创建它。
Note that with SQLite database on proxies, history data from proxies before the upgrade will be lost, because SQLite database upgrade is not supported and the SQLite database file has to be manually removed. When proxy is started for the first time and the SQLite database file is missing, proxy creates it automatically.
根据其数据库大小,数据库升级到 4.0 版本可能需要很长时间。
Depending on database size the database upgrade to version 4.0 may take a long time.
<note warning>值得注意的是,在升级之前,请务必阅读相关的升级说明! :::
Before the upgrade make sure to read the relevant upgrade notes!
请阅读下面的升级说明:
The following upgrade notes are available:
Upgrade from | Read full upgrade notes | Important notes/changes between versions |
---|---|---|
3.4.x | For 4.0 | 'libpthread' and 'zlib' libraries now mandatory; Support for plain text protocol dropped and header is mandatory; Pre-1.4 version Zabbix agents are no longer supported; The Server parameter in passive proxy configuration now mandatory |
3.2.x | Also for 3.4 | SQLite support as backend database dropped for Zabbix server/frontend; Perl Compatible Regular Expressions (PCRE) supported instead of POSIX extended; 'libpcre' and 'libevent' libraries mandatory for Zabbix server; Exit code checks added for user parameters, remote commands and system.run[] items without the 'nowait' flag as well as Zabbix server executed scripts; Zabbix Java gateway has to be upgraded to support new functionality |
3.0.x | Also for 3.2 | Database upgrade may be slow, depending on the history table size |
2.4.x | Also for 3.0 | Minimum required PHP version upped from 5.3.0 to 5.4.0 LogFile agent parameter must be specified |
2.2.x | Also for 2.4 | Node-based distributed monitoring removed |
2.0.x | Also for 2.2 | Minimum required PHP version upped from 5.1.6 to 5.3.0; Case-sensitive MySQL database required for proper server work; 'mysqli' PHP extension required instead of 'mysql' |
此外,还需检查升级至 Zabbix 4.0 的需求。
You may also want to check the requirements for 4.0.
建议在升级期间运行两个 SSH 会话,其中一个会话执行升级步骤,另一个会话监控其升级期间的日志。例如,在第二个 SSH 会话上运行tail -f zabbix_server.log
或 tail -f zabbix_proxy.log
,以实时显示最新的常规日志输出或错误日志输出。这对生产环境至关重要。
It may be handy to run two parallel SSH sessions during the upgrade, executing the upgrade steps in one and monitoring the server/proxy logs in another. For example, run tail -f zabbix_server.log
or tail -f zabbix_proxy.log
in the second SSH session showing you the latest log file entries and possible errors in real time. This can be critical for production instances.
停止 Zabbix server 以确保没有新数据插入数据库。
Stop Zabbix server to make sure that no new data is inserted into database.
这是非常重要的步骤。升级前请确保备份了数据库。如果升级失败(因磁盘空间不足、断电或其他意外导致的升级失败),备份的数据库将大有帮助。
This is a very important step. Make sure that you have a backup of your database. It will help if the upgrade procedure fails (lack of disk space, power off, any unexpected problem).
在升级前请确保备份了配置文件、PHP 文件和 Zabbix 二进制文件。
Make a backup copy of Zabbix binaries, configuration files and the PHP file directory.
使用此 说明 从源代码编译 Zabbixserver。
Use these instructions to compile Zabbix server from sources.
在新版本中,Zabbix server 的配置文件发生了一些变化,关于这些强制变更,详见升级说明。
See the upgrade notes for details on mandatory changes.
关于新的可选参数,详见 Zabbix 4.0 新特征 章节。
For new optional parameters, see the What's new section.
启动新的 Zabbix 进程。检查日志文件以查看进程是否成功启动。
Start new binaries. Check log files to see if the binaries have started successfully.
待 Zabbix server 的进程启动后,它将自动升级数据库。Zabbix server 将会报告当前(强制和可选)的和所需的数据库版本。如果当前的强制版本早于所需的版本,那么 Zabbix server 会自动执行所需数据库的升级修补程序。数据库升级的开始和进度(百分比)将会写入到 Zabbix server 的日志文件中。当升级完成后,会写入一条 "database upgrade fully completed" 信息到日志文件中。如果升级失败,Zabbix server 将不会启动。如果当前的强制数据库版本比所需的数据库版本新时,则 Zabbix server 也将无法启动。只有当前强制数据库版本对应于所需的强制版本时,Zabbix server 才会启动。
Zabbix server will automatically upgrade the database. When starting up, Zabbix server reports the current (mandatory and optional) and required database versions. If the current mandatory version is older than the required version, Zabbix server automatically executes the required database upgrade patches. The start and progress level (percentage) of the database upgrade is written to the Zabbix server log file. When the upgrade is completed, a "database upgrade fully completed" message is written to the log file. If any of the upgrade patches fail, Zabbix server will not start. Zabbix server will also not start if the current mandatory database version is newer than the required one. Zabbix server will only start if the current mandatory database version corresponds to the required mandatory version.
8673:20161117:104750.259 current database version (mandatory/optional): 03040000/03040000
8673:20161117:104750.259 required mandatory version: 03040000
在启动 Zabbix server 之前:
Before you start the server:
其最小的需要为 PHP 5.4.0 版本。如果升级请按照 安装说明 进行操作。
The minimum required PHP version is 5.4.0. Update if needed and follow installation instructions.
待升级完毕后,可能需要清除浏览器的 Cookies 和缓存,以便 Zabbix 的 Web 界面能正常工作。
After the upgrade you may need to clear web browser cookies and web browser cache for the Zabbix web interface to work properly.
停止 Zabbix proxy 进程。
Stop Zabbix proxy.
在升级前请确保备份了配置文件和 Zabbix proxy 二进制文件。
Make a backup copy of the Zabbix proxy binary and configuration file.
使用此 说明 从源代码编译 Zabbix proxy。
Use these instructions to compile Zabbix proxy from sources.
此版本中没有对 Zabbix proxy 的 参数 进行强制的更改。有关新的可选参数,详见 Zabbix 4.0.0 新特征章节。
There are no mandatory changes in this version to proxy parameters. For new optional parameters, see the What's new section.
启动新的 Zabbix proxy。检查日志文件以确定 Zabbix proxy 是否启动成功。
Start the new Zabbix proxy. Check log files to see if the proxy has started successfully.
Zabbix proxy 将自动升级数据库。数据库的升级和启动和 Zabbix server 类似。
Zabbix proxy will automatically upgrade the database. Database upgrade takes place similarly as when starting Zabbix server.
升级 Zabbix agent 并不是强制性的。如果需要使用新功能时,则可以按需升级 Zabbix agent。
Upgrading agents is not mandatory. You only need to upgrade agents if it is required to access the new functionality.
停止 Zabbix agent 进程。
Stop Zabbix agent.
在升级前请确保备份了配置文件和 Zabbix agent 二进制文件。
Make a backup copy of the Zabbix agent binary and configuration file.
使用此 说明 从源代码编译 Zabbix agent。
Use these instructions to compile Zabbix agent from sources.
或者,从 Zabbix 下载页面 下载预编译的 Zabbix agent 包。
Alternatively, you may download pre-compiled Zabbix agents from the Zabbix download page.
此版本中没有对 Zabbix agent 的参数进行强制的更改。
There are no mandatory changes in this version to agent parameters.
启动新的 Zabbix agent。检查日志文件以确定 Zabbix agent 是否启动成功。
Start the new Zabbix agent. Check log files to see if the agent has started successfully.
在 Zabbix 4.0.x 的次要版本之间进行升级时(例如从 4.0.1 升级到 4.0.3 ),需要与为 server/proxy/agent 主要版本之间的升级期间执行相同的操作。唯一的区别是,在次要版本之间进行升级时,不会对数据库进行任何更改。
When upgrading between minor versions of 4.0.x (for example from 4.0.1 to 4.0.3) it is required to execute the same actions for server/proxy/agent as during the upgrade between major versions. The only difference is that when upgrading between minor versions no changes to the database are made.