问题
使用 systemctl status network
命令查看网络服务状态时报错:Unit network.service could not be found.
用centos7以前的命令service查看报同样的错,查看service服务 /etc/init.d/
中并没有 network
,查看systemctl服务 /usr/lib/systemd/system
中也没有 network.service
检查 systemctl status net
使用 tab 键补全命令列出 net 开头的服务,可以看到系统中是存在 network.service
的,系统找不到是系统版本问题:在新版本的系统中, 一些网络脚本已被废弃, 如果还需使用要重新安装脚本 yum install network-scripts
(其他原因:没安装 NetworkManager yum install NetworkManager*
)
CentOS 8 yum install 失败:CentOS Linux 8 - AppStream 错误:为仓库 ‘appstream’ 下载元数据失败 : Cannot prepare internal mirrorlist: No URLs in mirrorlist
原因
CentOS Linux 8在2022年12月31日来到生命周期终点(End of Life,EoL). 即CentOS Linux 8操作系统版本结束了生命周期(EOL),Linux社区已不再维护该操作系统版本,,所以自带的yum源也就全部失效了,最终导致使用该默认源就无法安装软件
解决
方法1
现在软件包被转移到 https://vault.centos.org,如果仍要运行 CentOS 8,可以在 /etc/yum.repos.d
中更新一下源. 使用 vault.centos.org
代替 mirror.centos.org
即可. 切换到 root 用户更换 CentOS Linux 8 的 yum 源:
sed -i -e "s|mirrorlist=|#mirrorlist=|g" /etc/yum.repos.d/CentOS-*
sed -i -e "s|#baseurl=http://mirror.centos.org|baseurl=http://vault.centos.org|g" /etc/yum.repos.d/CentOS-*
再次安装,yum 源已能正常使用
安装完 network-scripts
就可以正常查看网络服务状态了
方法2
进入源目录把失效的源备份或直接删除:
cd /etc/yum.repos.d/
mkdir bak
mv CentOS-Linux-* bak #备份
rm -rf ./*.repo #删除
下载新的源:
wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-vault-8.5.2111.repo
yum makecache #建立新的元数据缓存
方法3
注释掉mirrorlist和旧baseurl, 更换为新的yum仓库镜像源
[root@hadoop100 ~]# cd /etc/yum.repos.d
[root@hadoop100 yum.repos.d]# vim CentOS-Linux-AppStream.repo
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=AppStream&infra=$infra
#baseurl=http://vault.centos.org/$contentdir/$releasever/AppStream/$basearch/os/
baseurl=https://mirrors.aliyun.com/centos/8-stream/AppStream/x86_64/os/
[root@hadoop100 yum.repos.d]# vim CentOS-Linux-BaseOS.repo
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=BaseOS&infra=$infra
#baseurl=http://vault.centos.org/$contentdir/$releasever/BaseOS/$basearch/os/
baseurl=https://mirrors.aliyun.com/centos/8-stream/BaseOS/x86_64/os/
[root@hadoop100 yum.repos.d]# vim CentOS-Linux-Extras.repo
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras&infra=$infra
#baseurl=http://vault.centos.org/$contentdir/$releasever/extras/$basearch/os/
baseurl=https://mirrors.aliyun.com/centos/8-stream/extras/x86_64/os/