centos7.9升级到centos8.5

因为要搭建个系统,那个系统需要centos8的环境,自己又觉得centos7搭建的各种依赖太折腾,决定找个centos7的虚拟机升级到8.

一、查看当前的系统配置

[root@]# cat /etc/centos-release
CentOS Linux release 7.9.2009 (Core)

[root@]# yum update
[root@}# reboot

二、 安装epel-relase、yum-utils和 rpmconf

[root@]# yum install epel-release -y
[root@]# yum install yum-utils -y

三、升级前检查rpmconf

yum install rpmconf -y
1、检查配置:rpmconf -a
执行如下所示,如有选择直接使用缺省设定。

四、 清理软件包

[root@]# package-cleanup --leaves
Loaded plugins: fastestmirror
libsysfs-2.1.0-16.el7.x86_64
如果除了 libsysfs 还有其他的包,请执行 yum update,然后重启下

检查不再提供的软件包:列出当前仓库中不提供升级的软件包信息
[root@]# package-cleanup --orphans
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile

  • base: mirrors.aliyun.com
  • epel: download.nus.edu.sg
  • extras: mirrors.aliyun.com
  • updates: mirrors.aliyun.com

五、安装默认的软件包管理器dnf 并清除yum

1、安装dnf
[root@]# yum install dnf -y

2、清除yum并升级
[root@]# dnf -y remove yum yum-metadata-parser
[root@]# rm -Rf /etc/yum
[root@]# dnf upgrade -y

3 查看版本
[root@]# dnf --version
4.0.9
Traceback (most recent call last):
File “/bin/dnf”, line 58, in
main.user_main(sys.argv[1:], exit_code=True)
File “/usr/lib/python2.7/site-packages/dnf/cli/main.py”, line 179, in user_main
errcode = main(args)
File “/usr/lib/python2.7/site-packages/dnf/cli/main.py”, line 64, in main
return _main(base, args, cli_class, option_parser_class)
File “/usr/lib/python2.7/site-packages/dnf/cli/main.py”, line 95, in _main
cli.configure(list(map(ucd, args)), option_parser())
File “/usr/lib/python2.7/site-packages/dnf/cli/cli.py”, line 868, in configure
self.base.output)
File “/usr/lib/python2.7/site-packages/dnf/cli/cli.py”, line 137, in print_versions
sm_ui_time(pkg.installtime)))
UnicodeDecodeError: ‘ascii’ codec can’t decode byte 0xe5 in position 4: ordinal not in range(128)

#更新dnf管理工具依赖包
[root@]# yum update python*

#为了防止出现别的问题,安装dnf所关联的软件工具
[root@]# yum install dnf-data dnf-plugins-core libdnf-devel libdnf python2-dnf-plugin-migrate dnf-automatic -y

这个报错
是因为python2的默认是字符串是ascii。需要改成utf8

修改编码
修改python编码 ,这个文件默认是没有的,可以创建新文件。
cat > /usr/lib/python2.7/site-packages/sitecustomize.py << END
#encoding=utf8
import sys
reload(sys)
sys.setdefaultencoding(‘utf8’)
END

#检查dnf软件管理工具是否正常(以下状态表示dnf就可以正常使用)
[root@]# dnf --version
4.0.9
Installed: dnf-0:4.0.9.2-2.el7_9.noarch at Tue 07 Jun 2022 01:31:12 PM CST
Built : CentOS BuildSystem http://bugs.centos.org at Wed 07 Apr 2021 03:52:38 PM CST

Installed: rpm-0:4.11.3-48.el7_9.x86_64 at Tue 07 Jun 2022 01:18:49 PM CST
Built : CentOS BuildSystem http://bugs.centos.org at Wed 24 Nov 2021 04:33:39 PM CST

六、系统升级

#CentOS 7升级到CentOS 8
#centos 7系统升级(使用新安装的dnf软件管理)
[root@]# dnf upgrade -y
#dnf安装CentOS 8发行软件包(基本所有仓库Centos 8软件包均已删除)

[root@]# dnf -y upgrade https://mirrors.bfsu.edu.cn/centos/8-stream/BaseOS/x86_64/os/Packages/centos-stream-release-8.5-3.el8.noarch.rpm

阿里云的三个包的查看地址
https://mirrors.aliyun.com/centos/8/BaseOS/x86_64/os/Packages/?spm=a2c6h.25603864.0.0.625d331bJNdrYw
三个系统包
[root@]# dnf install https://mirrors.aliyun.com/centos/8/BaseOS/x86_64/os/Packages/{centos-linux-repos-8-3.el8.noarch.rpm,centos-linux-release-8.5-1.2111.el8.noarch.rpm,centos-gpg-keys-8-3.el8.noarch.rpm}

#升级epel仓库源
[root@]# dnf -y upgrade https://dl.fedoraproject.org/pub/epel/epel-next-release-latest-8.noarch.rpm

[root@]# dnf -y upgrade https://mirrors.bfsu.edu.cn/epel/epel-release-latest-8.noarch.rpm

#清空所有缓存
[root@# dnf clean all

#删除 centos 7内核包
[root@]# rpm -e rpm -q kernel

#出现报错(一般为软件包不兼容或者软件包冲突导致,可根据以下方式卸载即可)
#卸载冲突的软件包
[root@]# rpm -e --nodeps sysvinit-tools

#启动CentOS 8系统升级
[root@]# dnf -y --releasever=8 --allowerasing --setopt=deltarpm=false distro-sync

安装报错了检查相关依赖
在这里插入图片描述
. 如果报 源重复
在这里插入图片描述
1 1. rm -rf /etc/yum.repos.d/*
2. curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-8.repo
2. Python 3依赖错误
1. dnf remove python3
3. 分段故障
1. rm -rf /var/lib/rpm/__db.*
2. rpm --rebuilddb
3. dnf clean all
4. dnf makecach

如果这个报错
[root@]# rpm -Va --nofiles --nodigest
Unsatisfied dependencies for initscripts-9.49.53-1.el7_9.1.x86_64:
sysvinit-tools >= 2.87-5 is needed by (installed) initscripts-9.49.53-1.el7_9.1.x86_64 //initscripts包是el7版本的
Unsatisfied dependencies for iprutils-2.4.17.1-3.el7_7.x86_64:
/sbin/pidof is needed by (installed) iprutils-2.4.17.1-3.el7_7.x86_64 //iprutils包是el7版本的

[root@]# dnf remove -y initscripts iprutils //移除上述两个包
[root@]# dnf install -y initscripts iprutils //重新安装

再安装报错
dnf -y --releasever=8 --allowerasing --setopt=deltarpm=false distro-sync
还是报错
运行事务检查
错误:事务检查与依赖解决错误:
(gcc >= 8 with gcc < 9) 被 annobin-9.72-1.el8_5.2.x86_64 需要
rpmlib(RichDependencies) <= 4.12.0-1 被 annobin-9.72-1.el8_5.2.x86_64 需要
(annobin if gcc) 被 redhat-rpm-config-125-1.el8.noarch 需要
rpmlib(RichDependencies) <= 4.12.0-1 被 redhat-rpm-config-125-1.el8.noarch 需要
要诊断问题,尝试运行:‘rpm -Va --nofiles --nodigest’ 。
RPM 数据库可能出错,请尝试运行’rpm --rebuilddb’进行恢复。
下载的软件包保存在缓存中,直到下次成功执行事务。
您可以通过执行 ‘dnf clean packages’ 删除软件包缓存。

这个依赖占时忽略
[root@]# rpm -Va --nofiles --nodigest
Unsatisfied dependencies for rpmconf-1.1.7-1.el7.1.noarch:
python36-rpmconf is needed by (installed) rpmconf-1.1.7-1.el7.1.noarch

gcc的版本没问题
[root]# gcc --version
gcc (GCC) 8.5.0 20210514 (Red Hat 8.5.0-4)
Copyright © 2018 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

查找依赖依赖的rpm包
[root@]# find /var/cache/dnf/ -name annobin-9.72-1.el8_5.2.x86_64
/var/cache/dnf/AppStream-bf1daca1ea021975/packages/annobin-9.72-1.el8_5.2.x86_64.rpm
[root@ ]# find /var/cache/dnf/ -name redhat-rpm-config-125-1.el8.noarch
/var/cache/dnf/AppStream-bf1daca1ea021975/packages/redhat-rpm-config-125-1.el8.noarch.rpm

安装这两个依赖包
[root@]# rpm -ivh --nodeps --force /var/cache/dnf/AppStream-bf1daca1ea021975/packages/annobin-9.72-1.el8_5.2.x86_64.rpm
Preparing… ################################# [100%]
Updating / installing…
1:annobin-9.72-1.el8_5.2 ################################# [100%]
[root@]# rpm -ivh --nodeps --force /var/cache/dnf/AppStream-bf1daca1ea021975/packages/redhat-rpm-config-125-1.el8.noarch.rpm
Preparing… ################################# [100%]
Updating / installing…
1:redhat-rpm-config-125-1.el8 ################################# [100%]

再次安装,安装成功
dnf -y --releasever=8 --allowerasing --setopt=deltarpm=false distro-sync
在这里插入图片描述

七 、升级内核

升级内核
[root@a]# dnf -y install kernel-core
在这里插入图片描述
安装完成后发现内核没有变
[root@]# uname -r
3.10.0-1160.el7.x86_64

八、重启后网卡失败问题

现在重启系统reboot,重启之后发现ssh连接不上,控制台查看,只有本地io网卡没有网络网卡
[root@]# ifconfig
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10
loop txqueuelen 1000 (Local Loopback)
RX packets 23 bytes 1380 (1.3 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 23 bytes 1380 (1.3 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
查看系统版本和内核,都已经更新了
[root@]# cat /etc/redhat-release
CentOS Linux release 8.5.2111
[root@]# uname -r
4.18.0-348.7.1.el8_5.x86_64

查看网卡状态
[root@]# systemctl status NetworkManager
● NetworkManager.service - Network Manager
Loaded: loaded (/usr/lib/systemd/system/NetworkManager.service; disabled; ve>
Active: inactive (dead)
Docs: man:NetworkManager(8)
在这里插入图片描述

启动网卡
[root@]# systemctl start NetworkManager

[root@]# systemctl status NetworkManager
● NetworkManager.service - Network Manager
Loaded: loaded (/usr/lib/systemd/system/NetworkManager.service; disabled; ve>
Active: active (running) since Fri 2023-08-11 15:01:31 CST; 2s ago
Docs: man:NetworkManager(8)
Main PID: 8031 (NetworkManager)
Tasks: 4 (limit: 49556)
Memory: 7.4M
CGroup: /system.slice/NetworkManager.service
└─8031 /usr/sbin/NetworkManager --no-daemon
在这里插入图片描述

操作的一些命令
#查看DNS服务器配置信息
cat /etc/resolv.conf

#查看网关信息
route -n

#显示网卡信息
ip a

#查看fstab信息
cat /etc/fstab

#eth0网卡为关闭状态 需要开启 运行下面4句才开启成功,自己测试的并未开启eth0
ifup eth0
nmcli connection reload
systemctl restart NetworkManager
nmcli connection reload

网卡的名字和原来的不同了,
原来的是eth0,现在的是ens3
1 重新配置网卡,本来想保留eth0的这中方式,但是看了下没保留成功,最后改成了ens3的网卡名字,配置了网关和路由网络通畅了
在这里插入图片描述

九、重启后ssh的失败问题

密码报错
Opt> 10.xx.xx.xx
开始连接到 root@10.xx.xx.xx
Connect asset 10.xx.xx.xx error: ssh: handshake failed: ssh: unable to authenticate, attempted methods [password none], no supported methods remain

原因是原先CentOS 7上sshd配置 /etc/ssh/sshd_config 和升级到CentOS 8之后的sshd不兼容
解决的方法是使用新软件包配置覆盖,这个我测试了没有成功
cd /etc/ssh
cp sshd_config.rpmnew sshd_config
cp ssh_config.rpmnew ssh_config
现在sshd可以成功启动了,

我的日志中没有查到这个错误也没报,值此做个参考记录,如果有可以尝试一下。
但是用户依然无法通过密码认证登陆,在 systemctl status sshd 中可以看到报错原因是PAM库加载错误:
Jun 06 23:05:36 worker-1.huatai.me sshd[16040]: PAM unable to dlopen(/usr/lib64/security/pam_tally2.so): /usr/lib64/security/pam_tally2.so: can>
Jun 06 23:05:36 worker-1.huatai.me sshd[16040]: PAM adding faulty module: /usr/lib64/security/pam_tally2.so
实际上系统缺少 /usr/lib64/security/pam_tally2.so 文件,原因是 /etc/pam.d/system-auth 包含了该认证策略。检查 /etc/pam.d 可以看到,升级CentOS 8的很多配置文件没有覆盖原先旧系统的配置文件,需要修正:
cd /etc/pam.d
mv sshd sshd.bak
mv sshd.rpmnew sshd
sysemctl restart sshd
然后就可以通过ssh远程登陆了。

修改了,也没查出ssh失败的问题
#允许ssh使用root用户远程登录
echo “PermitRootLogin yes” >> /etc/ssh/sshd_config
#重启系统
reboot
以上的网卡和ssh问题解决后可以接着下面的安装和测试
自己参考重启了ssh服务和修改参数后发现依然连接不上,各种折腾,没有折腾成功,最后使用的是控制台的方式远程进去的。

十、更新CentOS8的最小化安装的相关package并重启系统

[root@]# dnf -y groupupdate “Core” “Minimal Install”
[root@]# reboot

重启之后即可确认内核和版本文件信息均已升至最新

[root@]# uname -a
Linux centos7 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Tue Nov 16 14:42:35 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux

#min化安装centos 8软件包
[root@]# dnf -y groupupdate “Core” “Minimal Install”
#出现错误(centos8.0 软件仓库报错)

#删除原来的阿里软件仓库
[root@=]# rm -rf /etc/yum.repos.d/CentOS-Base.repo
#下载华为centos8版本的软件仓库
[root@=]# curl -o /etc/yum.repos.d/CentOS-Base.repo https://repo.huaweicloud.com/repository/conf/CentOS-8-reg.repo

#清理仓库缓存
[root@]# dnf clean all
#重新生成缓存并查看仓库(确认仓库是否正常)
[root@]# dnf repolist

#仓库修改完成后,继续安装min
[root@]# dnf groupupdate “Core” “Minimal Install” --allowerasing

[root@】]# dnf groupupdate “Core” “Minimal Install” --skip-broken
[root@】# rpm -Va --nofiles --nodigest
[root@】]# rpm --rebuilddb
[root@】]# dnf clean packages

#查看当前的系统版本(已经升级为centos 8.5)
[root@】]# cat /etc/redhat-release
CentOS Linux release 8.5.2111
#安装nginx(安装成功表示升级没有问题)
[root@]# dnf install nginx

最后总结,centos7.9直接升级到centos8.5,升级因为yum,python,dnf等问题,出现了各种问题,总的感觉就是7和8的各种软件版本的冲突,并且升级到8以后,自己尝试安装一些软件,发现好多还是7的软件名字,在8里不通用,也有各种依赖遗留问题,个人感觉如果想看新特性,还不如直接安装centos8,centios7升级8太折腾了。

参考
https://www.cnblogs.com/zeny/p/16578221.html
https://blog.csdn.net/m0_37886429/article/details/121419904
https://my.oschina.net/u/1384571/blog/5481174
https://cloud.tencent.com/developer/article/2302258
http://linux.it.net.cn/m/view.php?aid=31297

好的,下面我来详细介绍一下在 CentOS 7.9 上安装 JDK1.8 和 Tomcat8.5 的步骤。 1. 安装 JDK1.8 首先,我们需要下载 JDK1.8 的安装包。你可以在 Oracle 官网下载,也可以在其他网站下载。 然后,我们将下载的安装包上传到 CentOS 服务器上。假设我们将安装包放在 /usr/local/src 目录下。接着,我们执行以下命令进行安装: ``` cd /usr/local/src tar -zxvf jdk-8u291-linux-x64.tar.gz ``` 解压完成后,我们需要将 JDK1.8 的路径添加到环境变量中。编辑 /etc/profile 文件,添加以下内容: ``` export JAVA_HOME=/usr/local/src/jdk1.8.0_291 export PATH=$JAVA_HOME/bin:$PATH ``` 保存并退出后,执行以下命令使配置生效: ``` source /etc/profile ``` 最后,我们可以通过以下命令来验证 JDK1.8 是否安装成功: ``` java -version ``` 2. 安装 Tomcat8.5 接下来,我们需要下载 Tomcat8.5 的安装包。同样的,你可以在 Apache 官网下载,也可以在其他网站下载。 将下载的安装包上传到 CentOS 服务器上,并解压到 /usr/local 目录下: ``` cd /usr/local tar -zxvf apache-tomcat-8.5.68.tar.gz ``` 解压完成后,我们需要将 Tomcat8.5 的路径添加到环境变量中。编辑 /etc/profile 文件,添加以下内容: ``` export CATALINA_HOME=/usr/local/apache-tomcat-8.5.68 ``` 保存并退出后,执行以下命令使配置生效: ``` source /etc/profile ``` 3. 启动 Tomcat 现在,我们可以通过以下命令来启动 Tomcat: ``` $CATALINA_HOME/bin/startup.sh ``` 启动成功后,我们可以通过浏览器访问 http://<服务器IP>:8080 来查看 Tomcat 是否正常运行。 如果需要停止 Tomcat,可以执行以下命令: ``` $CATALINA_HOME/bin/shutdown.sh ``` 到此为止,你已经成功在 CentOS 7.9 上安装了 JDK1.8 和 Tomcat8.5,并成功运行了 Tomcat。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值