当前位置: 首页 > 科技观察

Zabbix随笔:6.0LTS升级指南之一

时间:2023-03-13 23:50:42 科技观察

本文主要讨论如何将Zabbix5.0LTS升级到6.0LTS。本文的环境注意本文的环境可能和你的环境不一样,所以问题可能不一样!CentOS7.9.2009Mariadb10.3ZabbixLTS5.0.20虚拟机环境是VMwareZabbix5.0.20升级思路系统升级->数据库升级->ZabbixServer升级停止相关服务systemctlstopzabbix-serverzabbix-agentrh-nginx116-nginxrh-php72-php-fpmmariadbpreparationworkinstallepelsource,yum-utilstoolyum-yinstallepel-releaseyum-yinstallyum-utilsrpmconf删除重复/未使用的安装包(可选)rpmconf-apackage-cleanup--leavespackage-cleanup--orphansinstalldnf(C8默认安装工具,yum升级版)yum-yinstalldnfupgradetoCentOS8dnf-yupgrade如果安装CentOS7.6,会遇到错误。原因是Python版本不匹配。需要升级Python版本,安装dnf相关组件。yumupdate-ypython*yuminstall-ydnf-datadnf-plugins-corelibdnf-devellibdnfpython2-dnf-plugin-migratednf-automatic安装CentOS8的镜像源(本文使用阿里的源),自CentOS8已经停止技术支持,所以需要使用centos-valut的yum源mv/etc/yum.repos.d/CentOS-Base.repo/etc/yum.repos.d/CentOS-Base.repo.bakcurl-o/etc/yum.repos.d/CentOS-Base.repohttps://mirrors.aliyun。com/repo/Centos-vault-8.5.2111.repo由于CentOS8已经停止支持,源已经切换到centos-valut,本文使用将原来的源备份到另一个名字来升级epel8的源dnf-yupgradeepel-release删除旧内核和冲突的软件rpm-e`rpm-qkernel`rpm-e--nodepssysvinit-toolsversionupgradednf-y--releasever=8--allowerasing--setopt=deltarpm=falsedistro-sync遇到的第一个问题就是更新时CentOS8的源失效。执行以下命令继续更新cd/etc/yum.repos.d/mkdirbakmvCentOS-Linux-*bak/mvCentOS-Base.repo.rpmsaveCentOS-Base.repo由于Zabbix本身安装在all-in-一种方式,会出现下面的问题。此时需要添加CentOS8的mariadb源,而Zabbix6.0LTS推荐的数据库版本为10.6,所以建议添加10.6cat</etc/yum.repos的yum源。d/mariadb.repo#MariaDB10.6CentOS存储库列表-创建于2022-01-1615:10UTC#https://mariadb.org/download/[mariadb]name=MariaDBbaseurl=https://mirrors.cloud.tencent。com/mariadb/yum/10.6/centos8-amd64module_hotfixes=1gpgkey=https://mirrors.cloud.tencent.com/mariadb/yum/RPM-GPG-KEY-MariaDBgpgcheck=1EOF如果继续执行更新命令,报错这个时候会出现,如下图,主要原因是在7版本的时候,软件的名字从8版本开始变了。比如Centos7中的python3-rpmconf,到了8版本就会变成python36-rpmconf.由于这些软件有一定的依赖性,卸载后rpm不能正常使用,所以在处理的时候不能直接卸载。相反,删除包裹信信息,不要卸载软件(注意根据报错,你的版本可能不是这个)rpm-e--justdbpython36-rpmconf-1.0.22-1.el7.noarchrpmconf-1.0.22-1。el7.noarchrpm-e--justdbyum-3.4.3-168.el7.centos.noarchyum-utils-1.1.31-54.el7_8.noarchpython2-dnf-plugin-migrate-4.0.2.2-3.el7_6。noarchyum-plugin-fastestmirror-1.1.31-54.el7_8.noarch完成以上步骤后,继续升级命令。升级完成后查看版本,重启服务器,reboot,查看内核,安装CentOS8Minimal相关组件,dnf组更新“Core”“MinimalInstall”-yZabbix部分升级Zabbix源,本文使用清华源猫</etc/yum.repos.d/zabbix.repo[zabbix]name=Zabbix官方仓库-\$basearchbaseurl=https://mirrors.tuna.tsinghua.edu。cn/zabbix/zabbix/6.0/rhel/8/\$basearch/enabled=1gpgcheck=1gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX-A14FE591[zabbix-不支持]name=ZabbixOfficialRepositorynon-supported-\$basearchbaseurl=https://mirrors.tuna.tsinghua.edu.cn/zabbix/non-supported/rhel/8/\$basearch/enabled=1gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIXgpgcheck=1EOF导入GPGKeycurlhttps://mirrors.tuna.tsinghua.edu.cn/zabbix/RPM-GPG-KEY-ZABBIX-A14FE591\-o/etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX-A14FE591curlhttps://mirrors.tuna.tsinghua.edu.cn/zabbix/RPM-GPG-KEY-ZABBIX\-o/etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIXcurlhttps://mirrors.tuna.tsinghua.edu.cn/zabbix/RPM-GPG-KEY-ZABBIX-A14FE591\-o/etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX-A14FE591curlhttps://mirrors.tuna.tsinghua.edu.cn/zabbix/RPM-GPG-KEY-ZABBIX\-o/etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX升级相关组件dnf-yinstallzabbix-server-mysqlzabbix-web-mysqlzabbix-nginx-confzabbix-sql-scriptszabbix-selinux-policyzabbix-agentstart相关组件systemctlstartzabbix-serverzabbix-agentnginxphp-fpmupgradedatabasemysql_upgrade-uroot-pxiaoyu123systemctlrestartmariadb报错解决如果发现此时无法连接数据库,请检查firewalld服务和selinuxareenabled(optional)systemctlstopfirewalldsystemctldisablefirewalldsetenforce0出现如下问题,进入zabbix数据库输入以下命令解决mysql-uroot-pusezabbixSETGLOBALinnodb_strict_mode=OFF;exitdatabaseupgradefailed升级成功修改zabbixServer配置vim/etc/zabbix/zabbix_server.confDBPassword=xiaoyu123修改Nginx配置,需要在ngnix.conf中将server块的80端口注释掉,如下图1,然后在conf.d中取消zabbix.conf的80端口注释,如下图图2vim/etc/nginx/nginx.confvim/etc/nginx/conf.d/zabbix.conf添加注释取消注释前端效果结论由于CentOS8已经进入EOL状态,建议使用其他发行版。很多发行版都提供了转换工具,或者使用ubuntu、debian等发行版安装新版本的Zabbix