CentOS 7 远程升级到 CentOS 8

CentOS 8 已经正式发布了,主要新特性如下:

  • 默认内核版本 4.18
  • 使用 dnf 作为默认包管理器(yum 为指向 dnf 的软链接)
  • BaseOS/AppStream 存储库
  • Python 的默认版本为 3.6
  • nftables 取代 iptables
  • GCC 8.2, glibc 2.28
  • OpenJDK 11, Node.js
  • MySQL 8.0, Mariadb 10.3, PostgreSQL 10, Redis 5

安装 CentOS 8 可以通过下载官方镜像,制作启动 U 盘来完成。本文不使用启动 U 盘,而是在 CentOS 7 系统运行的情况下,远程操作,热升级到 CentOS 8。

注意:热升级不能保障数据安全,因此不建议在生产环境中使用。本文作者用这种方法是因为人在家里无法使用 U 盘安装,但是又需要给一台尚未投入生产的 CentOS 7 服务器升级系统。

1. 安装 yum-utils

# 安装 epel
sudo yum install epel-release -y

sudo yum install yum-utils rpmconf -y
sudo rpmconf -a

sudo package-cleanup --leaves
sudo package-cleanup --orphans

2. 安装 dnf

sudo yum install dnf -y

sudo dnf -y remove yum yum-metadata-parser
sudo rm -rf /etc/yum /etc/yum.repos.d

3. 升级软件源

#sudo dnf upgrade -y

curl -O 'http://mirrors.ustc.edu.cn/centos/8/BaseOS/x86_64/os/Packages/centos-gpg-keys-8.1-1.1911.0.8.el8.noarch.rpm'
curl -O 'http://mirrors.ustc.edu.cn/centos/8/BaseOS/x86_64/os/Packages/centos-repos-8.1-1.1911.0.8.el8.x86_64.rpm'
curl -O 'http://mirrors.ustc.edu.cn/centos/8/BaseOS/x86_64/os/Packages/centos-release-8.1-1.1911.0.8.el8.x86_64.rpm'
sudo dnf install -y centos-gpg-keys-8.1-1.1911.0.8.el8.noarch.rpm centos-repos-8.1-1.1911.0.8.el8.x86_64.rpm centos-release-8.1-1.1911.0.8.el8.x86_64.rpm

sudo dnf -y upgrade https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm

4. 升级内核和软件包

sudo dnf clean all

sudo rpm -e `rpm -q kernel` # 移除旧内核
sudo rpm -e --nodeps sysvinit-tools
sudo dnf -y --releasever=8 --allowerasing --setopt=deltarpm=false distro-sync

# 安装新内核
sudo dnf -y install kernel-core

# 升级基本软件包
sudo dnf -y groupupdate "Core" "Minimal Install"

5. 更新 grub 菜单

sudo grub2-mkconfig -o /boot/grub2/grub.cfg

Problem

移除旧内核的时候出现以下错误,表明有软件包依赖该内核,必须先移除这个软件包才能继续操作。

这个问题不一定会出现,因为本文使用的 CentOS 7 镜像是 Vagrant 上的 centos/7 (virtualbox, 1905.1) 镜像,其中包含某些特定软件包不会在通用系统中存在。

sudo rpm -e `rpm -q kernel`
错误:依赖检测失败:
    kernel >= 3.10.0-384.el7 被 (已安裝) hypervvssd-0-0.34.20180415git.el7.x86_64 需要
    kernel >= 3.10.0-384.el7 被 (已安裝) hypervkvpd-0-0.34.20180415git.el7.x86_64 需要
    kernel >= 3.10.0-384.el7 被 (已安裝) hypervfcopyd-0-0.34.20180415git.el7.x86_64 需要
    kernel >= 3.10.0-384.el7 被 (已安裝) hypervvssd-0-0.34.20180415git.el7.x86_64 需要
    kernel >= 3.10.0-384.el7 被 (已安裝) hypervkvpd-0-0.34.20180415git.el7.x86_64 需要
    kernel >= 3.10.0-384.el7 被 (已安裝) hypervfcopyd-0-0.34.20180415git.el7.x86_64 需要

用以下命令移除这些软件包。

sudo dnf -y remove hypervvssd hypervkvpd
sudo rpm -e hypervfcopyd

移除之后重新执行移除旧内核的操作。

Reference

  • https://www.tecmint.com/upgrade-centos-7-to-centos-8/

你可能感兴趣的:(CentOS 7 远程升级到 CentOS 8)