Centos配置阿里雲yum源


Centos配置阿里雲yum源

  1. 進入到yum源文件存放目錄 cd /etc/yum.repos.d,執行 yum install -y wget,之后備份系統自帶的yum文件

    #	執行 yum install -y wget
    [root@localhost yum.repos.d]# yum install -y wget
    已加載插件:fastestmirror
    Loading mirror speeds from cached hostfile
     * base: mirrors.tuna.tsinghua.edu.cn
     * extras: ftp.sjtu.edu.cn
     * updates: ftp.sjtu.edu.cn
    正在解決依賴關系
    --> 正在檢查事務
    ---> 軟件包 wget.x86_64.0.1.14-18.el7_6.1 將被 安裝
    --> 解決依賴關系完成
    
    依賴關系解決
    
    ======================================================================================================================================
     Package                     架構                          版本                                     源                           大小
    ======================================================================================================================================
    正在安裝:
     wget                        x86_64                        1.14-18.el7_6.1                          base                        547 k
    
    事務概要
    ======================================================================================================================================
    安裝  1 軟件包
    
    總下載量:547 k
    安裝大小:2.0 M
    Downloading packages:
    警告:/var/cache/yum/x86_64/7/base/packages/wget-1.14-18.el7_6.1.x86_64.rpm: 頭V3 RSA/SHA256 Signature, 密鑰 ID f4a80eb5: NOKEY
    wget-1.14-18.el7_6.1.x86_64.rpm 的公鑰尚未安裝
    wget-1.14-18.el7_6.1.x86_64.rpm                                                                                | 547 kB  00:00:00     
    從 file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 檢索密鑰
    導入 GPG key 0xF4A80EB5:
     用戶ID     : "CentOS-7 Key (CentOS 7 Official Signing Key) <security@centos.org>"
     指紋       : 6341 ab27 53d7 8a78 a7c2 7bb1 24c6 a8a7 f4a8 0eb5
     軟件包     : centos-release-7-4.1708.el7.centos.x86_64 (@anaconda)
     來自       : /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
    Running transaction check
    Running transaction test
    Transaction test succeeded
    Running transaction
      正在安裝    : wget-1.14-18.el7_6.1.x86_64                                                                                       1/1 
      驗證中      : wget-1.14-18.el7_6.1.x86_64                                                                                       1/1 
    
    已安裝:
      wget.x86_64 0:1.14-18.el7_6.1                                                                                                       
    #	進入到yum源文件目錄並備份
    [root@localhost yum.repos.d]# 
    [root@localhost ~]# cd /etc/yum.repos.d
    [root@localhost yum.repos.d]# 
    [root@localhost yum.repos.d]# 
    [root@localhost yum.repos.d]# ls -lrt
    總用量 8
    -rw-r--r--. 1 root root 1919 3月  15 19:21 docker-ce.repo
    -rw-r--r--. 1 root root 2523 3月  16 11:10 Centos-7.repo
    drwxr-xr-x. 2 root root  187 3月  16 2022 bak
    [root@localhost yum.repos.d]# 
    [root@localhost yum.repos.d]# mkdir bak
    [root@localhost yum.repos.d]# ls -lrt
    總用量 28
    -rw-r--r--. 1 root root 3830 8月  30 2017 CentOS-Vault.repo
    -rw-r--r--. 1 root root 1331 8月  30 2017 CentOS-Sources.repo
    -rw-r--r--. 1 root root  630 8月  30 2017 CentOS-Media.repo
    -rw-r--r--. 1 root root  314 8月  30 2017 CentOS-fasttrack.repo
    -rw-r--r--. 1 root root  649 8月  30 2017 CentOS-Debuginfo.repo
    -rw-r--r--. 1 root root 1309 8月  30 2017 CentOS-CR.repo
    -rw-r--r--. 1 root root 1664 8月  30 2017 CentOS-Base.repo
    drwxr-xr-x. 2 root root    6 3月  16 13:03 bak
    [root@localhost yum.repos.d]# 
    [root@localhost yum.repos.d]# 
    [root@localhost yum.repos.d]# mv CentOS-* ./bak/
    [root@localhost yum.repos.d]# ls -lrt
    總用量 0
    drwxr-xr-x. 2 root root 187 3月  16 13:03 bak
    [root@localhost yum.repos.d]# 
    
    
  2. 執行 wget http://mirrors.aliyun.com/repo/Centos-7.repo 下載repo文件,

    [root@localhost yum.repos.d]# wget http://mirrors.aliyun.com/repo/Centos-7.repo
    --2022-03-16 14:12:31--  http://mirrors.aliyun.com/repo/Centos-7.repo
    正在解析主機 mirrors.aliyun.com (mirrors.aliyun.com)... 221.195.209.67, 221.204.226.116, 221.204.195.26, ...
    正在連接 mirrors.aliyun.com (mirrors.aliyun.com)|221.195.209.67|:80... 已連接。
    已發出 HTTP 請求,正在等待回應... 200 OK
    長度:2523 (2.5K) [application/octet-stream]
    正在保存至: “Centos-7.repo”
    
    100%[============================================================================================>] 2,523       --.-K/s 用時 0s      
    
    2022-03-16 14:12:32 (170 MB/s) - 已保存 “Centos-7.repo” [2523/2523])
    
    #	ls 查看文件已下載到目錄
    [root@localhost yum.repos.d]# ls -lrt
    總用量 4
    -rw-r--r--. 1 root root 2523 12月 26 2020 Centos-7.repo
    drwxr-xr-x. 2 root root  187 3月  16 13:03 bak
    [root@localhost yum.repos.d]# 
    [root@localhost yum.repos.d]# 
    
  3. 如果提示下載失敗,直接登錄到 http://mirrors.aliyun.com/repo/ 源文件下載地址,點擊對應的版本下載即可。之后用winscp或其他工具將文件拖入到 /etc/yum.repos.d 目錄下。

    image-20220316115316491

  4. 更新yum源

    #	yum clean all	清理緩存
    [root@localhost yum.repos.d]# 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
    [root@localhost yum.repos.d]# 
    [root@localhost yum.repos.d]# 
    
    
    #	yum makecache	生成緩存
    [root@localhost yum.repos.d]# yum makecache
    已加載插件:fastestmirror
    base                                                                                                           | 3.6 kB  00:00:00     
    extras                                                                                                         | 2.9 kB  00:00:00     
    updates                                                                                                        | 2.9 kB  00:00:00     
    base/7/x86_64/primary_db       FAILED                                                               ]  0.0 B/s |    0 B  --:--:-- ETA 
    http://mirrors.cloud.aliyuncs.com/centos/7/os/x86_64/repodata/6d0c3a488c282fe537794b5946b01e28c7f44db79097bb06826e1c0c88bad5ef-primary.sqlite.bz2: [Errno 14] curl#6 - "Could not resolve host: mirrors.cloud.aliyuncs.com; Name or service not known"
    正在嘗試其它鏡像。
    (1/10): base/7/x86_64/group_gz                                                                                 | 153 kB  00:00:00     
    (2/10): extras/7/x86_64/filelists_db                                                                           | 277 kB  00:00:01     
    (3/10): extras/7/x86_64/other_db                                                                               | 147 kB  00:00:00     
    (4/10): base/7/x86_64/other_db                                                                                 | 2.6 MB  00:00:07     
    (5/10): updates/7/x86_64/filelists_db                                                                          | 7.8 MB  00:00:19     
    base/7/x86_64/filelists_db     FAILED                                          
    http://mirrors.aliyuncs.com/centos/7/os/x86_64/repodata/d6d94c7d406fe7ad4902a97104b39a0d8299451832a97f31d71653ba982c955b-filelists.sqlite.bz2: [Errno 14] curl#7 - "Failed connect to mirrors.aliyuncs.com:80; Connection refused"
    正在嘗試其它鏡像。
    extras/7/x86_64/primary_db     FAILED                                          
    http://mirrors.aliyuncs.com/centos/7/extras/x86_64/repodata/6b9d4ba8d12dfc1d42c81979e0452874b9dd3240afd9060c4a14b7dbd1cd439c-primary.sqlite.bz2: [Errno 14] curl#7 - "Failed connect to mirrors.aliyuncs.com:80; Connection refused"
    正在嘗試其它鏡像。
    (6/10): extras/7/x86_64/primary_db                                                                             | 246 kB  00:00:00     
    updates/7/x86_64/primary_db    FAILED                                                               ] 407 kB/s |  12 MB  00:01:10 ETA 
    http://mirrors.aliyuncs.com/centos/7/updates/x86_64/repodata/2d69d28700b725aac11caa123929a65d95c7e5d02d45445438cc7c5583aee364-primary.sqlite.bz2: [Errno 14] curl#7 - "Failed connect to mirrors.aliyuncs.com:80; Connection refused"
    正在嘗試其它鏡像。
    updates/7/x86_64/other_db      FAILED                                                               ] 682 kB/s |  16 MB  00:00:35 ETA 
    http://mirrors.aliyuncs.com/centos/7/updates/x86_64/repodata/a2b80243882b3efdca177a96bdb9c327e81b469c669f10d3317f1a80ac632e27-other.sqlite.bz2: [Errno 14] curl#7 - "Failed connect to mirrors.aliyuncs.com:80; Connection refused"
    正在嘗試其它鏡像。
    (7/10): updates/7/x86_64/other_db                                                                              | 1.0 MB  00:00:02     
    (8/10): base/7/x86_64/filelists_db                                                                             | 7.2 MB  00:00:17     
    base/7/x86_64/primary_db       FAILED                                          ======-              ] 628 kB/s |  26 MB  00:00:21 ETA 
    http://mirrors.aliyuncs.com/centos/7/os/x86_64/repodata/6d0c3a488c282fe537794b5946b01e28c7f44db79097bb06826e1c0c88bad5ef-primary.sqlite.bz2: [Errno 14] curl#7 - "Failed connect to mirrors.aliyuncs.com:80; Connection refused"
    正在嘗試其它鏡像。
    (9/10): base/7/x86_64/primary_db                                                                               | 6.1 MB  00:00:15     
    (10/10): updates/7/x86_64/primary_db                                                                           |  14 MB  00:00:37     
    Determining fastest mirrors
     * base: mirrors.aliyun.com
     * extras: mirrors.aliyun.com
     * updates: mirrors.aliyun.com
    元數據緩存已建立
    [root@localhost yum.repos.d]# 
    
    

    參考:https://www.cnblogs.com/enduo/p/9078313.html


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM