Zabbix6.0升级为6.4
为了体验一些新的功能,比如
Webhook
和问题抑制等,升级个小版本。
一、环境信息
1. 版本要求
一定要事先查看官方文档,确认组件要求的版本,否则版本过高或者过低都会出现问题。
2. 升级前后信息
环境 | 升级前 | 升级后 |
---|---|---|
操作系统 | CentOS 7.3 | CentOS 7.3 |
MySQL | 8.0.28 | 8.0.40 |
PHP | 7.4.30 | 7.4.30 |
Zabbix-Server-MySQL | 6.0.8 | 6.4 |
Zabbix-Web-MySQL | 6.0.8 | 6.4 |
二、升级MySQL
1. 停止数据库
mysql> set global innodb_fast_shutdown=0;
# systemctl stop mysqld
2. 安装启动8.0.40
在MySQL 8.0及之后版本中,不再需要启动后执行
mysql_upgrade
命令,会自动检测后自动升级版本。
# wget https://dev.mysql.com/get/Downloads/MySQL-8.0/mysql-8.0.40-1.el7.x86_64.rpm-bundle.tar
# tar xf mysql-8.0.40-1.el7.x86_64.rpm-bundle.tar
# yum localinstall mysql-community-*
# systemctl start mysqld
# 查看日志 确认升级成功
# [root@zbx_db_test mysql80]# tailf /data/mysql/error.log
2024-12-18T09:12:21.214297Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.40) starting as process 8878
2024-12-18T09:12:21.225868Z 0 [Warning] [MY-012364] [InnoDB] innodb_open_files should not be greater than the open_files_limit.
2024-12-18T09:12:21.225931Z 0 [Warning] [MY-013907] [InnoDB] Deprecated configuration parameters innodb_log_file_size and/or innodb_log_files_in_group have been used to compute innodb_redo_log_capacity=268435456. Please use innodb_redo_log_capacity instead.
2024-12-18T09:12:21.227965Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2024-12-18T09:12:21.728676Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
2024-12-18T09:12:23.042597Z 4 [System] [MY-013381] [Server] Server upgrade from '80028' to '80040' started.
2024-12-18T09:12:26.270068Z 4 [System] [MY-013381] [Server] Server upgrade from '80028' to '80040' completed.
2024-12-18T09:12:26.342403Z 0 [Warning] [MY-011302] [Server] Plugin mysqlx reported: 'Failed at SSL configuration: "SSL context is not usable without certificate and private key"'
2024-12-18T09:12:26.342534Z 0 [System] [MY-011323] [Server] X Plugin ready for connections. Bind-address: '::' port: 33060, socket: /var/run/mysqld/mysqlx.sock
2024-12-18T09:12:26.342595Z 0 [System] [MY-010931] [Server] /usr/sbin/mysqld: ready for connections. Version: '8.0.40' socket: '/var/lib/mysql/mysql.sock' port: 3306 MySQL Community Server - GPL.
3. 不停机数据备份
在生产环境中,要进行数据备份。在
MySQL 8.0
中,不能直接用xtrbackup 2.4
之前的版本备份,只能用percona-xtrabackup-80.x
版本备份。
- 数据备份
# xtrabackup --defaults-file=/etc/my.cnf --user=root --password=xiM37mwXotfO# --backup --parallel=8 --target-dir=/data/backup1218
- 数据还原
# xtrabackup --prepare --use-memory=4G --target-dir=/data/backup1218
# xtrabackup --defaults-file=/etc/my.cnf --copy-back --target-dir=/data/backup1218
三、升级Zabbix-Sever
因为操作系统是
CentOS 7
,已经不支持RPM
包安装了,所以采用的是源码安装。
1. 升级安装包
# wget https://cdn.zabbix.com/zabbix/sources/stable/6.4/zabbix-6.4.20.tar.gz
# tar xf zabbix-6.4.20.tar.gz && cd zabbix-6.4.20
# ./configure --prefix=/usr/local/zabbix-server-6.4 --enable-server --enable-agent --with-mysql --with-net-snmp --with-libcurl --with-libxml2 --with-openipmi
# make install
3. 数据库设置参数
mysql> set global log_bin_trust_function_creators=1; (在升级过程中需要开启这个参数)
如果不设置上面参数,使用新版本启动升级过程会报错失败,报错如下:
[root@zabbix_64 zabbix-server-6.4]# tailf /tmp/zabbix_server.log
29320:20241218:171619.136 completed 11% of database upgrade
29320:20241218:171619.171 completed 12% of database upgrade
29320:20241218:171619.208 completed 13% of database upgrade
29320:20241218:171619.276 completed 14% of database upgrade
29320:20241218:171619.299 completed 15% of database upgrade
29320:20241218:171619.303 [Z3005] query failed: [1419] You do not have the SUPER privilege and binary logging is enabled (you *might* want to use the less safe log_bin_trust_function_creators variable) [create trigger hosts_insert after insert on hosts
for each row
insert into changelog (object,objectid,operation,clock)
values (1,new.hostid,1,unix_timestamp())]
29320:20241218:171619.304 database upgrade failed on patch 06010049, exiting in 10 seconds
29320:20241218:171629.304 Zabbix Server stopped. Zabbix 6.4.20 (revision 114e4f42c15).
....
3. 验证升级
- 服务启动
# 更新启动配置文件
# cat /lib/systemd/system/zabbix-server.service
[Unit]
Description=Zabbix Server
After=syslog.target
After=network.target
After=mysql.service
After=mysqld.service
After=mariadb.service
After=postgresql.service
After=pgbouncer.service
After=postgresql-9.4.service
After=postgresql-9.5.service
After=postgresql-9.6.service
After=postgresql-10.service
After=postgresql-11.service
After=postgresql-12.service
[Service]
Environment="CONFFILE=/etc/zabbix/zabbix_server.conf"
EnvironmentFile=-/etc/sysconfig/zabbix-server
Type=forking
Restart=on-failure
PIDFile=/run/zabbix/zabbix_server.pid
KillMode=control-group
ExecStart=/usr/local/zabbix-server-6.4/sbin/zabbix_server -c $CONFFILE
ExecStop=/bin/kill -SIGTERM $MAINPID
RestartSec=10s
TimeoutSec=0
[Install]
WantedBy=multi-user.target
# systemctl daemon-reload
# systemctl start zabbix-server
- 查看日志,确认升级成功
[root@zabbix_64 zabbix-server-6.4]# tailf /tmp/zabbix_server.log
四、升级 Zabbix前端
6.4 版本,前端文件都存放在
UI
目录中。
# mv /usr/share/zabbix /usr/share/zabbix_6.0
# mv /usr/src/zabbix-server-6.4/ui /usr/share/zabbix # 从解压目录中获取
- 前端界面配置
不开启数据库连接加密
Reference:
https://www.zabbix.com/cn/whats_new_6_4
https://www.zabbix.com/cn/download_sources#64
https://www.zabbix.com/documentation/6.4/zh/manual/installation/requirements
https://www.zabbix.com/documentation/6.4/en/manual/installation/upgrade_notes_640