avatar

目录
Zabbix3.4一步步升级至4.2版本(yum安装)

简言

前面我们已经介绍了Zabbix3.4的安装教程,但是随着zabbix的更新,现在已经到zabbix4的版本了。下面我们介绍此种安装方式如何进行升级

一、系统环境

Code
1
cat /etc/redhat-release

在这里插入图片描述
原有zabbix版本:Zabbix 3.4.15
升级zabbix版本:Zabbix 4.2.5

二、备份工作

因为我们是生产环境,所以升级之前要进行备份。
1.备份数据库
这是非常重要的一步。确保您具有数据库的备份。如果升级过程失败(缺少磁盘空间,关闭电源,出现意外问题),这将有所帮助。
简单备份

Code
1
mysqldump -uzabbix -p你的密码 zabbix > zabbix_back.sql

推荐备份
数据库全备时间比较长且文件交大,建议压缩或者使用xtrabackup, 此处采用mysqldump, 后面文档介绍具体用法

Code
1
2
mysqldump -uzabbix -p你的密码 --opt --skip-lock-tables --database zabbix > zabbix.sql
mysqldump -uzabbix -p你的密码 --opt --skip-lock-tables --database zabbix | gzip > zabbix_`date +'%Y%m%d%H%M%S'`.sql.gz

在这里插入图片描述
2.备份zabbix文件

Code
1
2
3
4
5
mkdir /opt/zabbix-backup/  #创建一个空文件
cp /etc/zabbix/zabbix_server.conf /opt/zabbix-backup/
cp /etc/httpd/conf.d/zabbix.conf /opt/zabbix-backup/
cp -R /usr/share/zabbix/ /opt/zabbix-backup/
cp -R /usr/share/doc/zabbix-* /opt/zabbix-backup/

三、检查及卸载当前zabbix版本

1、先停zabbix-server

Code
1
systemctl  stop zabbix-server.service

在这里插入图片描述
2、检查当前版本

Code
1
2
3
4
5
[root@localhost ~]# rpm -qa zabbix-web-mysql
zabbix-web-mysql-3.4.15-1.el7.noarch

[root@localhost ~]# rpm -qa zabbix-server-mysql
zabbix-server-mysql-3.4.15-1.el7.x86_64

3、卸载当前版本

Code
1
2
3
yum remove zabbix-server-mysql zabbix-web-mysql -y
yum remove zabbix-release -y
yum clean all

4、下载新版本yum源仓库地址

Code
1
rpm -Uvh https://repo.zabbix.com/zabbix/4.2/rhel/7/x86_64/zabbix-release-4.2-2.el7.noarch.rpm

在这里插入图片描述
5、安装新版本Zabbix3.4.1

Code
1
yum -y install zabbix-server-mysql zabbix-web-mysql zabbix-agent

在这里插入图片描述

四、配置及升级

1、配置数据库用户及密码

Code
1
grep '^'[a-Z] /etc/zabbix/zabbix_server.conf

这里我们发现里面没有密码这一项,我们手动添加DBPassword=zabbix

在这里插入图片描述

Code
1
grep '^'[a-Z] /etc/zabbix/zabbix_agentd.conf

将主机名称和server一致,否则会报下面的问题
cannot send list of active checks to “127.0.0.1”: host [Zabbix server] not
在这里插入图片描述
2、编辑Zabbix前端PHP配置,更改时区

Code
1
2
vim /etc/httpd/conf.d/zabbix.conf
php_value date.timezone Asia/Shanghai

在这里插入图片描述
3、启动zabbix服务

Code
1
2
systemctl enable zabbix-server
systemctl start zabbix-server

4、SELinux配置

Code
1
2
setsebool -P httpd_can_connect_zabbix on
setsebool -P httpd_can_network_connect_db on

5、启动httpd并设置开机启动

Code
1
2
systemctl start httpd
systemctl enable httpd

6、查看日志信息,是否升级成功(升级的时间会根据的数据库的大小决定你升级的时间)

Code
1
tail -f /var/log/zabbix/zabbix_server.log

2332:20170908:210551.886 server #9 started [trapper #1]
2335:20170908:210551.887 server #12 started [trapper #4]
2336:20170908:210551.889 server #13 started [trapper #5]
2341:20170908:210551.929 server #18 started [http poller #1]
1909:20170908:210654.146 Got signal [signal:15(SIGTERM),sender_pid:2398,sender_uid:0,reason:0]. Exiting …
1909:20170908:210656.146 syncing history data…
1909:20170908:210656.147 syncing history data done
1909:20170908:210656.147 syncing trend data…
1909:20170908:210656.149 syncing trend data done
1909:20170908:210656.149 Zabbix Server stopped. Zabbix 3.2.7 (revision 70298).
2783:20170908:213055.812 Starting Zabbix Server. Zabbix 3.4.1 (revision 71734).
2783:20170908:213055.813 ** Enabled features **
2783:20170908:213055.813 SNMP monitoring: YES
2783:20170908:213055.813 IPMI monitoring: YES
2783:20170908:213055.813 Web monitoring: YES
2783:20170908:213055.813 VMware monitoring: YES
2783:20170908:213055.813 SMTP authentication: YES
2783:20170908:213055.813 Jabber notifications: YES
2783:20170908:213055.813 Ez Texting notifications: YES
2783:20170908:213055.813 ODBC: YES
2783:20170908:213055.813 SSH2 support: YES
2783:20170908:213055.813 IPv6 support: YES
2783:20170908:213055.813 TLS support: YES
2783:20170908:213055.813 **
2783:20170908:213055.813 using configuration file: /etc/zabbix/zabbix_server.conf
2783:20170908:213055.817 current database version (mandatory/optional): 03020000/03020000
2783:20170908:213055.817 required mandatory version: 03040000
2783:20170908:213055.817 starting automatic database upgrade
2783:20170908:213055.842 completed 0% of database upgrade
2783:20170908:213055.886 completed 1% of database upgrade
2783:20170908:213055.904 completed 2% of database upgrade
2783:20170908:213055.920 completed 3% of database upgrade
2783:20170908:213055.922 completed 4% of database upgrade
2783:20170908:213055.951 completed 5% of database upgrade
2783:20170908:213056.028 completed 6% of database upgrade
2783:20170908:213056.043 completed 7% of database upgrade
2783:20170908:213056.047 completed 8% of database upgrade
2783:20170908:213056.067 completed 9% of database upgrade
2783:20170908:213056.170 completed 10% of database upgrade
2783:20170908:213056.238 completed 11% of database upgrade
2783:20170908:213056.240 completed 12% of database upgrade
2783:20170908:213056.244 completed 13% of database upgrade
2783:20170908:213056.265 completed 14% of database upgrade
2783:20170908:213056.271 completed 15% of database upgrade
2783:20170908:213056.381 completed 16% of database upgrade
2783:20170908:213056.448 completed 17% of database upgrade
2783:20170908:213056.499 completed 18% of database upgrade
2783:20170908:213056.502 completed 19% of database upgrade
2783:20170908:213056.516 completed 20% of database upgrade
2783:20170908:213056.557 completed 21% of database upgrade
2783:20170908:213056.570 completed 22% of database upgrade
2783:20170908:213056.603 completed 23% of database upgrade
2783:20170908:213056.621 completed 24% of database upgrade
2783:20170908:213056.650 completed 25% of database upgrade
2783:20170908:213056.689 completed 26% of database upgrade
2783:20170908:213056.721 completed 27% of database upgrade
2783:20170908:213056.726 completed 28% of database upgrade
2783:20170908:213056.733 completed 29% of database upgrade
2783:20170908:213056.768 completed 30% of database upgrade
2783:20170908:213056.771 completed 31% of database upgrade
2783:20170908:213056.795 completed 32% of database upgrade
2783:20170908:213056.798 completed 33% of database upgrade
2783:20170908:213056.802 completed 34% of database upgrade
2783:20170908:213056.805 completed 35% of database upgrade
2783:20170908:213056.807 completed 36% of database upgrade
2783:20170908:213056.809 completed 37% of database upgrade
2783:20170908:213056.812 completed 38% of database upgrade
2783:20170908:213056.815 completed 39% of database upgrade
2783:20170908:213056.882 completed 40% of database upgrade
2783:20170908:213056.921 completed 41% of database upgrade
2783:20170908:213056.935 completed 42% of database upgrade
2783:20170908:213056.938 completed 43% of database upgrade
2783:20170908:213056.940 completed 44% of database upgrade
2783:20170908:213056.943 completed 45% of database upgrade
2783:20170908:213056.966 completed 46% of database upgrade
2783:20170908:213057.004 completed 47% of database upgrade
2783:20170908:213057.022 completed 48% of database upgrade
2783:20170908:213057.050 completed 49% of database upgrade
2783:20170908:213057.165 completed 50% of database upgrade
2783:20170908:213057.193 completed 51% of database upgrade
2783:20170908:213057.200 completed 52% of database upgrade
2783:20170908:213057.204 completed 53% of database upgrade
2783:20170908:213057.209 completed 54% of database upgrade
2783:20170908:213057.328 completed 55% of database upgrade
2783:20170908:213057.346 completed 56% of database upgrade
2783:20170908:213057.352 completed 57% of database upgrade
2783:20170908:213057.359 completed 58% of database upgrade
2783:20170908:213057.422 completed 59% of database upgrade
2783:20170908:213057.437 completed 60% of database upgrade
2783:20170908:213057.455 completed 61% of database upgrade
2783:20170908:213057.475 completed 62% of database upgrade
2783:20170908:213057.516 completed 63% of database upgrade
2783:20170908:213057.520 completed 64% of database upgrade
2783:20170908:213057.611 completed 65% of database upgrade
2783:20170908:213057.628 completed 66% of database upgrade
2783:20170908:213057.633 completed 67% of database upgrade
2783:20170908:213057.635 completed 68% of database upgrade
2783:20170908:213057.636 completed 69% of database upgrade
2783:20170908:213057.639 completed 70% of database upgrade
2783:20170908:213057.706 completed 71% of database upgrade
2783:20170908:213057.744 completed 72% of database upgrade
2783:20170908:213057.749 completed 73% of database upgrade
2783:20170908:213057.757 completed 74% of database upgrade
2783:20170908:213057.771 completed 75% of database upgrade
2783:20170908:213057.781 completed 76% of database upgrade
2783:20170908:213057.796 completed 77% of database upgrade
2783:20170908:213057.821 completed 78% of database upgrade
2783:20170908:213057.856 completed 79% of database upgrade
2783:20170908:213058.033 completed 80% of database upgrade
2783:20170908:213058.131 completed 81% of database upgrade
2783:20170908:213058.147 completed 82% of database upgrade
2783:20170908:213058.157 completed 83% of database upgrade
2783:20170908:213058.167 completed 84% of database upgrade
2783:20170908:213058.177 completed 85% of database upgrade
2783:20170908:213058.185 completed 86% of database upgrade
2783:20170908:213058.190 completed 87% of database upgrade
2783:20170908:213058.192 completed 88% of database upgrade
2783:20170908:213058.199 completed 89% of database upgrade
2783:20170908:213058.209 completed 90% of database upgrade
2783:20170908:213058.219 completed 91% of database upgrade
2783:20170908:213058.233 completed 92% of database upgrade
2783:20170908:213058.288 completed 93% of database upgrade
2783:20170908:213058.309 completed 94% of database upgrade
2783:20170908:213058.310 completed 95% of database upgrade
2783:20170908:213058.311 completed 96% of database upgrade
2783:20170908:213058.313 completed 97% of database upgrade
2783:20170908:213058.314 completed 98% of database upgrade
2783:20170908:213058.315 completed 99% of database upgrade
2783:20170908:213058.316 completed 100% of database upgrade
2783:20170908:213058.316 database upgrade fully completed #看到该信息表示升级成功
2783:20170908:213058.322 server #0 started [main process]
2814:20170908:213058.346 server #27 started [trapper #5]
2798:20170908:213058.348 server #11 started [history syncer #3]
2800:20170908:213058.349 server #13 started [escalator #1]
2801:20170908:213058.350 server #14 started [proxy poller #1]
2803:20170908:213058.353 server #16 started [task manager #1]
2806:20170908:213058.353 server #19 started [poller #3]
2809:20170908:213058.365 server #22 started [unreachable poller #1]
2810:20170908:213058.376 server #23 started [trapper #1]
2817:20170908:213058.378 server #30 started [preprocessing manager #1]
2799:20170908:213058.378 server #12 started [history syncer #4]
2795:20170908:213058.378 server #8 started [discoverer #1]
2808:20170908:213058.390 server #21 started [poller #5]
2819:20170908:213058.400 server #32 started [preprocessing worker #2]
2816:20170908:213058.401 server #29 started [alert manager #1]
2791:20170908:213058.401 server #4 started [alerter #3]
2811:20170908:213058.401 server #24 started [trapper #2]
2788:20170908:213058.404 server #1 started [configuration syncer #1]
2789:20170908:213058.404 server #2 started [alerter #1]
2792:20170908:213058.404 server #5 started [housekeeper #1]
2793:20170908:213058.404 server #6 started [timer #1]
2794:20170908:213058.405 server #7 started [http poller #1]
2797:20170908:213058.405 server #10 started [history syncer #2]
2802:20170908:213058.405 server #15 started [self-monitoring #1]
2804:20170908:213058.406 server #17 started [poller #1]
2807:20170908:213058.416 server #20 started [poller #4]
2812:20170908:213058.427 server #25 started [trapper #3]
2813:20170908:213058.429 server #26 started [trapper #4]
2815:20170908:213058.431 server #28 started [icmp pinger #1]
2790:20170908:213058.431 server #3 started [alerter #2]
2796:20170908:213058.431 server #9 started [history syncer #1]
2805:20170908:213058.432 server #18 started [poller #2]
2820:20170908:213058.448 server #33 started [preprocessing worker #3]
2818:20170908:213058.449 server #31 started [preprocessing worker #1]
在这里插入图片描述

8、升级成功之后的问题处理
31503:20170909:110826.194 Starting Zabbix Server. Zabbix 3.4.1 (revision 71734).
31503:20170909:110826.194 ** Enabled features **
31503:20170909:110826.194 SNMP monitoring: YES
31503:20170909:110826.194 IPMI monitoring: YES
31503:20170909:110826.194 Web monitoring: YES
31503:20170909:110826.194 VMware monitoring: YES
31503:20170909:110826.194 SMTP authentication: YES
31503:20170909:110826.194 Jabber notifications: YES
31503:20170909:110826.195 Ez Texting notifications: YES
31503:20170909:110826.195 ODBC: YES
31503:20170909:110826.195 SSH2 support: YES
31503:20170909:110826.195 IPv6 support: YES
31503:20170909:110826.195 TLS support: YES
31503:20170909:110826.195 **
31503:20170909:110826.195 using configuration file: /etc/zabbix/zabbix_server.conf
31503:20170909:110826.201 current database version (mandatory/optional): 03040000/03040000
31503:20170909:110826.201 required mandatory version: 03040000
31503:20170909:110826.556 __mem_malloc: skipped 6 asked 64112 skip_min 584 skip_max 24312
31503:20170909:110826.557 [file:dbconfig.c,line:90] zbx_mem_realloc(): out of memory (requested 64112 bytes)
31503:20170909:110826.557 [file:dbconfig.c,line:90] zbx_mem_realloc(): please increase CacheSize configuration parameter
31526:20170909:110836.699 Starting Zabbix Server. Zabbix 3.4.1 (revision 71734).

找到zabbix的主配置文件 修改如下:

Code
1
vim /etc/zabbix/zabbix_server.conf

CacheSize=512M
这样就升级成功了

文章作者: 刘向洋
文章链接: https://liuxiangyang.space/2019/08/21/00172/
版权声明: 本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 LXY`S BLOG
打赏
  • 微信
    微信
  • 支付宝
    支付宝

评论
广告