優化yum下載安裝慢,不斷換mirror
阿新 • • 發佈:2018-12-02
不停地換mirror,為了解決這個問題,在網上搜了好多資料,總結出一個基於aliyun的mirror源
先檢查:是否能正常上網,DNS是否正常,閘道器gw是否正常,若通過ping 不正常,則解決好網路,再進行下面操作.
1. 清除快取
[[email protected] ~]# yum clean all 已載入外掛:fastestmirror 正在清理軟體源: 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
2.元資料建立
[[email protected] ~]# yum makecache 已載入外掛:fastestmirror Determining fastest mirrors * base: mirrors.cn99.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/12): base/7/x86_64/group_gz | 166 kB 00:00:01 (2/12): extras/7/x86_64/prestodelta | 100 kB 00:00:00 (3/12): extras/7/x86_64/filelists_db | 603 kB 00:00:02 (4/12): extras/7/x86_64/other_db | 126 kB 00:00:00 (5/12): extras/7/x86_64/primary_db | 205 kB 00:00:01 (6/12): base/7/x86_64/filelists_db | 6.9 MB 00:00:02 (7/12): base/7/x86_64/primary_db | 5.9 MB 00:00:03 (8/12): updates/7/x86_64/prestodelta | 679 kB 00:00:01 (9/12): updates/7/x86_64/other_db | 578 kB 00:00:01 (10/12): updates/7/x86_64/filelists_db | 3.4 MB 00:00:02 (11/12): updates/7/x86_64/primary_db | 6.0 MB 00:00:02 (12/12): base/7/x86_64/other_db | 2.5 MB 00:00:06 元資料快取已建立
3. 更新
[[email protected] ~]# yum update 已載入外掛:fastestmirror Loading mirror speeds from cached hostfile * base: mirrors.cn99.com * extras: mirrors.aliyun.com * updates: mirrors.aliyun.com No packages marked for update
4.備份yum源
[[email protected] ~]# cd /etc/yum.repos.d/ [[email protected]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 [[email protected] yum.repos.d]# mv CentOS-Base.repo CentOS-Base.repo.backup [[email protected] yum.repos.d]# ls CentOS-Base.repo.backup CentOS-Debuginfo.repo CentOS-Media.repo CentOS-Vault.repo CentOS-CR.repo CentOS-fasttrack.repo CentOS-Sources.repo
5. 下載新的CentOS-Base.repo 到/etc/yum.repos.d/
再建立快取
[[email protected] yum.repos.d]# wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo --2018-12-02 17:55:13-- http://mirrors.aliyun.com/repo/Centos-7.repo 正在解析主機 mirrors.aliyun.com (mirrors.aliyun.com)... 183.61.14.235, 183.61.14.231, 183.61.14.236, ... 正在連線 mirrors.aliyun.com (mirrors.aliyun.com)|183.61.14.235|:80... 已連線。 已發出 HTTP 請求,正在等待迴應... 200 OK 長度:2523 (2.5K) [application/octet-stream] 正在儲存至: “/etc/yum.repos.d/CentOS-Base.repo” 100%[===========================================================>] 2,523 --.-K/s 用時 0s 2018-12-02 17:55:18 (107 MB/s) - 已儲存 “/etc/yum.repos.d/CentOS-Base.repo” [2523/2523])
[[email protected] yum.repos.d]# yum makecache 已載入外掛:fastestmirror Loading mirror speeds from cached hostfile * 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 14] curl#7 - "Failed connect to mirrors.aliyuncs.com:80; 拒絕連線" 正在嘗試其它映象。 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; 未知的錯誤" 正在嘗試其它映象。 base | 3.6 kB 00:00:00 extras | 3.4 kB 00:00:00 updates | 3.4 kB 00:00:00 元資料快取已建立