搜索
首页运维CentOS详解CentOS7更新YUM源步骤

详解CentOS7更新YUM源步骤

Apr 27, 2021 pm 04:55 PM
linuxmysqlpython

下面由centos教程栏目给大家介绍CentOS 7更新YUM源步骤,希望对需要的朋友有所帮助!

国内小伙伴推荐使用阿里云的源

Step1 找到需要的源

阿里巴巴开源镜像站各种源应有尽有,老域名是https://mirrors.aliyun.com/

Step2 编辑CentOS7.repo文件

进入/etc/yum.repos.d,发现我的源还是7.4.1708

[base]
name=CentOS-$releasever - Base - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/7.4.1708/os/x86_64/
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7

#released updates
[updates]
name=CentOS-$releasever - Updates - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/7.4.1708/updates/x86_64/
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7

#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/7.4.1708/extras/x86_64/
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7

#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/7.4.1708/centosplus/x86_64/
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus
gpgcheck=1
enabled=0
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7

#contrib - packages by Centos Users
[contrib]
name=CentOS-$releasever - Contrib - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/7.4.1708/contrib/x86_64/
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=contrib
gpgcheck=1
enabled=0
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7

这个版本的源已经迁移到7.5.1804了,→地址,使用VIM将其替换

:%s/7.4.1708/7.7.1908/g

Step3 修复冲突报错

然后更新系统试试yum -y update

[root@liaogx ~]# yum -y update
Plugin "product-id" can't be imported
Plugin "search-disabled-repos" can't be imported
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.aliyun.com
 * epel: mirrors.tuna.tsinghua.edu.cn
 * extras: mirrors.aliyun.com
 * updates: mirrors.aliyun.com
Resolving Dependencies
--> Running transaction check
---> Package ModemManager.x86_64 0:1.6.0-2.el7 will be updated
......此处略......
---> Package yum-rhn-plugin.noarch 0:2.0.1-10.el7 will be installed
--> Running transaction check
---> Package libbytesize.x86_64 0:1.2-1.el7 will be installed
---> Package python2-pytoml.noarch 0:0.1.18-1.el7 will be installed
---> Package volume_key-libs.x86_64 0:0.3.9-8.el7 will be installed
--> Processing Conflict: initscripts-9.49.41-1.el7_5.1.x86_64 conflicts redhat-release < 7.5-0.11
--> Finished Dependency Resolution
Error: initscripts conflicts with redhat-release-server-7.4-18.el7.x86_64
 You could try using --skip-broken to work around the problem
** Found 2 pre-existing rpmdb problem(s), 'yum check' output follows:
PackageKit-1.1.5-1.el7.centos.x86_64 has missing requires of PackageKit-backend
rhn-check-2.0.2-17.el7.noarch has missing requires of yum-rhn-plugin >= ('0', '1.6.4', '1')
[root@liaogx ~]#

如果报如下错误

Error: initscripts conflicts with redhat-release-server-7.4-18.el7.x86_64

这是更新软件包是与原版本冲突造成的,有两种解决办法

  • 通过关键字initscritps排除冲突:yum update --exclude=kernel* --exclude=centos-release* --exclude=initscripts*
  • 删除冲突包:rpm -e redhat-release-server-7.4-18.el7.x86_64 --nodeps

这里使用第二种方法,把冲突的包干掉

[root@liaogx ~]# rpm -e redhat-release-server-7.4-18.el7.x86_64 --nodeps
warning: file /etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release: remove failed: No such file or directory
warning: file /etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-legacy-rhx: remove failed: No such file or directory
warning: file /etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-legacy-release: remove failed: No such file or directory
warning: file /etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-legacy-former: remove failed: No such file or directory
warning: file /etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-beta: remove failed: No such file or directory
[root@liaogx ~]#

Step4 更新系统

小白从入门到跑路必会,sudo yum -y update,老鸟都懂。

[root@liaogx ~]# yum -y update
......此处省略10分钟......
Complete!
[root@liaogx ~]#

更新成功 ^_^

以上是详解CentOS7更新YUM源步骤的详细内容。更多信息请关注PHP中文网其他相关文章!

声明
本文转载于:segmentfault。如有侵权,请联系admin@php.cn删除
CentOS的中断:了解因素CentOS的中断:了解因素Apr 24, 2025 am 12:01 AM

CentOS停止维护的原因是RedHat的战略转变,用户应对策略包括:1.迁移到其他发行版,如UbuntuServer、Debian或RockyLinux;2.继续使用CentOS7至2024年6月;3.转向CentOSStream;4.自建解决方案,如基于RHEL的定制发行版或使用容器技术。

CENTOS:是什么导致决定结束支持的决定CENTOS:是什么导致决定结束支持的决定Apr 23, 2025 am 12:10 AM

RedHatendedsupportforCentOStoshifttowardsacommerciallyfocusedmodelwithCentOSStream.1)CentOStransitionedtoCentOSStreamforRHELdevelopment.2)ThisencourageduserstomovetoRHEL.3)AlternativeslikeAlmaLinux,RockyLinux,andOracleLinuxemergedasreplacements.

使用CentOS:系统管理员指南使用CentOS:系统管理员指南Apr 22, 2025 am 12:04 AM

CentOS是一个基于RedHatEnterpriseLinux的开源操作系统,适合服务器环境。1.安装时选择合适的介质和选项,并配置网络、防火墙和用户权限。2.使用useradd、usermod和systemctl命令进行用户和服务管理,定期更新软件包。3.基本操作包括使用yum安装软件和systemctl管理服务,高级功能如SELinux增强安全性。4.查看系统日志解决常见错误,优化性能需监控资源和清理不必要文件。

CENTOS:安全性,稳定性和性能CENTOS:安全性,稳定性和性能Apr 21, 2025 am 12:11 AM

CentOS因其卓越的安全性、稳定性和性能成为服务器和企业环境的首选。 1)安全性通过SELinux提供强制访问控制,提升系统安全。 2)稳定性得益于长达10年的LTS版本支持,确保系统稳定。 3)性能通过优化内核和系统配置,显着提高系统响应速度和资源利用率。

CentOS替换景观:当前趋势和选择CentOS替换景观:当前趋势和选择Apr 20, 2025 am 12:05 AM

CentOS替代品应具备稳定性、兼容性、社区支持和软件包管理等特征。1.AlmaLinux提供10年支持,2.RockyLinux由CentOS创始人发起,确保与CentOS兼容。选择时需考虑迁移成本和性能优化。

CENTOS:Linux分布介绍CENTOS:Linux分布介绍Apr 19, 2025 am 12:07 AM

CentOS是一个基于RedHatEnterpriseLinux的开源发行版,专注于稳定性和长期支持,适用于各种服务器环境。1.CentOS的设计哲学是稳定,适用于Web、数据库和应用服务器。2.使用YUM作为包管理器,定期发布安全更新。3.安装简单,通过几条命令即可搭建Web服务器。4.高级功能包括使用SELinux增强安全性。5.常见问题如网络配置和软件依赖可以通过nmcli和yumdeplist命令调试。6.性能优化建议包括调整内核参数和使用轻量级Web服务器。

CENTOS IN ACTION:服务器管理和Web托管CENTOS IN ACTION:服务器管理和Web托管Apr 18, 2025 am 12:09 AM

CentOS在服务器管理和Web托管中广泛应用,具体方法包括:1)使用yum和systemctl管理服务器,2)安装并配置Nginx进行Web托管,3)利用top和mpstat优化性能,4)正确配置防火墙和管理磁盘空间以避免常见问题。

CENTOS:社区驱动的Linux分销CENTOS:社区驱动的Linux分销Apr 17, 2025 am 12:03 AM

CentOS是一个稳定的、企业级的Linux发行版,适用于服务器和企业环境。1)它基于RedHatEnterpriseLinux,提供免费、开源且兼容的操作系统。2)CentOS使用Yum包管理系统,简化软件安装和更新。3)支持高级自动化管理,如使用Ansible。4)常见错误包括软件包依赖和服务启动问题,可通过日志文件解决。5)性能优化建议包括使用轻量级软件、定期清理系统和优化内核参数。

See all articles

热AI工具

Undresser.AI Undress

Undresser.AI Undress

人工智能驱动的应用程序,用于创建逼真的裸体照片

AI Clothes Remover

AI Clothes Remover

用于从照片中去除衣服的在线人工智能工具。

Undress AI Tool

Undress AI Tool

免费脱衣服图片

Clothoff.io

Clothoff.io

AI脱衣机

Video Face Swap

Video Face Swap

使用我们完全免费的人工智能换脸工具轻松在任何视频中换脸!

热工具

SublimeText3 英文版

SublimeText3 英文版

推荐:为Win版本,支持代码提示!

记事本++7.3.1

记事本++7.3.1

好用且免费的代码编辑器

SublimeText3汉化版

SublimeText3汉化版

中文版,非常好用

mPDF

mPDF

mPDF是一个PHP库,可以从UTF-8编码的HTML生成PDF文件。原作者Ian Back编写mPDF以从他的网站上“即时”输出PDF文件,并处理不同的语言。与原始脚本如HTML2FPDF相比,它的速度较慢,并且在使用Unicode字体时生成的文件较大,但支持CSS样式等,并进行了大量增强。支持几乎所有语言,包括RTL(阿拉伯语和希伯来语)和CJK(中日韩)。支持嵌套的块级元素(如P、DIV),

禅工作室 13.0.1

禅工作室 13.0.1

功能强大的PHP集成开发环境