前言
查看centos的版本 ,我这台服务器是虚拟机,下面都是模拟实验
升级前一定要把服务器上配置文件,数据等进行备份
[root@localhost ~]#cat /etc/redhat-release
CentOS Linux release 7.9.2009 (Core)
[root@localhost ~]#uname -a
Linux jenkins_server 3.10.0-1160.83.1.el7.x86_64 #1 SMP Wed Jan 25 16:41:43 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux
[root@localhost ~]# docker run --name my-memcache -m 64 -d docker.io/memcached:1.6.20
/usr/bin/docker-current: Error response from daemon: Minimum memory limit allowed is 4MB.
See '/usr/bin/docker-current run --help'.
[root@localhost ~]# docker run --name my-memcache -m 64mb -d docker.io/memcached:1.6.20
1ad3ad059e1a2f3d179c64f88bd0ec494c46adf78caa9c0f1603e0210b639869
[root@localhost ~]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
1ad3ad059e1a docker.io/memcached:1.6.20 "docker-entrypoint..." 3 seconds ago Up 2 seconds 11211/tcp my-memcache
[root@localhost ~]# netstat -lnpt
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 1563/mysqld
tcp 0 0 127.0.0.1:6379 0.0.0.0:* LISTEN 908/redis-server 12
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 1160/nginx: master
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 903/sshd
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 1567/master
tcp6 0 0 :::80 :::* LISTEN 1160/nginx: master
tcp6 0 0 :::22 :::* LISTEN 903/sshd
tcp6 0 0 ::1:25 :::* LISTEN 1567/master
现在可以将 CentOS 7 升级到 Rocky Linux 8。由于 CentOS 8 已经死了,所以将 CentOS 7 迁移到 CentOS 8 是没有意义的。
现在,您不仅可以将 CentOS 7 升级到 Rocky Linux 8,还可以将 CentOS 7 升级到其他 EL 8 衍生产品,如 AlmaLinux、CentOS Stream、Oracle 和 Rocky Linux。
感谢ELevate(https://wiki.almalinux.org/elevate/),一项计划和工具,可以在RHEL衍生品的主要版本之间进行迁移。
在这里,我们将看到如何将 CentOS 7 升级到 Rocky Linux 8。
一 进行系统备份
在继续之前,我强烈建议您进行系统备份或快照以进行恢复,以防升级后出现问题。除此之外,您还可以先在虚拟机或测试计算机上尝试此升级过程,然后再在实时服务器上执行此升级过程。
如果你的centos7系统未到达最新版本,请进行升级
yum update -y
[root@localhost ~]#cat /etc/redhat-release
CentOS Linux release 7.9.2009 (Core)
[root@localhost ~]#uname -a
Linux localhost 3.10.0-1160.el7.x86_64 #1 SMP Mon Oct 19 16:18:59 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
1 升级内核,使用最新内核
[root@localhost ~]# cat /etc/redhat-release
CentOS Linux release 7.9.2009 (Core)
[root@localhost ~]# uname -a
Linux localhost.localdomain 3.10.0-1160.90.1.el7.x86_64 #1 SMP Thu May 4 15:21:22 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux
二 安装提升
安装提升发布包以配置项目存储库并安装 GPG 密钥。
yum install -y http://repo.almalinux.org/elevate/elevate-release-latest-el7.noarch.rpm
三 安装 Rocky Linux 的 leapp 软件包和迁移数据。
yum install -y leapp-upgrade leapp-data-rocky
四 执行预检查
使用以下命令启动升级前检查。此检查将确定操作系统升级的可能性,并报告升级前需要修复的潜在问题。
leapp preupgrade
1 报错
此外,您还可以在文件中获取有关报告的升级阻止程序(风险因素:高(限制)和建议的解决方案)的详细信息。除了阻止程序之外,该文件还将包含从信息到高的其他风险,您可以查看并进一步进行。/var/log/leapp/leapp-report.txt
[root@localhost ~]# cat /var/log/leapp/leapp-report.txt |grep command
[command] yum -y remove kernel-devel-3.10.0-1160.83.1.el7
Remediation: [hint] Please register user choices with leapp answer cli command or by manually editing the answerfile.
[command] leapp answer --section remove_pam_pkcs11_module_check.confirm=True
Summary: In RHEL 8, there is no 'python' command. Python 3 (backward incompatible) is the primary Python version and Python 2 is available with limited support and limited set of packages. Read more here: https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/8/html-single/configuring_basic_system_settings/#using-python3
The postqueue command no longer forces all message arrival times to be reported in UTC. To get the old behavior, set TZ=UTC in main.cf:import_environment.
2 处理,根据文件中提升执行命令
[root@localhost ~]# yum -y remove kernel-devel-3.10.0-1160.90.1.el7 && leapp answer --section remove_pam_pkcs11_module_check.confirm=True
3再次检测,没有再报错,担任也可以再次查看/var/log/leapp/leapp-report.txt
[root@localhost ~]#leapp preupgrade
五 升级到 Rocky Linux 8
1使用以下命令开始升级。此升级需要一些时间才能完成。下载了一堆包,更新了一堆包
leapp upgrade
2 升级报错
STDERR:
No matches found for the following disable plugin patterns: subscription-manager
Repository extras is listed more than once in the configuration
Warning: Package marked by Leapp to upgrade not found in repositories metadata: gpg-pubkey
RPM: warning: Generating 6 missing index(es), please wait...
Error: Transaction test error:
file /usr/lib64/.libcrypto.so.1.1.1k.hmac from install of openssl-libs-1:1.1.1k-9.el8_7.x86_64 conflicts with file from package openssl11-libs-1:1.1.1k-5.el7.x86_64
file /usr/lib64/.libssl.so.1.1.1k.hmac from install of openssl-libs-1:1.1.1k-9.el8_7.x86_64 conflicts with file from package openssl11-libs-1:1.1.1k-5.el7.x86_64
file /usr/lib64/engines-1.1/afalg.so from install of openssl-libs-1:1.1.1k-9.el8_7.x86_64 conflicts with file from package openssl11-libs-1:1.1.1k-5.el7.x86_64
file /usr/lib64/engines-1.1/capi.so from install of openssl-libs-1:1.1.1k-9.el8_7.x86_64 conflicts with file from package openssl11-libs-1:1.1.1k-5.el7.x86_64
file /usr/lib64/engines-1.1/padlock.so from install of openssl-libs-1:1.1.1k-9.el8_7.x86_64 conflicts with file from package openssl11-libs-1:1.1.1k-5.el7.x86_64
file /usr/lib64/libcrypto.so.1.1.1k from install of openssl-libs-1:1.1.1k-9.el8_7.x86_64 conflicts with file from package openssl11-libs-1:1.1.1k-5.el7.x86_64
file /usr/lib64/libssl.so.1.1.1k from install of openssl-libs-1:1.1.1k-9.el8_7.x86_64 conflicts with file from package openssl11-libs-1:1.1.1k-5.el7.x86_64
============================================================
END OF ERRORS
============================================================
Debug output written to /var/log/leapp/leapp-upgrade.log
============================================================
REPORT
============================================================
A report has been generated at /var/log/leapp/leapp-report.json
A report has been generated at /var/log/leapp/leapp-report.txt
============================================================
END OF REPORT
============================================================
Answerfile has been generated at /var/log/leapp/answerfile
2023-06-01 14:19:34.232 ERROR PID: 26818 leapp: Upgrade workflow failed, check log for details
[root@localhost ~]#
2.1 报错处理:移除openssl11-libs
[root@localhost ~]# yum remove openssl11-libs-1:1.1.1k-5.el7.x86_64
请先备份nginx配置文件在移除
3 再次升级
leapp upgrade
终于通过了
3.1 重启,选择升级
[root@localhost ~]# shutdown -r now
选择第一个
3.2 更新并安装一些包,这个过程相当缓慢
3.4 熟悉的页面
4 系统升级成功
但是我的docker被卸载了,镜像也找不到了,如果安装了docker 一定要备份啊 ,当然其他服务也是如此
[root@localhost ~]# cat /etc/redhat-release
Rocky Linux release 8.8 (Green Obsidian)
[root@localhost ~]# uname -a
Linux localhost.localdomain 4.18.0-477.13.1.el8_8.x86_64 #1 SMP Tue May 30 22:15:39 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux
六 升级后操作
1 先重新配置下yum吧
[root@localhost ~]# cd /etc/yum.repos.d/
[root@localhost yum.repos.d]# ll
总用量 76
-rw-r--r--. 1 root root 2523 8月 4 2022 CentOS-Base.repo.rpmsave
-rw-r--r--. 1 root root 379 3月 17 19:26 ELevate.repo
-rw-r--r--. 1 root root 1698 11月 5 2022 epel-modular.repo
-rw-r--r--. 1 root root 1332 11月 5 2022 epel.repo
-rw-r--r--. 1 root root 1797 11月 5 2022 epel-testing-modular.repo
-rw-r--r--. 1 root root 1431 11月 5 2022 epel-testing.repo
-rw-r--r--. 1 root root 710 4月 26 02:50 Rocky-AppStream.repo
-rw-r--r--. 1 root root 695 4月 26 02:50 Rocky-BaseOS.repo
-rw-r--r--. 1 root root 1753 4月 26 02:50 Rocky-Debuginfo.repo
-rw-r--r--. 1 root root 360 4月 26 02:50 Rocky-Devel.repo
-rw-r--r--. 1 root root 695 4月 26 02:50 Rocky-Extras.repo
-rw-r--r--. 1 root root 731 4月 26 02:50 Rocky-HighAvailability.repo
-rw-r--r--. 1 root root 680 4月 26 02:50 Rocky-Media.repo
-rw-r--r--. 1 root root 680 4月 26 02:50 Rocky-NFV.repo
-rw-r--r--. 1 root root 690 4月 26 02:50 Rocky-Plus.repo
-rw-r--r--. 1 root root 715 4月 26 02:50 Rocky-PowerTools.repo
-rw-r--r--. 1 root root 746 4月 26 02:50 Rocky-ResilientStorage.repo
-rw-r--r--. 1 root root 681 4月 26 02:50 Rocky-RT.repo
-rw-r--r--. 1 root root 2335 4月 26 02:50 Rocky-Sources.repo
[root@localhost yum.repos.d]# rm -rf CentOS-Base.repo.rpmsave
[root@localhost yum.repos.d]# mkdir backup
[root@localhost yum.repos.d]# cp ./Rocky-*.repo ./backup/
[root@localhost yum.repos.d]# mv ELevate.repo epel-modular.repo epel.repo epel-testing-modular.repo epel-testing.repo ./backup/
[root@localhost yum.repos.d]# sed -e 's|^mirrorlist=|#mirrorlist=|g' \
-e 's|^#baseurl=http://dl.rockylinux.org/$contentdir|baseurl=https://mirrors.aliyun.com/rockylinux|g' \
-i.bak \
/etc/yum.repos.d/Rocky-*.repo
[root@localhost ~]# yum makecache
或者 dnf makecache
[root@localhost ~]# yum makecache
Rocky Linux 8 - AppStream 276 kB/s | 9.2 MB 00:34
Rocky Linux 8 - BaseOS 225 kB/s | 3.8 MB 00:17
Rocky Linux 8 - Extras 1.2 kB/s | 13 kB 00:10
元数据缓存已建立。
2 新的系统中无法找到docker服务,无法使用docker命令,但是docker的存储数据目录还在
但是我的docker被卸载了,镜像也找不到了,如果安装了docker 一定要备份啊 ,当然其他服务也是如此
[root@localhost ~]# netstat -lnpt
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1039/sshd
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 1650/master
tcp 0 0 127.0.0.1:6379 0.0.0.0:* LISTEN 1045/redis-server 1
tcp6 0 0 :::22 :::* LISTEN 1039/sshd
tcp6 0 0 ::1:25 :::* LISTEN 1650/master
tcp6 0 0 :::3306 :::* LISTEN 1325/mysqld
[root@localhost ~]# which docker
/usr/bin/which: no docker in (/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin)
[root@localhost ~]# du -sh /var/lib/docker
96M /var/lib/docker
[root@localhost ~]# ll /var/lib/docker/
总用量 4
drwx------. 3 root root 78 6月 1 14:02 containers
drwx------. 3 root root 22 6月 1 13:56 image
drwxr-x---. 3 root root 19 6月 1 13:56 network
drwx------. 11 root root 4096 6月 1 13:47 overlay2
drwx------. 4 root root 32 6月 1 13:56 plugins
drwx------. 2 root root 6 6月 1 13:56 swarm
drwx------. 2 root root 6 6月 1 14:00 tmp
drwx------. 2 root root 6 6月 1 13:56 trust
drwx------. 2 root root 25 6月 1 15:37 volumes
2.1 rockylinux上的并没有docker的安装包,叫podman
官网 https://podman.io/
[root@localhost ~]# yum install docker
上次元数据过期检查:0:02:00 前,执行于 2023年06月01日 星期四 15时36分48秒。
依赖关系解决。
==============================================================================================================================================================================================
软件包 架构 版本 仓库 大小
==============================================================================================================================================================================================
安装:
podman-docker noarch 3:4.4.1-12.module+el8.8.0+1265+fa25dd7a appstream 74 k
安装依赖关系:
conmon x86_64 3:2.1.6-1.module+el8.8.0+1265+fa25dd7a appstream 56 k
containernetworking-plugins x86_64 1:1.2.0-1.module+el8.8.0+1265+fa25dd7a appstream 20 M
podman x86_64 3:4.4.1-12.module+el8.8.0+1265+fa25dd7a appstream 15 M
podman-catatonit x86_64 3:4.4.1-12.module+el8.8.0+1265+fa25dd7a appstream 361 k
shadow-utils-subid x86_64 2:4.6-17.el8 baseos 112 k
事务概要
==============================================================================================================================================================================================
安装 6 软件包
总下载:35 M
安装大小:107 M
确定吗?[y/N]: y
下载软件包:
(1/6): conmon-2.1.6-1.module+el8.8.0+1265+fa25dd7a.x86_64.rpm 10 kB/s | 56 kB 00:05
(2/6): podman-catatonit-4.4.1-12.module+el8.8.0+1265+fa25dd7a.x86_64.rpm 242 kB/s | 361 kB 00:01
(3/6): podman-docker-4.4.1-12.module+el8.8.0+1265+fa25dd7a.noarch.rpm 196 kB/s | 74 kB 00:00
(4/6): shadow-utils-subid-4.6-17.el8.x86_64.rpm 199 kB/s | 112 kB 00:00
(5/6): podman-4.4.1-12.module+el8.8.0+1265+fa25dd7a.x86_64.rpm 225 kB/s | 15 MB 01:07
(6/6): containernetworking-plugins-1.2.0-1.module+el8.8.0+1265+fa25dd7a.x86_64.rpm 228 kB/s | 20 MB 01:29
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
总计 405 kB/s | 35 MB 01:29
Rocky Linux 8 - AppStream 172 kB/s | 1.6 kB 00:00
导入 GPG 公钥 0x6D745A60:
Userid: "Release Engineering <infrastructure@rockylinux.org>"
指纹: 7051 C470 A929 F454 CEBE 37B7 15AF 5DAC 6D74 5A60
来自: /etc/pki/rpm-gpg/RPM-GPG-KEY-rockyofficial
确定吗?[y/N]: y
导入公钥成功
运行事务检查
事务检查成功。
运行事务测试
事务测试成功。
运行事务
准备中 : 1/1
安装 : shadow-utils-subid-2:4.6-17.el8.x86_64 1/6
安装 : containernetworking-plugins-1:1.2.0-1.module+el8.8.0+1265+fa25dd7a.x86_64 2/6
安装 : conmon-3:2.1.6-1.module+el8.8.0+1265+fa25dd7a.x86_64 3/6
安装 : podman-catatonit-3:4.4.1-12.module+el8.8.0+1265+fa25dd7a.x86_64 4/6
安装 : podman-3:4.4.1-12.module+el8.8.0+1265+fa25dd7a.x86_64 5/6
安装 : podman-docker-3:4.4.1-12.module+el8.8.0+1265+fa25dd7a.noarch 6/6
运行脚本: podman-docker-3:4.4.1-12.module+el8.8.0+1265+fa25dd7a.noarch 6/6
验证 : conmon-3:2.1.6-1.module+el8.8.0+1265+fa25dd7a.x86_64 1/6
验证 : containernetworking-plugins-1:1.2.0-1.module+el8.8.0+1265+fa25dd7a.x86_64 2/6
验证 : podman-3:4.4.1-12.module+el8.8.0+1265+fa25dd7a.x86_64 3/6
验证 : podman-catatonit-3:4.4.1-12.module+el8.8.0+1265+fa25dd7a.x86_64 4/6
验证 : podman-docker-3:4.4.1-12.module+el8.8.0+1265+fa25dd7a.noarch 5/6
验证 : shadow-utils-subid-2:4.6-17.el8.x86_64 6/6
已更新安装的产品。
已安装:
conmon-3:2.1.6-1.module+el8.8.0+1265+fa25dd7a.x86_64 containernetworking-plugins-1:1.2.0-1.module+el8.8.0+1265+fa25dd7a.x86_64
podman-3:4.4.1-12.module+el8.8.0+1265+fa25dd7a.x86_64 podman-catatonit-3:4.4.1-12.module+el8.8.0+1265+fa25dd7a.x86_64
podman-docker-3:4.4.1-12.module+el8.8.0+1265+fa25dd7a.noarch shadow-utils-subid-2:4.6-17.el8.x86_64
完毕!
2.2 podman简单操作
[root@localhost ~]# ll /usr/lib/systemd/system/podman*
-rw-r--r--. 1 root root 284 5月 17 05:25 /usr/lib/systemd/system/podman-auto-update.service
-rw-r--r--. 1 root root 143 5月 17 05:25 /usr/lib/systemd/system/podman-auto-update.timer
-rw-r--r--. 1 root root 667 5月 17 05:25 /usr/lib/systemd/system/podman-clean-transient.service
-rw-r--r--. 1 root root 443 5月 17 05:25 /usr/lib/systemd/system/podman-kube@.service
-rw-r--r--. 1 root root 510 5月 17 05:25 /usr/lib/systemd/system/podman-restart.service
-rw-r--r--. 1 root root 324 5月 17 05:25 /usr/lib/systemd/system/podman.service
-rw-r--r--. 1 root root 176 5月 17 05:25 /usr/lib/systemd/system/podman.socket
[root@localhost ~]#
[root@localhost ~]# systemctl startpodman
[root@localhost ~]# systemctl enable podman
[root@localhost ~]# podman -v
podman version 4.4.1
2.3 podman的目录
podman本地存储地址 /var/lib/containers/storage
[root@localhost ~]# find / -name podman
/run/podman
/var/lib/cni/networks/podman
/usr/bin/podman
/usr/share/doc/podman
/usr/share/licenses/podman
/usr/share/bash-completion/completions/podman
/usr/libexec/podman
[root@localhost ~]# find / -name containers
/run/containers
/etc/containers
/var/lib/containers
/var/lib/docker/containers
/usr/share/containers
2.4 拉取镜像memcache,podman从dockerhub拉去镜像是可以的
[root@localhost ~]# podman pull docker.io/memcached:1.6.20
Trying to pull docker.io/library/memcached:1.6.20...
Getting image source signatures
Copying blob 26b333375d58 done
Copying blob f03b40093957 done
Copying blob 42850af464e5 done
Copying blob 66835158f1e3 done
Copying blob 4027e4df9c70 done
Copying blob e874830b2907 done
Copying config a78754495c done
Writing manifest to image destination
Storing signatures
a78754495cd58c1fd188f1147b890bd9de6c8a3bf9cbea69c917e578a7fa6842
2.5 启动镜像
[root@localhost ~]# podman run --name my-memcache -m 64mb -p 11211:11211 -d docker.io/memcached:1.6.20
[root@localhost ~]# podman ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
3565b7560aca docker.io/library/memcached:1.6.20 memcached 39 seconds ago Up 39 seconds 0.0.0.0:11211->11211/tcp my-memcache
[root@localhost ~]# netstat -lnpt
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1039/sshd
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 1650/master
tcp 0 0 0.0.0.0:11211 0.0.0.0:* LISTEN 50316/conmon
tcp 0 0 127.0.0.1:6379 0.0.0.0:* LISTEN 1045/redis-server 1
tcp6 0 0 :::22 :::* LISTEN 1039/sshd
tcp6 0 0 ::1:25 :::* LISTEN 1650/master
tcp6 0 0 :::3306 :::* LISTEN 1325/mysqld
3 安装nginx
nginx从在centos7.9上的1.20版本降级到了1.14版本
[root@localhost ~]# yum install nginx
[root@localhost ~]# nginx -v
nginx version: nginx/1.14.1
systemctl start nginx
systemctl enable nginx
访问web
本文参考
https://www.itzgeek.com/how-tos/linux/centos-how-tos/how-to-upgrade-centos-7-to-rocky-linux-8.html#:~:text=Upgrade%20CentOS%207%20to%20Rocky%20Linux%208%201,Linux%208%20…%205%20Post%20Migration%20Checkouts%20