如何将Zabbix从1.8.x升级到2.0.x


最近在研究Zabbix的过程中,逐渐的喜欢上了这个工具,感觉集成的非常棒,完全可以替代Nagios+Cacti的组合。
今天下发布一篇关于Zabbix升级的文档,后面会根据自身的经验,图文并茂撰写一篇Zabbix从入门到熟悉的文章供大家参考。

本文参考资料:
http://www.zabbix.com/documentation/2.0/manual/installation/upgrade_notes
http://www.zabbix.com/documentation/2.0/manual/installation/upgrade?s[]=upgrade

文档内容应公司要求全部用英文来撰写了,不过相信大家阅读起来应该没有什么问题的。

Upgraded Zabbix from 1.8.2 to 2.0.2.

1. Stop Zabbix server
$ su - zabbix
$ sudo /etc/init.d/zabbix_server stop

2. Back up the existing Zabbix database
$ mkdir -p /home/zabbix/zabbix_upgrade/backup
$ cd /home/zabbix/zabbix_upgrade/backup
$ mysqldump -uroot -p123456 zabbix > zabbix.backup.sql

3. Back up configuration files, PHP files and zabbix binaries
$ cp -rp /etc/zabbix .
$ cp -rp /home/zabbix/public_html .
$ cp -rp /etc/init.d/zabbix-* .
$ cp -rp /usr/sbin/zabbix* .
$ cp -rp /usr/bin/zabbix* .

4. Install new server binaries
Download zabbix-2.0.2.tar.gz from website.
$ cd /home/zabbix/zabbix_upgrade/
$ tar xzvf zabbix-2.0.2.tar.gz
$ cd zabbix-2.0.2
$ ./configure --prefix=/usr --with-mysql --with-net-snmp --with-libcurl --enable-server --enable-agent
$ make
$ sudo make install
$ sudo zabbix_server --help
Zabbix server v2.0.2 (revision 29214) ...

5. Review server configuration parameters
$ cd /usr/etc/
$ sudo cp -rp /home/zabbix/zabbix_upgrade/backup/zabbix/zabbix_* .

6. Upgrade the database
Clean the history data:
$date +%s -d "2012/9/1 00:00:00" ## Choose a date, to clean all history data before this day.
1346428800

mysql> DELETE FROM `history_uint` WHERE `clock` < 1346428800;
mysql> optimize table history_uint;

mysql> DELETE FROM `history` WHERE `clock` < 1346428800;
mysql> optimize table history;

$ cd /home/zabbix/zabbix_upgrade/zabbix-2.0.2/upgrades/dbpatches/2.0/mysql
$ mysql -uroot -p123456 zabbix < patch.sql

7. Install new Zabbix web interface
$ cd /home/zabbix/zabbix_upgrade/
$ sudo mv /home/zabbix/public_html /home/zabbix/public_html_bak
$ sudo mkdir /home/zabbix/public_html
$ sudo chown -R zabbix:zabbix /home/zabbix/public_html
$ cp -r zabbix-2.0.2/frontends/php/* /home/zabbix/public_html/

8. Start new Zabbix binaries
$ /etc/init.d/zabbix-server start
$ ps aux | grep zabbix_server

Open the webpage http://IP/zabbix/
Then follow the steps to setup the Zabbix WebUI.

Download the zabbix.conf.php and put it into /home/zabbix/public_html/conf/

Restart Zabbix server
$ /etc/init.d/zabbix-server stop
$ /etc/init.d/zabbix-server start

9. Upgrade Zabbix agent clients
We don't have to upgrade all Zabbix agent clients, but we'd better to do it if we can.

Download zabbix-2.0.2.tar.gz from website.
$ sudo /etc/init.d/zabbix_agentd stop

$ mkdir -p /home/zabbix/zabbix_upgrade/backup
$ cd /home/zabbix/zabbix_upgrade/backup
$ cp -rp /etc/zabbix .
$ cp -rp /etc/init.d/zabbix-* .
$ cp -rp /usr/sbin/zabbix* .
$ cp -rp /usr/bin/zabbix* .

$ cd /home/zabbix/zabbix_upgrade/
$ tar xzvf zabbix-2.0.2.tar.gz
$ cd zabbix-2.0.2
$ ./configure --prefix=/usr --with-net-snmp --with-libcurl --enable-agent
$ make
$ sudo make install

$ cd /usr/etc/
$ sudo cp -rp /home/zabbix/zabbix_upgrade/backup/zabbix/zabbix_* .

$ sudo zabbix_agent --help
Zabbix agent v2.0.2 (revision 29214) ...

$ sudo /etc/init.d/zabbix_agentd start

10. Done

11. Something we should pay attention
Configuration files location changed:
/etc/zabbix → /usr/etc

But except the /etc/zabbix/alert.d/.

{IPADDRESS} macro deprecated, use {HOST.IP}

  1. #1 by denny on 2014/06/10 - 02:23

    如果是开个git repo, 然后整理出一个可重复执行的shell脚本就好了。

    类似OpenStack的devstack那种。

(will not be published)
*