资讯专栏INFORMATION COLUMN

CentOS 7更新YUM源步骤

qiangdada / 1605人阅读

摘要:此处省略分钟更新成功程序员交流群,干货分享,加我拉你入群。,边敲代码边学习。

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

Step1 找到需要的源

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

Step2 编辑CentOS7.repo文件

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

</>复制代码

  1. [base]
  2. name=CentOS-$releasever - Base - mirrors.aliyun.com
  3. failovermethod=priority
  4. baseurl=http://mirrors.aliyun.com/centos/7.4.1708/os/x86_64/
  5. #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os
  6. gpgcheck=1
  7. gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
  8. #released updates
  9. [updates]
  10. name=CentOS-$releasever - Updates - mirrors.aliyun.com
  11. failovermethod=priority
  12. baseurl=http://mirrors.aliyun.com/centos/7.4.1708/updates/x86_64/
  13. #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates
  14. gpgcheck=1
  15. gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
  16. #additional packages that may be useful
  17. [extras]
  18. name=CentOS-$releasever - Extras - mirrors.aliyun.com
  19. failovermethod=priority
  20. baseurl=http://mirrors.aliyun.com/centos/7.4.1708/extras/x86_64/
  21. #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras
  22. gpgcheck=1
  23. gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
  24. #additional packages that extend functionality of existing packages
  25. [centosplus]
  26. name=CentOS-$releasever - Plus - mirrors.aliyun.com
  27. failovermethod=priority
  28. baseurl=http://mirrors.aliyun.com/centos/7.4.1708/centosplus/x86_64/
  29. #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus
  30. gpgcheck=1
  31. enabled=0
  32. gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
  33. #contrib - packages by Centos Users
  34. [contrib]
  35. name=CentOS-$releasever - Contrib - mirrors.aliyun.com
  36. failovermethod=priority
  37. baseurl=http://mirrors.aliyun.com/centos/7.4.1708/contrib/x86_64/
  38. #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=contrib
  39. gpgcheck=1
  40. enabled=0
  41. gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7

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

</>复制代码

  1. :%s/7.4.1708/7.5.1804/g
Step3 修复冲突报错

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

</>复制代码

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

如果报如下错误

</>复制代码

  1. 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

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

</>复制代码

  1. [root@liaogx ~]# rpm -e redhat-release-server-7.4-18.el7.x86_64 --nodeps
  2. warning: file /etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release: remove failed: No such file or directory
  3. warning: file /etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-legacy-rhx: remove failed: No such file or directory
  4. warning: file /etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-legacy-release: remove failed: No such file or directory
  5. warning: file /etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-legacy-former: remove failed: No such file or directory
  6. warning: file /etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-beta: remove failed: No such file or directory
  7. [root@liaogx ~]#
Step4 更新系统

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

</>复制代码

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

更新成功 ^_^

</>复制代码

  1. 程序员交流群,干货分享,加我拉你入群。,边敲代码边学习。

文章版权归作者所有,未经允许请勿转载,若此文章存在违规行为,您可以联系管理员删除。

转载请注明本文地址:https://www.ucloud.cn/yun/24300.html

相关文章

  • CentOS 7更新YUM步骤

    摘要:此处省略分钟更新成功程序员交流群,干货分享,加我拉你入群。,边敲代码边学习。 国内小伙伴推荐使用阿里云的源 Step1 找到需要的源 阿里巴巴开源镜像站各种源应有尽有,老域名是https://mirrors.aliyun.com/ showImg(https://segmentfault.com/img/remote/1460000016397362?w=1920&h=1002); S...

    MadPecker 评论0 收藏0
  • CentOS 7更新YUM步骤

    摘要:此处省略分钟更新成功程序员交流群,干货分享,加我拉你入群。,边敲代码边学习。 国内小伙伴推荐使用阿里云的源 Step1 找到需要的源 阿里巴巴开源镜像站各种源应有尽有,老域名是https://mirrors.aliyun.com/ showImg(https://segmentfault.com/img/remote/1460000016397362?w=1920&h=1002); S...

    yeooo 评论0 收藏0

发表评论

0条评论

qiangdada

|高级讲师

TA的文章

阅读更多
最新活动
阅读需要支付1元查看
<