万能yum源配置方法

网上各种配置yum源的方法,有时候未必适用自己的情况。本文给出一种万能配置法,适合于centos、redhat,其他操作系统我没试,操作类似,可以自己研究一下。本文yum源为阿里。

1、检查是否安装yum包。若是安装了,那么又有哪些yum包:

rpm -qa |grep yum

2、替换CentOS-Base.repo

进入到系统yum源的目录下:

cd /etc/yum.repos.d

注:CentOS-Base.repo文件我已经改好了,大家直接替换就好,下载路径:

https://download.csdn.net/download/tyzyumi/20600053

3、配置DNS,否则无法解析阿里的域名

cd /etc/sysconfig/network-scripts

vi XXX(网口文件)

在文件最后新增DNS

DNS1=8.8.8.8

DNS2=8.8.4.4

重启network

service network restart

如果该布重启失败,应该是新增DNS那步创建了不存在的接口,需删掉新增的接口文件,在已有的接口配置文件中新增。

4、运行yum clean all(等同于 yum cleanheaders ; yum cleanpackages;

yum clean all

5、运行makecache 生成缓存

yum makecache

6、更新YUM文件

yum update

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
1. 使用官方源 在 /etc/yum.repos.d/ 中创建一个新文件,例如 /etc/yum.repos.d/official.repo,然后将以下内容复制到该文件中: [official] name=Official CentOS $releasever Base baseurl=http://mirror.centos.org/$contentdir/$releasever/os/$basearch/ gpgcheck=1 gpgkey=http://mirror.centos.org/$contentdir/$releasever/os/$basearch/RPM-GPG-KEY-CentOS-$releasever 保存文件后,使用命令 yum update 来检查更新。 2. 使用第三方源 许多第三方源可供选择。以下是一些示例: - EPEL (Extra Packages for Enterprise Linux) 源: 在 /etc/yum.repos.d/ 中创建一个新文件,例如 /etc/yum.repos.d/epel.repo,然后将以下内容复制到该文件中: [epel] name=Extra Packages for Enterprise Linux 7 - $basearch baseurl=https://mirrors.tuna.tsinghua.edu.cn/epel/7/$basearch gpgcheck=1 gpgkey=https://mirrors.tuna.tsinghua.edu.cn/epel/RPM-GPG-KEY-EPEL-7 保存文件后,使用命令 yum update 来检查更新。 - RPM Fusion 源: 在 /etc/yum.repos.d/ 中创建一个新文件,例如 /etc/yum.repos.d/rpmfusion.repo,然后将以下内容复制到该文件中: [rpmfusion-free] name=RPM Fusion for Fedora $releasever - Free baseurl=https://mirrors.tuna.tsinghua.edu.cn/rpmfusion/free/fedora/releases/$releasever/Everything/$basearch/os/ enabled=1 gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-rpmfusion-free-fedora-$releasever-$basearch [rpmfusion-nonfree] name=RPM Fusion for Fedora $releasever - Nonfree baseurl=https://mirrors.tuna.tsinghua.edu.cn/rpmfusion/nonfree/fedora/releases/$releasever/Everything/$basearch/os/ enabled=1 gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-rpmfusion-nonfree-fedora-$releasever-$basearch 保存文件后,使用命令 yum update 来检查更新。 3. 使用国内镜像源 许多国内镜像源可供选择。以下是一些示例: - 清华大学开源软件镜像站: 在 /etc/yum.repos.d/ 中创建一个新文件,例如 /etc/yum.repos.d/tuna.repo,然后将以下内容复制到该文件中: [tuna] name=tuna baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/os/$basearch/ enabled=1 gpgcheck=0 保存文件后,使用命令 yum update 来检查更新。 - 阿里云开源镜像站: 在 /etc/yum.repos.d/ 中创建一个新文件,例如 /etc/yum.repos.d/aliyun.repo,然后将以下内容复制到该文件中: [aliyun] name=aliyun baseurl=https://mirrors.aliyun.com/centos/$releasever/os/$basearch/ enabled=1 gpgcheck=0 保存文件后,使用命令 yum update 来检查更新。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值