升級要求
PHP版本
PHP版本已從最低的5.4.0 升級到 7.2.0
數據庫版本
- MySQL 5.5.62
- MariaDB 10.0.37
- PostgreSQL 9.2.24
- Oracle 11.2
如何升級PHP不再贅述,本環境爲7.2版本。
ZABBIX備份
mkdir -p /home/backup/zabbix-backup
cp /etc/zabbix/zabbix_server.conf /home/backup/zabbix-backup
cp /etc/zabbix/zabbix_agentd.conf /home/backup/zabbix-backup
cp /etc/zabbix/web/zabbix.conf.php /home/backup/zabbix-backup
cp -R /usr/share/zabbix/ /home/backup/zabbix-backup
cp –R /usr/share/doc/zabbix-* /home/backup/zabbix-backup
數據庫備份
mysql root@localhost:(none)> select count(8) tables,table_schema from information_schema.tables where table_schema = 'zabbix';
+--------+--------------+
| tables | table_schema |
+--------+--------------+
| 149 | zabbix |
+--------+--------------+
1 row in set
Time: 0.014s
mysqldump -uzabbix -pzabbix --opt --skip-lock-tables zabbix | gzip > /home/backup/zabbix_$(date +%Y%m%d_%H%M%S).sql.gz
[root@shvm01 doc]# ll /home/backup/
總用量 5120
-rw-r--r-- 1 root root 20 4月 23 10:48 zabbix_20200423_104832.sql.gz
-rw-r--r-- 1 root root 5233446 4月 23 10:48 zabbix_20200423_104849.sql.gz
drwxr-xr-x 3 root root 4096 4月 23 10:45 zabbix-backup
停止 zabbix-server zabbix-agent 服務
systemctl stop zabbix-server zabbix-agent
卸載舊版本服務
yum remove zabbix-web-* httpd
升級:
rpm -Uvh https://repo.zabbix.com/zabbix/5.0/rhel/7/x86_64/zabbix-release-5.0-1.el7.noarch.rpm
yum clean all
yum update zabbix-server-mysql zabbix-agent
yum-config-manager --enable rhel-server-rhscl-7-rpms
編輯配置文件 /etc/yum.repos.d/zabbix.repo and enable zabbix-frontend repository.
[zabbix-frontend]
...
enabled=1
...
安裝ZABBIX 前端包
yum install zabbix-web-mysql-scl zabbix-apache-conf-scl
爲Zabbix前端配置PHP
編輯配置文件 /etc/opt/rh/rh-php72/php-fpm.d/zabbix.conf, uncomment and set the right timezone for you.
php_value[date.timezone] = Asia/Shanghai
啓動Zabbix server和agent進程,併爲它們設置開機自啓:
systemctl restart zabbix-server zabbix-agent httpd rh-php72-php-fpm
systemctl enable zabbix-server zabbix-agent httpd rh-php72-php-fpm
附:
安裝過程中有數據庫報錯:Index column size too large
根據報錯提示可以看出是因爲索引列太大導致。
【解決辦法】:
根據報錯提示,嘗試解決:
先檢查一下是不是數據庫被限制了索引的大小
SHOW variables like 'innodb_large_prefix'
如果查詢的值是OFF的話 執行下面命令
SET GLOBAL INNODB_LARGE_PREFIX = ON;
執行完了 之後 還得查看當前的innodb_file_format引擎格式類型是不是BARRACUDA
SHOW variables like 'innodb_file_format'
如果不是的話則需要修改 SET GLOBAL innodb_file_format = BARRACUDA;
但是再次執行上面的修改語句還是會報相同的錯誤。
查了下資料,發現需要更改表的結構:
alter table items row_format=dynamic;
alter table items row_format=compressed;
再次執行後,可以正常執行。