CentOS 6.7使用阿里云CentOS的yum源

  1. This directory CentOS 6.7使用阿里云CentOS的yum源  
  2.   
  3.   
  4. 1、备份原有repo文件  
  5.   
  6. #cd /etc/yum.repos.d  
  7.   
  8. #mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup  
  9.   
  10. ## ll  
  11. total 16  
  12. -rw-r--r--. 1 root root 2572 Jul  2  2014 CentOS-Base.repo  
  13. -rw-r--r--. 1 root root  529 Jun 12  2015 CentOS-Base.repo.backup  
  14. -rw-r--r--. 1 root root  358 Oct 24 23:23 redhat.repo  
  15. -rw-r--r--. 1 root root 3749 Mar 29  2017 repomd.xml  
  16.   
  17.   
  18. 2.下载repo文件  
  19.   
  20. # wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo  
  21. --2017-10-31 19:14:33--  http://mirrors.aliyun.com/repo/Centos-6.repo  
  22. Resolving mirrors.aliyun.com... 223.111.244.145223.111.244.152223.111.244.147, ...  
  23. Connecting to mirrors.aliyun.com|223.111.244.145|:80... connected.  
  24. HTTP request sent, awaiting response... 200 OK  
  25. Length: 2572 (2.5K) [application/octet-stream]  
  26. Saving to: “/etc/yum.repos.d/CentOS-Base.repo”  
  27.   
  28. 100%[=============================================================================================================================>] 2,572       --.-K/s   in 0s        
  29.   
  30. 2017-10-31 19:14:33 (204 MB/s) - “/etc/yum.repos.d/CentOS-Base.repo” saved [2572/2572]  
  31.   
  32.   
  33. 3.但在yum makecahe 时候报错  
  34.   
  35. # yum makecache  
  36. Loaded plugins: aliases, changelog, kabi, presto, product-id, refresh-packagekit, security, subscription-manager, tmprepo, verify, versionlock  
  37. This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.  
  38. Loading support for Red Hat kernel ABI  
  39. http://mirrors.aliyun.com/centos/6Server/os/x86_64/repodata/repomd.xml: [Errno 14] PYCURL ERROR 22 - "The requested URL returned error: 404 Not Found"  
  40. Trying other mirror.  
  41. http://mirrors.aliyuncs.com/centos/6Server/os/x86_64/repodata/repomd.xml: [Errno 12] Timeout on http://mirrors.aliyuncs.com/centos/6Server/os/x86_64/repodata/repomd.xml: (28, 'connect() timed out!')  
  42. Trying other mirror.  
  43. Error: Cannot retrieve repository metadata (repomd.xml) for repository: base. Please verify its path and try again  
  44.   
  45.   
  46. 4.查看repo文件  
  47.   
  48. ## vi CentOS-Base.repo  
  49.   
  50. # CentOS-Base.repo  
  51. #  
  52. # The mirror system uses the connecting IP address of the client and the  
  53. # update status of each mirror to pick mirrors that are updated to and  
  54. # geographically close to the client.  You should use this for CentOS updates  
  55. # unless you are manually picking other mirrors.  
  56. #  
  57. # If the mirrorlist= does not work for you, as a fall back you can try the  
  58. # remarked out baseurl= line instead.  
  59.   
  60. [base]  
  61. name=CentOS-$releasever - Base - mirrors.aliyun.com  
  62. failovermethod=priority  
  63. baseurl=http://mirrors.aliyun.com/centos/$releasever/os/$basearch/  
  64.         http://mirrors.aliyuncs.com/centos/$releasever/os/$basearch/  
  65. #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os  
  66. gpgcheck=1  
  67. gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-6  
  68.   
  69. #released updates  
  70. [updates]  
  71. name=CentOS-$releasever - Updates - mirrors.aliyun.com  
  72. # CentOS-Base.repo  
  73. #  
  74. # The mirror system uses the connecting IP address of the client and the  
  75. # update status of each mirror to pick mirrors that are updated to and  
  76. # geographically close to the client.  You should use this for CentOS updates  
  77. # unless you are manually picking other mirrors.  
  78. #  
  79. # If the mirrorlist= does not work for you, as a fall back you can try the  
  80. # remarked out baseurl= line instead.  
  81.   
  82. [base]  
  83. name=CentOS-$releasever - Base - mirrors.aliyun.com  
  84. failovermethod=priority  
  85. baseurl=http://mirrors.aliyun.com/centos/$releasever/os/$basearch/  
  86.         http://mirrors.aliyuncs.com/centos/$releasever/os/$basearch/  
  87. #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os  
  88. gpgcheck=1  
  89. gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-6  
  90.   
  91. #released updates  
  92. [updates]  
  93. name=CentOS-$releasever - Updates - mirrors.aliyun.com  
  94. failovermethod=priority  
  95. baseurl=http://mirrors.aliyun.com/centos/$releasever/updates/$basearch/  
  96.         http://mirrors.aliyuncs.com/centos/$releasever/updates/$basearch/  
  97. #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates  
  98. gpgcheck=1  
  99. gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-6  
  100.   
  101. #additional packages that may be useful  
  102. [extras]  
  103. name=CentOS-$releasever - Extras - mirrors.aliyun.com  
  104. failovermethod=priority  
  105. baseurl=http://mirrors.aliyun.com/centos/$releasever/extras/$basearch/  
  106.         http://mirrors.aliyuncs.com/centos/$releasever/extras/$basearch/# cd /etc/yum.repos.d/  
  107.   
  108.   
  109.   
  110. 5.查看6.7的readmew文件,还是有些表变化发现小版本不再进行更新  
  111. This directory (and version of CentOS) is deprecated.  For normal users,  
  112. you should use /6/ and not /6.7/ in your path. Please see this FAQ  
  113. concerning the CentOS release scheme:  
  114. If you know what you are doing, and absolutely want to remain at the 6.7  
  115. level, go to http://vault.centos.org/ for packages.   
  116.   
  117. Please keep in mind that 6.06.16.26.36.4 , 6.56.6 and 6.7 no longer gets any updates, norany security fix's..  
  118.   
  119. 根据repo文件变量的变化,可以修改repo文件把所有$releasever替换成6   
  120.   
  121.  执行替换操作  
  122.   
  123. #sed -i 's/\$releasever/6/' CentOS-Base.repo  
  124.   
  125.   
  126.   
  127. 6.清理并重新生成yum缓存  
  128.   
  129. # yum clean all  
  130. Loaded plugins: aliases, changelog, kabi, presto, product-id, refresh-packagekit, security, subscription-manager, tmprepo, verify, versionlock  
  131. This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.  
  132. Loading support for Red Hat kernel ABI  
  133. Cleaning repos: base extras updates  
  134. Cleaning up Everything  
  135. 0 delta-package files removed, by presto  
  136.   
  137.   
  138. 7.重新yum makecache  
  139.   
  140. # yum makecache  
  141. Loaded plugins: aliases, changelog, kabi, presto, product-id, refresh-packagekit, security, subscription-manager, tmprepo, verify, versionlock  
  142. This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.  
  143. Loading support for Red Hat kernel ABI  
  144. base                                           | 3.7 kB     00:00       
  145. base/group_gz                                  | 226 kB     00:00       
  146. base/filelists_db                              | 6.4 MB     00:01       
  147. base/primary_db                                | 4.7 MB     00:00       
  148. base/other_db                                  | 2.8 MB     00:00       
  149. extras                                         | 3.4 kB     00:00       
  150. extras/filelists_db                            |  25 kB     00:00       
  151. extras/prestodelta                             | 1.3 kB     00:00       
  152. extras/primary_db                              |  29 kB     00:00       
  153. extras/other_db                                |  30 kB     00:00       
  154. updates                                        | 3.4 kB     00:00       
  155. updates/filelists_db                           | 3.0 MB     00:00       
  156. updates/prestodelta                            | 145 kB     00:00       
  157. updates/primary_db                             | 4.7 MB     00:01       
  158. updates/other_db                               |  66 MB     00:26       
  159. Metadata Cache Created  
网上还有一个据说完善的方法,不过没有进行测试,有兴趣的同学可以测试一下
在所有mirrorlist前面加上#,并所有$releasever替换成6

sed -i '/mirrorlist/d' CentOS-Base.repo


sed -i 's/\$releasever/6/' CentOS-Base.repo


sed -i  '/\ [addons\]/,/^$/d' CentOS-Base.repo


sed-i 's/RPM-GPG-KEY-CentOS-5/RPM-GPG-KEY-CentOS-6/' CentOS-Base.repo
  1. This directory CentOS 6.7使用阿里云CentOS的yum源  
  2.   
  3.   
  4. 1、备份原有repo文件  
  5.   
  6. #cd /etc/yum.repos.d  
  7.   
  8. #mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup  
  9.   
  10. ## ll  
  11. total 16  
  12. -rw-r--r--. 1 root root 2572 Jul  2  2014 CentOS-Base.repo  
  13. -rw-r--r--. 1 root root  529 Jun 12  2015 CentOS-Base.repo.backup  
  14. -rw-r--r--. 1 root root  358 Oct 24 23:23 redhat.repo  
  15. -rw-r--r--. 1 root root 3749 Mar 29  2017 repomd.xml  
  16.   
  17.   
  18. 2.下载repo文件  
  19.   
  20. # wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo  
  21. --2017-10-31 19:14:33--  http://mirrors.aliyun.com/repo/Centos-6.repo  
  22. Resolving mirrors.aliyun.com... 223.111.244.145223.111.244.152223.111.244.147, ...  
  23. Connecting to mirrors.aliyun.com|223.111.244.145|:80... connected.  
  24. HTTP request sent, awaiting response... 200 OK  
  25. Length: 2572 (2.5K) [application/octet-stream]  
  26. Saving to: “/etc/yum.repos.d/CentOS-Base.repo”  
  27.   
  28. 100%[=============================================================================================================================>] 2,572       --.-K/s   in 0s        
  29.   
  30. 2017-10-31 19:14:33 (204 MB/s) - “/etc/yum.repos.d/CentOS-Base.repo” saved [2572/2572]  
  31.   
  32.   
  33. 3.但在yum makecahe 时候报错  
  34.   
  35. # yum makecache  
  36. Loaded plugins: aliases, changelog, kabi, presto, product-id, refresh-packagekit, security, subscription-manager, tmprepo, verify, versionlock  
  37. This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.  
  38. Loading support for Red Hat kernel ABI  
  39. http://mirrors.aliyun.com/centos/6Server/os/x86_64/repodata/repomd.xml: [Errno 14] PYCURL ERROR 22 - "The requested URL returned error: 404 Not Found"  
  40. Trying other mirror.  
  41. http://mirrors.aliyuncs.com/centos/6Server/os/x86_64/repodata/repomd.xml: [Errno 12] Timeout on http://mirrors.aliyuncs.com/centos/6Server/os/x86_64/repodata/repomd.xml: (28, 'connect() timed out!')  
  42. Trying other mirror.  
  43. Error: Cannot retrieve repository metadata (repomd.xml) for repository: base. Please verify its path and try again  
  44.   
  45.   
  46. 4.查看repo文件  
  47.   
  48. ## vi CentOS-Base.repo  
  49.   
  50. # CentOS-Base.repo  
  51. #  
  52. # The mirror system uses the connecting IP address of the client and the  
  53. # update status of each mirror to pick mirrors that are updated to and  
  54. # geographically close to the client.  You should use this for CentOS updates  
  55. # unless you are manually picking other mirrors.  
  56. #  
  57. # If the mirrorlist= does not work for you, as a fall back you can try the  
  58. # remarked out baseurl= line instead.  
  59.   
  60. [base]  
  61. name=CentOS-$releasever - Base - mirrors.aliyun.com  
  62. failovermethod=priority  
  63. baseurl=http://mirrors.aliyun.com/centos/$releasever/os/$basearch/  
  64.         http://mirrors.aliyuncs.com/centos/$releasever/os/$basearch/  
  65. #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os  
  66. gpgcheck=1  
  67. gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-6  
  68.   
  69. #released updates  
  70. [updates]  
  71. name=CentOS-$releasever - Updates - mirrors.aliyun.com  
  72. # CentOS-Base.repo  
  73. #  
  74. # The mirror system uses the connecting IP address of the client and the  
  75. # update status of each mirror to pick mirrors that are updated to and  
  76. # geographically close to the client.  You should use this for CentOS updates  
  77. # unless you are manually picking other mirrors.  
  78. #  
  79. # If the mirrorlist= does not work for you, as a fall back you can try the  
  80. # remarked out baseurl= line instead.  
  81.   
  82. [base]  
  83. name=CentOS-$releasever - Base - mirrors.aliyun.com  
  84. failovermethod=priority  
  85. baseurl=http://mirrors.aliyun.com/centos/$releasever/os/$basearch/  
  86.         http://mirrors.aliyuncs.com/centos/$releasever/os/$basearch/  
  87. #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os  
  88. gpgcheck=1  
  89. gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-6  
  90.   
  91. #released updates  
  92. [updates]  
  93. name=CentOS-$releasever - Updates - mirrors.aliyun.com  
  94. failovermethod=priority  
  95. baseurl=http://mirrors.aliyun.com/centos/$releasever/updates/$basearch/  
  96.         http://mirrors.aliyuncs.com/centos/$releasever/updates/$basearch/  
  97. #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates  
  98. gpgcheck=1  
  99. gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-6  
  100.   
  101. #additional packages that may be useful  
  102. [extras]  
  103. name=CentOS-$releasever - Extras - mirrors.aliyun.com  
  104. failovermethod=priority  
  105. baseurl=http://mirrors.aliyun.com/centos/$releasever/extras/$basearch/  
  106.         http://mirrors.aliyuncs.com/centos/$releasever/extras/$basearch/# cd /etc/yum.repos.d/  
  107.   
  108.   
  109.   
  110. 5.查看6.7的readmew文件,还是有些表变化发现小版本不再进行更新  
  111. This directory (and version of CentOS) is deprecated.  For normal users,  
  112. you should use /6/ and not /6.7/ in your path. Please see this FAQ  
  113. concerning the CentOS release scheme:  
  114. If you know what you are doing, and absolutely want to remain at the 6.7  
  115. level, go to http://vault.centos.org/ for packages.   
  116.   
  117. Please keep in mind that 6.06.16.26.36.4 , 6.56.6 and 6.7 no longer gets any updates, norany security fix's..  
  118.   
  119. 根据repo文件变量的变化,可以修改repo文件把所有$releasever替换成6   
  120.   
  121.  执行替换操作  
  122.   
  123. #sed -i 's/\$releasever/6/' CentOS-Base.repo  
  124.   
  125.   
  126.   
  127. 6.清理并重新生成yum缓存  
  128.   
  129. # yum clean all  
  130. Loaded plugins: aliases, changelog, kabi, presto, product-id, refresh-packagekit, security, subscription-manager, tmprepo, verify, versionlock  
  131. This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.  
  132. Loading support for Red Hat kernel ABI  
  133. Cleaning repos: base extras updates  
  134. Cleaning up Everything  
  135. 0 delta-package files removed, by presto  
  136.   
  137.   
  138. 7.重新yum makecache  
  139.   
  140. # yum makecache  
  141. Loaded plugins: aliases, changelog, kabi, presto, product-id, refresh-packagekit, security, subscription-manager, tmprepo, verify, versionlock  
  142. This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.  
  143. Loading support for Red Hat kernel ABI  
  144. base                                           | 3.7 kB     00:00       
  145. base/group_gz                                  | 226 kB     00:00       
  146. base/filelists_db                              | 6.4 MB     00:01       
  147. base/primary_db                                | 4.7 MB     00:00       
  148. base/other_db                                  | 2.8 MB     00:00       
  149. extras                                         | 3.4 kB     00:00       
  150. extras/filelists_db                            |  25 kB     00:00       
  151. extras/prestodelta                             | 1.3 kB     00:00       
  152. extras/primary_db                              |  29 kB     00:00       
  153. extras/other_db                                |  30 kB     00:00       
  154. updates                                        | 3.4 kB     00:00       
  155. updates/filelists_db                           | 3.0 MB     00:00       
  156. updates/prestodelta                            | 145 kB     00:00       
  157. updates/primary_db                             | 4.7 MB     00:01       
  158. updates/other_db                               |  66 MB     00:26       
  159. Metadata Cache Created  
网上还有一个据说完善的方法,不过没有进行测试,有兴趣的同学可以测试一下
在所有mirrorlist前面加上#,并所有$releasever替换成6

sed -i '/mirrorlist/d' CentOS-Base.repo


sed -i 's/\$releasever/6/' CentOS-Base.repo


sed -i  '/\ [addons\]/,/^$/d' CentOS-Base.repo


sed-i 's/RPM-GPG-KEY-CentOS-5/RPM-GPG-KEY-CentOS-6/' CentOS-Base.repo

猜你喜欢

转载自blog.csdn.net/hknishi_zs/article/details/80625777
今日推荐