从CentOS 8.x迁移到CentOS Stream 8

../

我在将VPS服务器从CentOS 8.x迁移到CentOS Stream 8进行了尝试。基本步骤如下:

$ dnf install centos-release-stream
$ dnf swap centos-linux-repos 
$ dnf swap centos-stream-repos
$ dnf distro-sync

在迁移前的CentOS版本是8.5。

$ cat /etc/redhat-release 
CentOS Linux release 8.5.2111

$ dnf install centos-release-stream
$ dnf swap centos-linux-repos
$ dnf swap centos-stream-repos
$ dnf distro-sync

当我运行dnf distro-sync时遇到了大量错误。当出现”无法安装最佳更新候选包”错误时,请按照指示,在命令行中添加选项以替换冲突的包,并重新运行。

$ dnf distro-sync --allowerasing --skip-broken --nobest

大约进行了900次升级。

$ cat /etc/centos-release
CentOS Stream release 8

$ dnf update

我成功地迁移到了CentOS Stream 8。但是,当我进行更新或没有选择选项的distro-sync时,出现了许多错误。

对于epel.repo等的适应

由于CentOS8已经到达EOL并结束支持,一些旧的存储库不能再使用yum或dnf下载。epel是由Fedora项目运营的存储库。请将版本为“7”的部分更改为“$releasever”或“8”。另外,如果出现类似“在/etc/yum.repos.d/epel.repo中的failovermethod=priority无效配置值”的警告,请删除或注释掉failovermethod=priority行。

$ vi /etc/yum.repos.d/epel.repo
[epel]
name=Extra Packages for Enterprise Linux $releasever - $basearch
# It is much more secure to use the metalink, but if you wish to use a local mirror
# place it's address here.
metalink=https://mirrors.fedoraproject.org/metalink?repo=epel-$releasever&arch=$basearch&infra=$infra&content=$contentdir
enabled=1
gpgcheck=1
countme=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-8

[epel-debuginfo]
name=Extra Packages for Enterprise Linux $releasever - $basearch - Debug
# It is much more secure to use the metalink, but if you wish to use a local mirror
# place it's address here.
metalink=https://mirrors.fedoraproject.org/metalink?repo=epel-debug-$releasever&arch=$basearch&infra=$infra&content=$contentdir
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-8
gpgcheck=1

[epel-source]
name=Extra Packages for Enterprise Linux $releasever - $basearch - Source
# It is much more secure to use the metalink, but if you wish to use a local mirror
# place it's address here.
metalink=https://mirrors.fedoraproject.org/metalink?repo=epel-source-$releasever&arch=$basearch&infra=$infra&content=$contentdir
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-8
gpgcheck=1

由于出现了「包 epel-release-7-14.noarch 已经安装。无法安装 epel-release-8-15.el8.noarch」的错误,所以我先移除了 epel-release,然后重新安装。

$ dnf remove epel-release
$ dnf install epel-release

以下是repolist的结果。进行了clean all操作并进行了更新。

$ dnf repolist
repo id             repo の名前
appstream           CentOS Stream 8 - AppStream
baseos              CentOS Stream 8 - BaseOS
elrepo              ELRepo.org Community Enterprise Linux Repository - el8
epel                Extra Packages for Enterprise Linux 8 - x86_64
epel-modular        Extra Packages for Enterprise Linux Modular 8 - x86_64
extras              CentOS Stream 8 - Extras
extras-common       CentOS Stream 8 - Extras common packages

$ dnf clean all
93 ファイルが削除されました。

$ dnf update
CentOS Stream 8 - AppStream                     4.8 MB/s |  23 MB     00:04    
CentOS Stream 8 - BaseOS                        4.9 MB/s |  23 MB     00:04    
CentOS Stream 8 - Extras                         31 kB/s |  18 kB     00:00    
CentOS Stream 8 - Extras common packages         12 kB/s | 4.3 kB     00:00    
ELRepo.org Community Enterprise Linux Repositor 113 kB/s | 230 kB     00:02    
Extra Packages for Enterprise Linux 8 - x86_64  5.0 MB/s |  11 MB     00:02    
Extra Packages for Enterprise Linux Modular 8 - 4.1 MB/s | 1.0 MB     00:00    
Extra Packages for Enterprise Linux 8 - Next -  631 kB/s | 559 kB     00:00   

直到没有错误出现,我重复下面的动作数次。

$ dnf distro-sync
$ dnf update

MySQL8.0的重新设置

实际上,由于MySQL 8.0也存在竞争性问题,所以我先删除了相关的repo,然后进行了remove和install操作。以前,在CentOS 8.x时,我自己导入了rpm包,但由于CentOS Stream 8 – AppStream中已经默认包含了MySQL 8.0,所以可能是这个原因。

$ dnf repolist
・・・
mysql-connectors-community    MySQL Connectors Community
mysql-tools-community         MySQL Tools Community

$ cd /etc/yum.repos.d/
$ rm -f mysql-*

$ dnf remove mysql
$ dnf module list mysql
CentOS Stream 8 - AppStream
Name          Stream             Profiles                   Summary             
mysql         8.0 [d][e]         client, server [d]         MySQL Module  

$ dnf moduleinstall mysql:8.0
mysql-server   x86_64  8.0.26-1.module_el8.4.0+915+de215114   appstream   25 M
mecab          x86_64  0.996-1.module_el8.4.0+589+11e12751.9  appstream  393 k
mysql          x86_64  8.0.26-1.module_el8.4.0+915+de215114   appstream   12 M
mysql-errmsg   x86_64  8.0.26-1.module_el8.4.0+915+de215114   appstream  598 k
protobuf-lite  x86_64  3.5.0-15.el8                           appstream  149 k
 
$ mysql --version
mysql  Ver 8.0.26 for Linux on x86_64 (Source distribution)

修改在/etc/my.cnf.d/目录下的配置文件,并重新运行服务。由于数据库内的数据仍然存在,只需要配置服务运行所需的设置,就可以使其恢复正常。

$ vi /etc/my.cnf.d/mysql-server.cnf
[mysqld]
character-set-server=utf8
lower_case_table_names=1  # 大文字小文字を区別しない場合

$ vi /etc/my.cnf.d/client.cnf
[client]
default-character-set=utf8

$ systemctl restart mysqld
$ systemctl status mysqld
$ mysql -uroot -p 
・・・
../
广告
将在 10 秒后关闭
bannerAds