zabbix4.4升级5.0
Zabbix4.4升级5.0
-
备份原数据
systemctl stop httpd zabbix-agent zabbix-server
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/ -
备份数据库
mysqldump -uzabbix -pzabbix --opt --skip-lock-tables zabbix | gzip > /home/backup/zabbix_$(date +%Y%m%d_%H%M%S).sql.gz -
卸载旧版本
yum remove zabbix-web-* httpd -
更新yum源
rpm -Uvh https://repo.zabbix.co3.m/zabbix/5.0/rhel/7/x86_64/zabbix-release-5.0-1.el7.noarch.rpm #如果更新失败,不是自己网络问题就把https改成http
yum clean all -
更新组件包
yum update zabbix-server zabbix-agent –y
修改源
[zabbix-frontend]
name=Zabbix Official Repository frontend - $basearch
baseurl=http://repo.zabbix.com/zabbix/5.0/rhel/7/$basearch/frontend
enabled=1 #修改为1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX-A14FE591 -
更新源后安装7.2的php
yum -y install http://mirror.centos.org/centos/7/extras/x86_64/Packages/centos-release-scl-rh-2-3.el7.centos.noarch.rpm
yum install zabbix-web-mysql-scl zabbix-apache-conf-scl –y
修改配置文件时区
vim /etc/opt/rh/rh-php72/php-fpm.d/zabbix.conf
修改时区 #php_value[date.timezone] = Asia/Shanghai
systemctl restart zabbix-server zabbix-agent httpd rh-php72-php-fpm
systemctl enable zabbix-server zabbix-agent httpd rh-php72-php-fpm
zabbix升级失败还原
1) 停止服务,还原版本
systemctl stop httpd zabbix-agent zabbix-server
yum remove zabbix-server zabbix-agent httpd rh-php72-php-fpm
rpm -Uvh https://repo.zabbix.com/zabbix/4.4/rhel/7/x86_64/zabbix-release-4.4-1.el7.noarch.rpm #装不装这个无所谓
sed –i ‘s/5.0/4.4/g’ /etc/yum.repos.d/zabbix.repo #修改好这个就可以直接安装了
yum clean all
yum install –y zabbix-web-* httpd zabbix-server zabbix-agent
2) 还原配置文件,重新启动
Cp /home/backup/zabbix_backup/zabbix_server.conf /etc/zabbix/zabbix_server.conf
Cp /home/backup/zabbix_backup/zabbix_agentd.conf /etc/zabbix/zabbix_agentd.conf
Cp /home/backup/zabbix_backup/zabbix.conf.php /etc/zabbix/web/zabbix.conf.php
vim /etc/httpd/conf.d/zabbix.conf #修改httpd时区
php_value date.timezone Asia/Shanghai
systemctl restart zabbix-server zabbix-agent httpd
zabbix-proxy升级
1、 备份配置文件
cp /etc/zabbix/zabbix_agentd.conf /home/backup/zabbix_backup/
cp /etc/zabbix/zabbix_proxy.conf /home/backup/zabbix_backup/
2、 更新yum源
rpm -Uvh http://repo.zabbix.com/zabbix/5.0/rhel/7/x86_64/zabbix-release-5.0-1.el7.noarch.rpm
yum clean all
3、 升级启动
yum update zabbix-agent -y zabbix-proxy -y
systemctl stop zabbix-agent zabbix-proxy
systemctl restart zabbix-agent zabbix-proxy
Zabbix升级报错
(1) 数据库连接超时断联警报,发现zabbix-server一直发送报警,查看日志发现
很多类似信息,后修改数据库配置文件log_warnings=1后,再无此类报警
log_warnings用于标识警告信息是否一并记录到错误日志中
log_warnings的值为0,表示不记录警告信息。
log_warnings的值为1,表示警告信息一并记录到错误日志中。
log_warnings的值大于1,表示"失败的连接"的信息和创建新连接时"拒绝访问"类的错误信息也会被记录到错误日志中。
mysql5.5中log_warnings参数的默认值为1
mysql5.7中log_warnings参数的默认值为2
mysql> show variables like "%log_warnings%";
(2) 修改数据库的设置非交互连接超时时间
mysql> set global wait_timeout = 120;
(3) 从低版本一直升级上来可能会有问题,所以如果数据库刚刚好够需要升级版本的标准还是升一下比较好,5.0官方文档mysql更新插件包
Use zabbix;
ALTER TABLE trends
MODIFY value_min DOUBLE PRECISION DEFAULT '0.0000' NOT NULL,
MODIFY value_avg DOUBLE PRECISION DEFAULT '0.0000' NOT NULL,
MODIFY value_max DOUBLE PRECISION DEFAULT '0.0000' NOT NULL;
ALTER TABLE history MODIFY value DOUBLE PRECISION DEFAULT '0.0000' NOT NULL;
(4) 升级后可能会再登录zabbix是报错,需要修改数据库
update dbversion set mandatory=5000000;
flush privileges;
(5) zabbix-proxy 升级报错
Z3005] query failed: [1091] Can't DROP 'c_items_1'; check that column/key exists [alter table items drop foreign key c_items_1]
解决办法:数据库执行以下语句
ALTER TABLE items ADD CONSTRAINT c_items_1 FOREIGN KEY (hostid) REFERENCES hosts (hostid) ON DELETE CASCADE;