从 zabbix server 3.2 升级到 zabbix server 3.4.6

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了从 zabbix server 3.2 升级到 zabbix server 3.4.6相关的知识,希望对你有一定的参考价值。

一、停止 zabbix Server

[[email protected] ~]# /etc/init.d/zabbix_server stop
Shutting down zabbix_server:                                [  OK  ]
[[email protected] ~]# /etc/init.d/zabbix_agentd stop
Shutting down zabbix_agentd:                               [  OK  ]

二、备份现有的 Zabbix Server 数据库

防止升级过程失败(如磁盘空间不足,断电及其他意外问题)。

[[email protected] ~]# mysqldump -uzabbix -p你的密码 zabbix > zabbix_back.sql

三、备份配置文件,php 文件和 Zabbix 二进制文件

#备份 web 目录
[[email protected] ~]# cd /app/product/nginx/html/
[[email protected] html]# ll
total 16
-rw-r--r--  1 root root  537 Aug  7 15:08 50x.html
-rw-r--r--  1 root root  612 Aug  7 15:08 index.html
-rw-r--r--  1 root root   20 Aug  8 09:28 index.php
drwxr-xr-x 13 root root 4096 Aug  8 10:03 zabbix
[[email protected] html]# /bin/cp -fr zabbix/ zabbixbackup   #<--f:强制复制
[[email protected] html]# ll
total 20
-rw-r--r--  1 root root  537 Aug  7 15:08 50x.html
-rw-r--r--  1 root root  612 Aug  7 15:08 index.html
-rw-r--r--  1 root root   20 Aug  8 09:28 index.php
drwxr-xr-x 13 root root 4096 Aug  8 10:03 zabbix
drwxr-xr-x 13 root root 4096 Jan 22 10:56 zabbixbackup
[[email protected]gc product]# mkdir /opt/backup/zabbix3.2
[[email protected] product]# cd zabbix3.2/
[[email protected] zabbix3.2]# ll
total 20
drwxr-xr-x 2 zabbix zabbix 4096 Aug  8 09:36 bin
drwxr-xr-x 4 zabbix zabbix 4096 Aug 10 18:11 etc
drwxr-xr-x 2 zabbix zabbix 4096 Aug  8 09:36 lib
drwxr-xr-x 2 zabbix zabbix 4096 Aug  8 09:36 sbin
drwxr-xr-x 4 zabbix zabbix 4096 Aug  8 09:36 share
#备份 Zabbix Server 配置信息
[[email protected] zabbix3.2]# cd etc
[[email protected] etc]# ll
total 36
-rw-r--r-- 1 zabbix zabbix 10300 Aug 10 16:25 zabbix_agentd.conf
drwxr-xr-x 2 zabbix zabbix  4096 Aug  8 09:36 zabbix_agentd.conf.d
-rw-r--r-- 1 zabbix zabbix 14698 Aug 10 16:32 zabbix_server.conf
drwxr-xr-x 2 zabbix zabbix  4096 Aug  8 09:36 zabbix_server.conf.d
[[email protected] etc]# cd ..
[[email protected] zabbix3.2]# /bin/cp -fr etc/ /opt/backup/zabbix3.2

四、安装新的 Zabbix Server 二进制文件

下载地址:https://sourceforge.net/projects/zabbix/files/ZABBIX%20Latest%20Stable/3.4.6/zabbix-3.4.6.tar.gz/download
[[email protected] ~]# cd /opt/software/
[[email protected] software]# tar xf zabbix-3.4.6.tar.gz
[[email protected] ~]# cd /opt/software/zabbix-3.4.6
[[email protected] zabbix-3.4.6]# ./configure --prefix=/app/product/zabbix3.2 --enable-server --enable-agent --with-net-snmp --with-libcurl --with-libxml2 --with-mysql=/app/product/mysql/bin/mysql_config
Configuration:

  Detected OS:           linux-gnu
  Install path:          /app/product/zabbix3.2
  Compilation arch:      linux

  Compiler:              gcc
  Compiler flags:         -g -O2

  Library-specific flags:
    database:               -I/app/product/mysql/include   -g -fabi-version=2 -fno-omit-frame-pointer -fno-strict-aliasing   
    libXML2:               -I/usr/include/libxml2
    Net-SNMP:               -I/usr/include/rpm -I/usr/local/include -I/usr/lib64/perl5/CORE -I. -I/usr/include

  Enable server:         yes
  Server details:
    With database:         MySQL
    WEB Monitoring:        cURL
    Native Jabber:         no
    SNMP:                  yes
    IPMI:                  no
    SSH:                   no
    TLS:                   no
    ODBC:                  no
    Linker flags:             -L/app/product/mysql/lib        -L/usr/lib64   -L/usr/local/lib    -rdynamic   
    Libraries:               -lmysqlclient  -lpthread -lm -lrt -ldl     -lxml2    -lnetsnmp   -levent    -lcurl -lm -ldl -lrt  -lresolv -lpcreposix -lpcre -liconv

  Enable proxy:          no

  Enable agent:          yes
  Agent details:
    TLS:                   no
    Linker flags:              -rdynamic   
    Libraries:                 -lcurl -lm -ldl -lrt  -lresolv -lpcreposix -lpcre -liconv

  Enable Java gateway:   no

  LDAP support:          no
  IPv6 support:          no

***********************************************************
*            Now run 'make install'                       *
*                                                         *
*            Thank you for using Zabbix!                  *
*              <http://www.zabbix.com>                    *
***********************************************************
[[email protected] zabbix-3.4.6]# make
[[email protected] zabbix-3.4.6]# make install
[[email protected] zabbix-3.4.6]# cd frontends/php/
[[email protected] zabbix-3.4.6]# rm -rf /app/product/nginx/html/zabbix/*
[[email protected] php]# cp -a . /app/product/nginx/html/zabbix/
  • Zabbix Server 自动升级数据库

       Zabbix Server 将会自动升级数据库。开始后,Zabbix Server 报告当前(强制和非强制的)和需要的数据库版本。如果当前强制版本低于需要的版本,Zabbix Server 自动执行所需要的数据库补丁。数据库升级的开始和进度信息(百分比)将会写入 Zabbix Server 的日志文件中。当升级完成后,将会在日志文件中写入一条 “database upgrade fully completed” 的信息。如果任何升级补丁失败,Zabbix Server 将不会启动,即使数据库当前强制版本比所需版本高,Zabbix Server 也不会启动。只有当数据库当前的强制版本与需要的强制版本相符时,Zabbix Server 才会启动。

40668:20180122:115151.697 using configuration file: /app/product/zabbix3.2/etc/zabbix_server.conf
40668:20180122:115151.710 current database version (mandatory/optional): 03020000/03020000
40668:20180122:115151.710 required mandatory version: 03040000
40668:20180122:115151.710 optional patches were found
40668:20180122:115151.710 starting automatic database upgrade
40668:20180122:115151.728 completed 0% of database upgrade
40668:20180122:115151.837 completed 1% of database upgrade
40668:20180122:115151.918 completed 2% of database upgrade
40668:20180122:115151.951 completed 3% of database upgrade
......
40668:20180122:115156.580 completed 96% of database upgrade
40668:20180122:115156.584 completed 97% of database upgrade
40668:20180122:115156.594 completed 98% of database upgrade
40668:20180122:115156.623 completed 99% of database upgrade
40668:20180122:115156.685 completed 100% of database upgrade
40668:20180122:115156.685 database upgrade fully completed
40668:20180122:115156.834 server #0 started [main process]
40671:20180122:115156.835 server #1 started [configuration syncer #1]
40672:20180122:115156.835 server #2 started [alerter #1]
40673:20180122:115156.836 server #3 started [alerter #2]
40674:20180122:115156.836 server #4 started [alerter #3]
40675:20180122:115156.836 server #5 started [housekeeper #1]
40676:20180122:115156.837 server #6 started [timer #1]
40677:20180122:115156.837 server #7 started [http poller #1]
40678:20180122:115156.838 server #8 started [discoverer #1]
40680:20180122:115156.838 server #9 started [history syncer #1]
40681:20180122:115156.839 server #10 started [history syncer #2]
40683:20180122:115156.839 server #11 started [history syncer #3]
40685:20180122:115156.840 server #12 started [history syncer #4]
40687:20180122:115156.840 server #13 started [escalator #1]
40689:20180122:115156.841 server #14 started [proxy poller #1]
40691:20180122:115156.841 server #15 started [self-monitoring #1]
40693:20180122:115156.842 server #16 started [task manager #1]
40694:20180122:115156.842 server #17 started [poller #1]
40696:20180122:115156.843 server #18 started [poller #2]
40697:20180122:115156.843 server #19 started [poller #3]
40698:20180122:115156.844 server #20 started [poller #4]
40699:20180122:115156.844 server #21 started [poller #5]
40700:20180122:115156.845 server #22 started [unreachable poller #1]
40701:20180122:115156.850 server #23 started [trapper #1]
40705:20180122:115156.851 server #27 started [trapper #5]
40704:20180122:115156.853 server #26 started [trapper #4]
40702:20180122:115156.853 server #24 started [trapper #2]
40703:20180122:115156.854 server #25 started [trapper #3]
40706:20180122:115156.856 server #28 started [icmp pinger #1]
40707:20180122:115156.857 server #29 started [alert manager #1]
40708:20180122:115156.861 server #30 started [preprocessing manager #1]
40709:20180122:115156.950 server #31 started [preprocessing worker #1]
40710:20180122:115156.953 server #32 started [preprocessing worker #2]
40711:20180122:115156.953 server #33 started [preprocessing worker #3]

五、启动新的 Zabbix Server 二进制

[[email protected] ~]# /etc/init.d/zabbix_server start
Starting zabbix_server:                                      [  OK  ]
[[email protected] ~]# /etc/init.d/zabbix_agentd start
Starting zabbix_agentd:                                    [  OK  ]

六、安装新的Zabbix Web接口

在浏览器打开网址http://zabbix_server_ip/zabbix/setup.php

登陆 UI 界面

技术分享图片

[[email protected] ~]# rm -rf /app/product/zabbix3.2/etc/zabbix_server.conf
[[email protected] ~]# cp /opt/software/zabbix-3.4.6/conf/zabbix_server.conf /app/product/zabbix3.2/etc

七、升级过程中的故障解决

错误:

Starting zabbix_server:  /app/product/zabbix3.2/sbin/zabbix_server: error while loading shared libraries: libevent-2.1.so.6: cannot open shared object file: No such file or directory

解决方法:

[[email protected] etc]# ln -s /usr/local/lib/libevent-2.1.so.6 /usr/lib64/

错误:

configure: error: Unable to use libevent (libevent check failed)

解决方法:

http://libevent.org/
https://github.com/libevent/libevent/releases/download/release-2.1.8-stable/libevent-2.1.8-stable.tar.gz
[[email protected] software]# tar xf libevent-2.1.8-stable.tar.gz
[[email protected] software]# cd libevent-2.1.8-stable
[[email protected] libevent-2.1.8-stable]# ./configure
[[email protected] libevent-2.1.8-stable]# make && make install


以上是关于从 zabbix server 3.2 升级到 zabbix server 3.4.6的主要内容,如果未能解决你的问题,请参考以下文章

zabbix3.x.x升级教程

zabbix 3.2高可用

阿里云zabbix镜像从2.4源码升级至3.2.1版本

Zabbix 3.2 短信报警配置

运维工具Zabbix学习 16.zabbix3升级到zabbix5

zabbix6.0升级教程:源码包升级