1、简介
从别人给的告警处得知,zabbix4.4版本以下存在漏洞,这里就给予升级;官方bug修复【参考1】打开太慢,不方便;
从支持时间看4.4版本的支持时间也到了,需要替换为最新的了;【参考4】
本文记录的是http版本的zabbix4.4升级到5.0版本;操作系统版本是centos7
2、安装zabbix4.4【参考2】
官方的安装步骤 a. 安装 国内源,替换为阿里源 # rpm -Uvh https://mirrors.aliyun.com/zabbix/zabbix/4.0/rhel/7/x86_64/zabbix-release-4.0-2.el7.noarch.rpm # sed -i 's/repo.zabbix.com/mirrors.aliyun.com\/zabbix/g' /etc/yum.repos.d/zabbix.repo # yum clean all b. 安装Zabbix server,Web前端,agent # yum install zabbix-server-mysql zabbix-web-mysql zabbix-apache-conf zabbix-agent c. 创建初始数据库 在数据库主机上运行以下代码。 # mysql -uroot -p password mysql> create database zabbix character set utf8 collate utf8_bin; mysql> create user zabbix@localhost identified by 'password'; mysql> grant all privileges on zabbix.* to zabbix@localhost; mysql> quit; 导入初始架构和数据,系统将提示您输入新创建的密码。 # zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -uzabbix -p zabbix d. 为Zabbix server配置数据库 编辑配置文件 /etc/zabbix/zabbix_server.conf DBPassword=password e. 为Zabbix前端配置PHP 编辑配置文件 /etc/httpd/conf.d/zabbix.conf, uncomment and set the right timezone for you. # php_value date.timezone Europe/Riga f. 启动Zabbix server和agent进程 启动Zabbix server和agent进程,并为它们设置开机自启: # systemctl restart zabbix-server zabbix-agent httpd # systemctl enable zabbix-server zabbix-agent httpd g. 配置Zabbix前端 连接到新安装的Zabbix前端: http://server_ip_or_name/zabbix 账号:Admin 密码:zabbix
注意事项: 1)若是没有数据库,用mariadb作为数据库(MySQL的替代版本) yum install mariadb-server mariadb -y systemctl start mariadb 2)防火墙要打开,配置文件在/lib/firewalld/services/文件中,就是http.xml、zabbix-server.xml两个文件 firewall-cmd --permanent --add-service=http firewall-cmd --permanent --add-service=zabbix-server firewall-cmd --reload 3)若不想关闭selinux,使用下面的几步 yum install setroubleshoot -y setsebool -P httpd_can_network_connect 1 启动zabbix-server后,从命令journalctl -f若看到了报错,执行下面的命令 ausearch -c 'zabbix_server' --raw | audit2allow -M my-zabbixserver semodule -i my-zabbixserver.pp 4)记录系统生成的配置文件,若数据库改了密码,这个文件里面也是要改的 Configuration file "/etc/zabbix/web/zabbix.conf.php" created. 5)编辑PHP配置文件,设置为中国时区 [root@localhost ~]# cat /etc/httpd/conf.d/zabbix.conf |grep Asia php_value date.timezone Asia/Shanghai [root@localhost ~]#
3、升级为5.0【参考2】【参考5】【参考6】【参考7】
#关掉旧的zabbix监控系统,数据库不关,毕竟数据库要升级 systemctl stop zabbix-server zabbix-agent httpd #备份 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/ #安装源,并修改为阿里的地址,并启动fronted的源 rpm -Uvh https://mirrors.aliyun.com/zabbix/zabbix/5.0/rhel/7/x86_64/zabbix-release-5.0-1.el7.noarch.rpm sed -i 's/repo.zabbix.com/mirrors.aliyun.com\/zabbix/g' /etc/yum.repos.d/zabbix.repo sed -i '11 s/enabled=0/enabled=1/g' /etc/yum.repos.d/zabbix.repo yum clean all yum upgrade zabbix-server-mysql zabbix-web-mysql zabbix-agent -y #安装redhat的scl软件集合源,方便一个系统安装多个源,比如下面会自动安装的依赖包rh-php72 yum install centos-release-scl -y #移除旧的界面,否则新的界面会冲突,无法安装 yum remove zabbix-web zabbix-web-mysql -y #安装新的界面 yum install zabbix-web-mysql-scl zabbix-apache-conf-scl zabbix-web -y #可能会报错,多等个10秒就可以了; systemctl restart httpd mariadb systemctl restart zabbix-server zabbix-agent rh-php72-php-fpm #设置自启动 systemctl enable httpd mariadb zabbix-server zabbix-agent rh-php72-php-fpm
bug查看)参考1:https://www.zabbix.com/cn/release_notes
安装手册)参考2:https://www.zabbix.com/cn/download
使用手册)参考3:https://www.zabbix.com/documentation/4.0/zh/manual/web_monitoring/example
zabbix版本支持时间)参考4:https://www.zabbix.com/cn/life_cycle_and_release_policy
zabbix升级)参考5:https://www.zabbix.com/documentation/current/manual/installation/upgrade/packages/rhel_centos
zabbix升级-web部分)参考6:https://www.zabbix.com/documentation/current/manual/installation/install_from_packages/frontend_on_rhel7
zabbix升级-中文)参考7:https://blog.csdn.net/qq_41571056/article/details/106176259
时间:2020-09-10