1.安装wget
yum install -y wget
[vagrant@localhost ~]$ yum install -y wget Failed to set locale, defaulting to C Loaded plugins: fastestmirror Determining fastest mirrors * base: mirrors.aliyun.com * extras: mirrors.aliyun.com * updates: mirrors.aliyun.com base | 3.6 kB 00:00:00 extras | 3.4 kB 00:00:00 updates | 3.4 kB 00:00:00 (1/4): extras/7/x86_64/primary_db | 215 kB 00:00:00 (2/4): base/7/x86_64/group_gz | 166 kB 00:00:02 (3/4): base/7/x86_64/primary_db | 6.0 MB 00:00:11 (4/4): updates/7/x86_64/primary_db | 7.4 MB 00:00:12 Resolving Dependencies --> Running transaction check ---> Package wget.x86_64 0:1.14-18.el7_6.1 will be installed --> Finished Dependency Resolution Dependencies Resolved ================================================================================================================= Package Arch Version Repository Size ================================================================================================================= Installing: wget x86_64 1.14-18.el7_6.1 updates 547 k Transaction Summary ================================================================================================================= Install 1 Package Total download size: 547 k Installed size: 2.0 M Downloading packages: warning: /var/cache/yum/x86_64/7/updates/packages/wget-1.14-18.el7_6.1.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY Public key for wget-1.14-18.el7_6.1.x86_64.rpm is not installed wget-1.14-18.el7_6.1.x86_64.rpm | 547 kB 00:00:00 Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 Importing GPG key 0xF4A80EB5: Userid : "CentOS-7 Key (CentOS 7 Official Signing Key) <security@centos.org>" Fingerprint: 6341 ab27 53d7 8a78 a7c2 7bb1 24c6 a8a7 f4a8 0eb5 Package : centos-release-7-5.1804.el7.centos.x86_64 (@anaconda) From : /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 Running transaction check Running transaction test Transaction test succeeded Running transaction Installing : wget-1.14-18.el7_6.1.x86_64 1/1 Verifying : wget-1.14-18.el7_6.1.x86_64 1/1 Installed: wget.x86_64 0:1.14-18.el7_6.1 Complete!
2.备份
==mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup ==
[root@localhost vagrant]# mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
查询国内镜像源
打开阿里镜像 http://mirrors.aliyun.com/
下载CentOS-Base.repo到/etc/yum.repos.d/
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
[root@localhost yum.repos.d]# wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo --2019-08-29 08:31:52-- http://mirrors.aliyun.com/repo/Centos-7.repo Resolving mirrors.aliyun.com (mirrors.aliyun.com)... 114.80.24.201, 114.80.24.196, 114.80.24.199, ... Connecting to mirrors.aliyun.com (mirrors.aliyun.com)|114.80.24.201|:80... connected. HTTP request sent, awaiting response... 200 OK Length: 2523 (2.5K) [application/octet-stream] Saving to: '/etc/yum.repos.d/CentOS-Base.repo' 100%[=======================================================================>] 2,523 --.-K/s in 0s 2019-08-29 08:31:54 (121 MB/s) - '/etc/yum.repos.d/CentOS-Base.repo' saved [2523/2523]
清除缓存
yum clean all
[root@localhost yum.repos.d]# yum clean all Failed to set locale, defaulting to C Loaded plugins: fastestmirror Cleaning repos: base extras updates Cleaning up everything Maybe you want: rm -rf /var/cache/yum, to also free up space taken by orphaned data from disabled or removed repos Cleaning up list of fastest mirrors
生存缓存
yum makecache
[root@localhost yum.repos.d]# yum makecache Failed to set locale, defaulting to C Loaded plugins: fastestmirror Determining fastest mirrors * base: mirrors.aliyun.com * extras: mirrors.aliyun.com * updates: mirrors.aliyun.com http://mirrors.aliyuncs.com/centos/7/os/x86_64/repodata/repomd.xml: [Errno 12] Timeout on http://mirrors.aliyuncs.com/centos/7/os/x86_64/repodata/repomd.xml: (28, 'Connection timed out after 30003 milliseconds') Trying other mirror. http://mirrors.cloud.aliyuncs.com/centos/7/os/x86_64/repodata/repomd.xml: [Errno 14] curl#6 - "Could not resolve host: mirrors.cloud.aliyuncs.com; Unknown error" Trying other mirror. base | 3.6 kB 00:00:00 extras | 3.4 kB 00:00:00 updates | 3.4 kB 00:00:00 (1/12): base/7/x86_64/group_gz | 166 kB 00:00:00 (2/12): base/7/x86_64/primary_db | 6.0 MB 00:00:10 (3/12): extras/7/x86_64/prestodelta | 73 kB 00:00:00 (4/12): extras/7/x86_64/filelists_db | 249 kB 00:00:00 (5/12): extras/7/x86_64/primary_db | 215 kB 00:00:00 (6/12): extras/7/x86_64/other_db | 131 kB 00:00:00 (7/12): base/7/x86_64/filelists_db | 7.1 MB 00:00:13 (8/12): updates/7/x86_64/prestodelta | 945 kB 00:00:02 (9/12): base/7/x86_64/other_db | 2.6 MB 00:00:06 (10/12): updates/7/x86_64/filelists_db | 5.2 MB 00:00:14 (11/12): updates/7/x86_64/other_db | 764 kB 00:00:01 (12/12): updates/7/x86_64/primary_db | 7.4 MB 00:00:14 Metadata Cache Created
来源:51CTO
作者:黄千佑
链接:https://blog.csdn.net/qq_15722433/article/details/100141041