centos7升级centos8
-安装epel存储库
yum install epel-release -y
-安装yum-utils工具
yum install yum-utils -y
-解析rpm包
yum install rpmconf -y
yes | rpmconf -a # 如果出现一些提示,请输入Y和回车继续
package-cleanup --leaves
package-cleanup --orphans
yum -y remove python36-rpmconf rpmconf
-安装dnf
yum install dnf -y
-删除软件包管理器
dnf remove yum yum-metadata-parser
rm -rf /etc/yum
-升级
dnf upgrade -y
-使用dnf安装CentOS 8发行包 http://mirrors.aliyun.com/centos/8-stream/BaseOS/x86_64/os/Packages/
http://mirrors.aliyun.com/centos/
curl -O http://mirrors.aliyun.com/centos/8-stream/BaseOS/x86_64/os/Packages/centos-stream-release-8.6-1.el8.noarch.rpm
curl -O http://mirrors.aliyun.com/centos/8-stream/BaseOS/x86_64/os/Packages/centos-gpg-keys-8-6.el8.noarch.rpm
curl -O http://mirrors.aliyun.com/centos/8-stream/BaseOS/x86_64/os/Packages/centos-stream-repos-8-6.el8.noarch.rpm
dnf -y upgrade centos-gpg-keys-8-6.el8.noarch.rpm centos-stream-repos-8-6.el8.noarch.rpm centos-stream-release-8.6-1.el8.noarch.rpm
-升级EPEL存储库
dnf -y upgrade https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm
yum -y remove kmod-kvdo
centos8阿里云
# file: /etc/yum.repos.d/CentOS-AppStream.repo
[AppStream]
name=CentOS-$releasever - AppStream
baseurl=http://mirrors.aliyun.com/centos/$releasever/AppStream/$basearch/os/
gpgcheck=1
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
# file: /etc/yum.repos.d/CentOS-Base.repo
[BaseOS]
name=CentOS-$releasever - Base
baseurl=http://mirrors.aliyun.com/centos/$releasever/BaseOS/$basearch/os/
gpgcheck=1
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
# file: /etc/yum.repos.d/CentOS-Epel.repo
[epel]
name=CentOS-$releasever - Epel
baseurl=http://mirrors.aliyun.com/epel/8/Everything/$basearch
enabled=1
gpgcheck=0
-重建dnf缓存
dnf makecache
-成功升级EPEL存储库后,请删除所有临时文件
dnf clean all
-删除用于CentOS 7的旧内核内核
rpm -e --nodeps `rpm -qa|grep -i kernel`
rpm -e `rpm -q kernel-devel`
rpm -e `rpm -q kernel`
-删除有冲突的软件包
rpm -e --nodeps sysvinit-tools
-更新CentOS 8系统
dnf -y --releasever=8 --allowerasing --setopt=deltarpm=false distro-sync
-报错, 卸载from后面包
rpm -e --nodeps kexec-tools-2.0.15-51.el7_9.3.x86_64
rpm -e --nodeps systemd-219-78.el7_9.3.x86_64
..........................................
-重复一次
dnf -y --releasever=8 --allowerasing --setopt=deltarpm=false distro-sync
yes | rpmconf -a # 一直输入Y和回车即可
-CentOS 8安装新的内核
dnf -y install kernel-core kernel-modules
-安装CentOS 8最小软件包。yum安装失败,不用管它
dnf -y groupupdate "Core" "Minimal Install"
rpm -qa |grep el7 | xargs dnf -y remove
systemctl enable NetworkManager
systemctl disable network
dnf -y remove tuned sssd-common
-检查版本
cat /etc/redhat-release
#centos8异常
---repo ‘appstream’ 下载元数据失败
sed -e 's|^mirrorlist=|#mirrorlist=|g' -e 's|^# baseurl=https://repo.almalinux.org|baseurl=https://mirrors.aliyun.com|g' -i.bak /etc/yum.repos.d/almalinux*.repo
centos8升级AlmaLinux
dnf update
dnf install epel-release
curl -O https://raw.githubusercontent.com/AlmaLinux/almalinux-deploy/master/almalinux-deploy.sh
curl -O http://up.htmltoo.com/soft/src/system/almalinux-deploy.sh
chmod -R 777 almalinux-deploy.sh
bash ./almalinux-deploy.sh
reboot
cat /etc/redhat-release
#替换国内源
sed -e 's|^mirrorlist=|#mirrorlist=|g' \
-e 's|^# baseurl=https://repo.almalinux.org|baseurl=https://mirrors.aliyun.com|g' \
-i.bak \
/etc/yum.repos.d/almalinux*.repo
#1.AlmaLinux 8 ->9
curl https://repo.almalinux.org/elevate/testing/elevate-testing.repo -o /etc/yum.repos.d/elevate-testing.repo
rpm --import https://repo.almalinux.org/elevate/RPM-GPG-KEY-ELevate
-安装Leapp工具和AlmaLinux升级包
yum install -y leapp-upgrade leapp-data-almalinux
-执行升级预检查
leapp preupgrade
-生成检查到的问题列表
tail -f -n 50 /var/log/leapp/answerfile
-设置/回答预检查过程中检查出的问题
-假设 /var/log/leapp/answerfile检查问题有 remove_pam_pkcs11_module_check
-设置该问题的答案是True 表示同意删除 pam_pkcs11 模块 (pam_pkcs11模块已废弃)
leapp answer --section remove_pam_pkcs11_module_check.confirm=True
-假设 /var/log/leapp/answerfile检查问题有 check_vdo.no_vdo_devices
-设置该问题的答案是True 表示当前系统中没有vdo文件系统
leapp answer --section check_vdo.no_vdo_devices=True
-执行升级
leapp upgrade
reboot
#2.AlmaLinux 8 ->9
dnf -y install epel-release
dnf -y update
dnf -y install rpmconf yum-utils
-如果出现一些提示,请输入Y和回车继续,如果没提示继续第四步操作
rpmconf -a
rpm -e --nodeps `rpm -qa|grep almalinux`
rpm -ivh --nodeps --force http://mirrors.aliyun.com/almalinux/9.1/BaseOS/x86_64/os/Packages/almalinux-gpg-keys-9.1-1.9.el9.x86_64.rpm
rpm -ivh --nodeps --force http://mirrors.aliyun.com/almalinux/9.1/BaseOS/x86_64/os/Packages/almalinux-release-9.1-1.9.el9.x86_64.rpm
rpm -ivh --nodeps --force http://mirrors.aliyun.com/almalinux/9.1/BaseOS/x86_64/os/Packages/almalinux-repos-9.1-1.9.el9.x86_64.rpm
dnf clean all
-升级AlmaLinux-9
dnf -y --releasever=9 --allowerasing --setopt=deltarpm=false distro-sync
-重建rpm数据库
rpm --rebuilddb
-卸载AlmaLinux-8的内核
rpm -e --nodeps `rpm -qa|grep -i kernel`
-安装内核(防止有些时候没安装内核开机失败,开机失败的可以用AlmaLinux-9 ISO镜像救援模式安装内核)
dnf -y install kernel kernel-core shim
-安装基础环境
dnf -y groupinstall "Minimal Install"
-安装rpmconf和yum-utils
dnf -y install rpmconf yum-utils
-执行rpmconf,会出现如下界面,一直输入Y和回车即可
rpmconf -a
-执行下面两条命令,防止迁移完成后找不到引导,重启开不了机
export grubcfg=`find /boot/ -name almalinux`
grub2-mkconfig -o $grubcfg/grub.cfg
-禁用无效module,处理:冲突的请求,没有东西提供 module(platform:el8)(模块 python36:3.6:8050020211009220235:982725ab.x86_64 需要它)。
dnf module disable -y container-tools perl perl-DBD-MySQL perl-DBI perl-IO-Socket-SSL perl-libwww-perl python27 python36 python38 python39 satellite-5-client virt
-Signature not supported. Hash algorithm SHA1 not available.
update-crypto-policies --set DEFAULT:SHA1
reboot
sed -i 's/.*#Port 22/Port 55555/' /etc/ssh/sshd_config
sed -i 's/.#PermitRootLogin yes/PermitRootLogin yes/' /etc/ssh/sshd_config
systemctl restart sshd
CentOS8 升级到 Rocky Linux
-升级当前系统
dnf upgrade -y
dnf install dnf -y; dnf update -y;
-重启当前系统:
reboot
-下载脚本:
curl -O https://raw.githubusercontent.com/rocky-linux/rocky-tools/main/migrate2rocky/migrate2rocky.sh
-给脚本授权
chmod +x migrate2rocky.sh
-运行脚本
bash migrate2rocky.sh -r
-同步软件包
dnf distro-sync -y
-重启系统
reboot
-查看系统版本:
cat /etc/redhat-release