• 欢迎访问DBA的辛酸事儿,推荐使用最新版火狐浏览器和Chrome浏览器访问本网站
  • 欢迎大家关注博主公众号:DBA的辛酸事儿
  • 博文中若有错误的地方,请大家指正,大家的指正是我前进的动力

CentOS 7系统配置国内yum源和epel源

Linux SEian.G 5年前 (2019-02-23) 8778次浏览 已收录 0个评论

在日常的学习和工作中,经常要安装一些软件,但是如果仅是配置本地yum源的话,非常的局限,并且也无法做到在线升级或在线安装软件;

所以为了方便日常的学习和工作,我们来配置一下国内的yum源以及epel源(如果为了方便,大家使用云服务器就好了,这些都是配置好的!)

1、首先进入/etc/yum.repos.d/目录下,新建一个repo目录,用于保存系统中原来的repo文件

[root@wjq1 ~]# cd /etc/yum.repos.d/
[root@wjq1 yum.repos.d]# ll
drwxr-xr-x. 2 root root 187 Jun 12  2018 repo

2.在CentOS中配置使用网易和阿里的开源镜像

2、到阿里开源镜像站点下载系统对应版本的repo文件

[root@wjq1 yum.repos.d]# wget http://mirrors.aliyun.com/repo/Centos-7.repo
--2019-02-15 12:12:53--  http://mirrors.aliyun.com/repo/Centos-7.repo
Resolving proxy.tencent.com (proxy.tencent.com)... 10.1.156.88
Connecting to proxy.tencent.com (proxy.tencent.com)|10.1.156.88|:8080... connected.
Proxy request sent, awaiting response... 200 OK
Length: 2523 (2.5K) [application/octet-stream]
Saving to: ‘Centos-7.repo’

100%[==========================================================================================================>] 2,523       --.-K/s   in 0s      

2019-02-15 12:12:53 (67.6 MB/s) - ‘Centos-7.repo’ saved [2523/2523]

[root@wjq1 yum.repos.d]# ll
total 4
-rw-r--r--  1 root root 2523 Jun 16  2018 Centos-7.repo
drwxr-xr-x. 2 root root  217 Feb 15 12:14 repo

或者手动下载repo文件并上传到/etc/yum.repos.d/目录

阿里云开源镜像:阿里云开源镜像

3、清除系统yum缓存并生成新的yum缓存

[root@wjq1 yum.repos.d]# yum clean all   #清除系统所有的yum缓存
Loaded plugins: fastestmirror, langpacks
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


[root@wjq1 yum.repos.d]# yum makecache   # 生成yum缓存
Loaded plugins: fastestmirror, langpacks
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/12): base/7/x86_64/group_gz                                                                                               | 166 kB  00:00:00     
base/7/x86_64/primary_db       FAILED                                          
http://mirrors.cloud.aliyuncs.com/centos/7/os/x86_64/repodata/6614b3605d961a4aaec45d74ac4e5e713e517debb3ee454a1c91097955780697-primary.sqlite.bz2: [Errno 14] HTTP Error 504 - Gateway Timeout
Trying other mirror.
(2/12): extras/7/x86_64/filelists_db                                                                                         | 230 kB  00:00:00     
(3/12): extras/7/x86_64/primary_db                                                                                           | 179 kB  00:00:00     
(4/12): extras/7/x86_64/other_db                                                                                             | 117 kB  00:00:00     
(5/12): updates/7/x86_64/filelists_db                                                                                        | 1.9 MB  00:00:00     
(6/12): updates/7/x86_64/primary_db                                                                                          | 2.4 MB  00:00:00     
(7/12): base/7/x86_64/other_db                                                                                               | 2.6 MB  00:00:00     
(8/12): updates/7/x86_64/other_db                                                                                            | 331 kB  00:00:00     
(9/12): base/7/x86_64/primary_db                                                                                             | 6.0 MB  00:00:00     
base/7/x86_64/filelists_db     FAILED                                          
http://mirrors.aliyuncs.com/centos/7/os/x86_64/repodata/a0ec5a4708a1026db100d4799c404c9ed48a9371a4bab234a1355f86628a244a-filelists.sqlite.bz2: [Errno 14] HTTP Error 504 - Gateway Timeout
Trying other mirror.
extras/7/x86_64/prestodelta    FAILED                                          =========================-         ] 228 kB/s |  17 MB  00:00:17 ETA 
http://mirrors.aliyuncs.com/centos/7/extras/x86_64/repodata/6ddc7ed4f8b31ae5fe805eb71716d60413495a98094b0b2ef5a955d6c78ab1fd-prestodelta.xml.gz: [Errno 12] Timeout on http://mirrors.aliyuncs.com/centos/7/extras/x86_64/repodata/6ddc7ed4f8b31ae5fe805eb71716d60413495a98094b0b2ef5a955d6c78ab1fd-prestodelta.xml.gz: (28, 'Operation too slow. Less than 1000 bytes/sec transferred the last 30 seconds')
Trying other mirror.
(10/12): base/7/x86_64/filelists_db                                                                                          | 7.1 MB  00:00:00     
updates/7/x86_64/prestodelta   FAILED                                          
http://mirrors.aliyuncs.com/centos/7/updates/x86_64/repodata/84a6837c67a1e571dfd5c69e155c0d4c99dfddbe6777b062c15f956ac3c0ccdc-prestodelta.xml.gz: [Errno 12] Timeout on http://mirrors.aliyuncs.com/centos/7/updates/x86_64/repodata/84a6837c67a1e571dfd5c69e155c0d4c99dfddbe6777b062c15f956ac3c0ccdc-prestodelta.xml.gz: (28, 'Operation too slow. Less than 1000 bytes/sec transferred the last 30 seconds')
Trying other mirror.
(11/12): updates/7/x86_64/prestodelta                                                                                        | 333 kB  00:00:00     
(12/12): extras/7/x86_64/prestodelta                                                                                         |  47 kB  00:00:00     
Metadata Cache Created

4、安装epel源

[root@wjq1 yum.repos.d]# yum list | grep epel-release
epel-release.noarch                         7-11                       extras   

[root@wjq1 yum.repos.d]# yum install -y epel-release
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: mirrors.aliyun.com
 * extras: mirrors.aliyun.com
 * updates: mirrors.aliyun.com
Resolving Dependencies
--> Running transaction check
---> Package epel-release.noarch 0:7-11 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

====================================================================================================================================================
 Package                                 Arch                              Version                          Repository                         Size
====================================================================================================================================================
Installing:
 epel-release                            noarch                            7-11                             extras                             15 k

Transaction Summary
====================================================================================================================================================
Install  1 Package

Total download size: 15 k
Installed size: 24 k
Downloading packages:
warning: /var/cache/yum/x86_64/7/extras/packages/epel-release-7-11.noarch.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
Public key for epel-release-7-11.noarch.rpm is not installed
epel-release-7-11.noarch.rpm                                                                                                 |  15 kB  00:00:00     
Retrieving key from http://mirrors.aliyun.com/centos/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
 From       : http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : epel-release-7-11.noarch                                                                                                         1/1 
  Verifying  : epel-release-7-11.noarch                                                                                                         1/1 

Installed:
  epel-release.noarch 0:7-11                                                                                                                        

Complete!

# epel源安装成功,比原来多了一个epel.repo和epel-testing.repo文件
[root@wjq1 yum.repos.d]# ll
-rw-r--r--  1 root root 2523 Jun 16  2018 Centos-7.repo
-rw-r--r--  1 root root  951 Oct  3  2017 epel.repo
-rw-r--r--  1 root root 1050 Oct  3  2017 epel-testing.repo
drwxr-xr-x. 2 root root  217 Feb 15 12:14 repo

5、使用阿里开源镜像提供的epel源

[root@wjq1 yum.repos.d]# wget -O /etc/yum.repos.d/epel-7.repo http://mirrors.aliyun.com/repo/epel-7.repo
--2019-02-15 12:24:15--  http://mirrors.aliyun.com/repo/epel-7.repo
Resolving proxy.tencent.com (proxy.tencent.com)... 10.1.156.88
Connecting to proxy.tencent.com (proxy.tencent.com)|10.1.156.88|:8080... connected.
Proxy request sent, awaiting response... 200 OK
Length: 664 [application/octet-stream]
Saving to: ‘/etc/yum.repos.d/epel-7.repo’

100%[==========================================================================================================>] 664         --.-K/s   in 0s      

2019-02-15 12:24:16 (1.33 MB/s) - ‘/etc/yum.repos.d/epel-7.repo’ saved [664/664]

[root@wjq1 yum.repos.d]# ll
total 16
-rw-r--r--  1 root root 2523 Jun 16  2018 Centos-7.repo
-rw-r--r--  1 root root  664 May 11  2018 epel-7.repo
-rw-r--r--  1 root root  951 Oct  3  2017 epel.repo
-rw-r--r--  1 root root 1050 Oct  3  2017 epel-testing.repo
drwxr-xr-x. 2 root root  217 Feb 15 12:14 repo

6、再次清除系统yum缓存,并重新生成新的yum缓存

[root@wjq1 yum.repos.d]# yum clean all
Loaded plugins: fastestmirror, langpacks
Repository epel is listed more than once in the configuration
Repository epel-debuginfo is listed more than once in the configuration
Repository epel-source is listed more than once in the configuration
Cleaning repos: base epel 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@wjq1 yum.repos.d]# yum makecache
Loaded plugins: fastestmirror, langpacks
Repository epel is listed more than once in the configuration
Repository epel-debuginfo is listed more than once in the configuration
Repository epel-source is listed more than once in the configuration
Determining fastest mirrors
 * base: mirrors.aliyun.com
 * extras: mirrors.aliyun.com
 * updates: mirrors.aliyun.com
base                                                                                                                         | 3.6 kB  00:00:00     
epel                                                                                                                         | 4.7 kB  00:00:00     
extras                                                                                                                       | 3.4 kB  00:00:00     
updates                                                                                                                      | 3.4 kB  00:00:00     
(1/18): base/7/x86_64/group_gz                                                                                               | 166 kB  00:00:00     
(2/18): base/7/x86_64/filelists_db                                                                                           | 7.1 MB  00:00:01     
(3/18): epel/x86_64/group_gz                                                                                                 |  88 kB  00:00:00     
(4/18): base/7/x86_64/other_db                                                                                               | 2.6 MB  00:00:00     
(5/18): epel/x86_64/updateinfo                                                                                               | 959 kB  00:00:00     
(6/18): epel/x86_64/prestodelta                                                                                              | 4.6 kB  00:00:00     
(7/18): base/7/x86_64/primary_db                                                                                             | 6.0 MB  00:00:01     
(8/18): epel/x86_64/primary_db                                                                                               | 6.6 MB  00:00:01     
(9/18): epel/x86_64/filelists_db                                                                                             |  11 MB  00:00:02     
(10/18): extras/7/x86_64/prestodelta                                                                                         |  47 kB  00:00:00     
(11/18): extras/7/x86_64/filelists_db                                                                                        | 230 kB  00:00:00     
(12/18): extras/7/x86_64/primary_db                                                                                          | 179 kB  00:00:00     
(13/18): extras/7/x86_64/other_db                                                                                            | 117 kB  00:00:00     
(14/18): updates/7/x86_64/prestodelta                                                                                        | 333 kB  00:00:00     
(15/18): epel/x86_64/other_db                                                                                                | 3.2 MB  00:00:00     
(16/18): updates/7/x86_64/filelists_db                                                                                       | 1.9 MB  00:00:00     
(17/18): updates/7/x86_64/other_db                                                                                           | 331 kB  00:00:00     
(18/18): updates/7/x86_64/primary_db                                                                                         | 2.4 MB  00:00:00     
Metadata Cache Created

7、查看系统可用的yum源和所有的yum源

CentOS 7系统配置国内yum源和epel源CentOS 7系统配置国内yum源和epel源
到这里,国内的yum源和epel源就配置好了,下面就可以安装软件了,很方便的哦。。。

CentOS 7系统配置国内yum源和epel源


如果您觉得本站对你有帮助,那么可以收藏和推荐本站,帮助本站更好地发展,在此谢过各位网友的支持。
转载请注明原文链接:CentOS 7系统配置国内yum源和epel源
喜欢 (4)
SEian.G
关于作者:
用心去记录工作,用心去感受生活,用心去学着成长;座右铭:苦练七十二变,笑对八十一难
发表我的评论
取消评论

表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址