1. 程式人生 > >從 zabbix server 3.2 升級到 zabbix server 3.4.6

從 zabbix server 3.2 升級到 zabbix server 3.4.6

poi repo required mark usr while alt err cer

一、停止 zabbix Server

[root@jrgc ~]# /etc/init.d/zabbix_server stop
Shutting down zabbix_server:                                [  OK  ]
[root@jrgc ~]# /etc/init.d/zabbix_agentd stop
Shutting down zabbix_agentd:                               [  OK  ]

二、備份現有的 Zabbix Server 數據庫

防止升級過程失敗(如磁盤空間不足,斷電及其他意外問題)。

[root@jrgc ~]# mysqldump -uzabbix -p你的密碼 zabbix > zabbix_back.sql

三、備份配置文件,PHP 文件和 Zabbix 二進制文件

#備份 web 目錄
[root@jrgc ~]# cd /app/product/nginx/html/
[root@jrgc 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
[root@jrgc html]# /bin/cp -fr zabbix/ zabbixbackup   #<--f:強制復制
[root@jrgc 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
[root@jrgc product]# mkdir /opt/backup/zabbix3.2
[root@jrgc product]# cd zabbix3.2/
[root@jrgc 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 配置信息
[root@jrgc zabbix3.2]# cd etc
[root@jrgc 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
[root@jrgc etc]# cd ..
[root@jrgc 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
[root@jrgc ~]# cd /opt/software/
[root@jrgc software]# tar xf zabbix-3.4.6.tar.gz
[root@jrgc ~]# cd /opt/software/zabbix-3.4.6
[root@jrgc 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>                    *
***********************************************************
[root@jrgc zabbix-3.4.6]# make
[root@jrgc zabbix-3.4.6]# make install
[root@jrgc zabbix-3.4.6]# cd frontends/php/
[root@jrgc zabbix-3.4.6]# rm -rf /app/product/nginx/html/zabbix/*
[root@jrgc 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 二進制

[root@jrgc ~]# /etc/init.d/zabbix_server start
Starting zabbix_server:                                      [  OK  ]
[root@jrgc ~]# /etc/init.d/zabbix_agentd start
Starting zabbix_agentd:                                    [  OK  ]

六、安裝新的Zabbix Web接口

在瀏覽器打開網址http://zabbix_server_ip/zabbix/setup.php

登陸 UI 界面

技術分享圖片

[root@jrgc ~]# rm -rf /app/product/zabbix3.2/etc/zabbix_server.conf
[root@jrgc ~]# 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

解決方法:

[root@jrgc 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
[root@jrgc software]# tar xf libevent-2.1.8-stable.tar.gz
[root@jrgc software]# cd libevent-2.1.8-stable
[root@jrgc libevent-2.1.8-stable]# ./configure
[root@jrgc libevent-2.1.8-stable]# make && make install


從 zabbix server 3.2 升級到 zabbix server 3.4.6