centos7配置国内网络源yum

准备环境
配置网络源yum
一,备份本地yum文件

[root@localhost ~]# cd /etc/yum.repos.d/
[root@localhost yum.repos.d]# ls
CentOS-Base.repo  CentOS-Debuginfo.repo  CentOS-Media.repo    CentOS-Vault.repo
CentOS-CR.repo    CentOS-fasttrack.repo  CentOS-Sources.repo
[root@localhost yum.repos.d]# mkdir yum.repos.d.bak    创建备份目录
[root@localhost yum.repos.d]# mv C* yum.repos.d.bak   移动到备份目录
[root@localhost yum.repos.d]# vim yum.repo    配置国内网络源yum,名称随意,但文件后缀必须为repo

二,配置网络源yum
在yum.repo文件中编辑下面配置

# CentOS-Base.repo
# The mirror system uses the connecting IP address of the client and the
# update status of each mirror to pick mirrors that are updated to and
# geographically close to the client.  You should use this for CentOS updates
# unless you are manually picking other mirrors.

# If the mirrorlist= does not work for you, as a fall back you can try the
# remarked out baseurl= line instead.
#
#

[base]
name=CentOS-$releasever - Base
baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/os/$basearch/
# mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

# released updates
[updates]
name=CentOS-$releasever - Updates
baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/updates/$basearch/
# mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

# additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras
baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/extras/$basearch/
# mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

# additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus
baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/centosplus/$basearch/
# mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

三,清空yum缓存,重新加载数据,安装yum扩展包

[root@localhost yum.repos.d]# yum clean all										#清空缓存
Loaded plugins: fastestmirror, langpacks
Cleaning repos: base extras updates
Cleaning up everything
[root@localhost yum.repos.d]# yum makecache								#加载数据
Loaded plugins: fastestmirror, langpacks
base                                                           | 3.6 kB  00:00:00     
extras                                                         | 2.9 kB  00:00:00     
updates                                                        | 2.9 kB  00:00:00     
(1/10): base/7/x86_64/group_gz                                 | 153 kB  00:00:00     
(2/10): base/7/x86_64/primary_db                               | 6.1 MB  00:00:00     
(3/10): base/7/x86_64/other_db                                 | 2.6 MB  00:00:00     
(4/10): base/7/x86_64/filelists_db                                                                                                                      | 7.2 MB  00:00:06     
(5/10): extras/7/x86_64/filelists_db                                                                                                                    | 224 kB  00:00:05     
(6/10): extras/7/x86_64/other_db                                                                                                                        | 134 kB  00:00:00     
(7/10): extras/7/x86_64/primary_db                                                                                                                      | 222 kB  00:00:06     
(8/10): updates/7/x86_64/primary_db                                                                                                                     | 3.7 MB  00:00:01     
(9/10): updates/7/x86_64/other_db                                                                                                                       | 227 kB  00:00:00     
(10/10): updates/7/x86_64/filelists_db                                                                                                                  | 2.1 MB  00:00:01     
Determining fastest mirrors
Metadata Cache Created
[root@localhost yum.repos.d]# yum -y install yum-utils                  			#安装yum扩展程序

四,配置完成,yum可直接下载最新安装包

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值