Centos7配置国内yum源和epel源

简介: Centos7配置国内yum源和epel源

前言:下载几个国内yum源和epel源即可完成大部分软件的安装,可省去大部分时间


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


[root@caq ~]# cd /etc/yum.repos.d/
[root@caq yum.repos.d]# mkdir repo_bak
[root@caq yum.repos.d]# mv *.repo repo_bak/


2.在CentOS中配置使用网易和阿里的开源镜像 到网易和阿里开源镜像站点下载系统对应版本的repo文件


[root@caq yum.repos.d]# wget http://mirrors.aliyun.com/repo/Centos-7.repo
[root@caq yum.repos.d]# wget http://mirrors.163.com/.help/CentOS7-Base-163.repo
[root@caq yum.repos.d]# ls
Centos-7.repo  CentOS-Base-163.repo  repo.bak


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

[root@caq yum.repos.d]# ls      # 列出/etc/yum.repos.d/目录下的文件
Centos-7.repo  CentOS-Base-163.repo  repo.bak
[root@caq yum.repos.d]# yum clean all   # 清除系统所有的yum缓存
Loaded plugins: fastestmirror, langpacks
Repository base is listed more than once in the configuration
Repository updates is listed more than once in the configuration
Repository extras is listed more than once in the configuration
Repository centosplus is listed more than once in the configuration
Cleaning repos: base extras updates
Cleaning up everything
Cleaning up list of fastest mirrors
[root@caq yum.repos.d]# yum makecache   # 生成yum缓存
Loaded plugins: fastestmirror, langpacks
Repository base is listed more than once in the configuration
Repository updates is listed more than once in the configuration
Repository extras is listed more than once in the configuration
Repository centosplus is listed more than once in the configuration
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/filelists_db                                                    | 6.7 MB  00:00:02     
(2/12): base/7/x86_64/group_gz                                                        | 156 kB  00:00:02     
(3/12): base/7/x86_64/other_db                                                        | 2.5 MB  00:00:01     
(4/12): base/7/x86_64/primary_db                                                      | 5.7 MB  00:00:02     
(5/12): extras/7/x86_64/prestodelta                                                   |  51 kB  00:00:01     
(6/12): extras/7/x86_64/filelists_db                                                  | 494 kB  00:00:02     
(7/12): extras/7/x86_64/other_db                                                      |  86 kB  00:00:00     
(8/12): extras/7/x86_64/primary_db                                                    | 130 kB  00:00:01     
(9/12): updates/7/x86_64/prestodelta                                                  | 406 kB  00:00:01     
(10/12): updates/7/x86_64/filelists_db                                                | 2.1 MB  00:00:01     
(11/12): updates/7/x86_64/other_db                                                    | 354 kB  00:00:00     
(12/12): updates/7/x86_64/primary_db                                                  | 3.6 MB  00:00:01     
Determining fastest mirrors
Metadata Cache Created


4.安装epel源


[root@caq yum.repos.d]# yum list | grep epel-release
Repository base is listed more than once in the configuration
Repository updates is listed more than once in the configuration
Repository extras is listed more than once in the configuration
Repository centosplus is listed more than once in the configuration
epel-release.noarch                         7-9                        extras   
[root@caq yum.repos.d]# yum install -y epel-release
Loaded plugins: fastestmirror, langpacks
Repository base is listed more than once in the configuration
Repository updates is listed more than once in the configuration
Repository extras is listed more than once in the configuration
Repository centosplus is listed more than once in the configuration
Loading mirror speeds from cached hostfile
Resolving Dependencies
--> Running transaction check
---> Package epel-release.noarch 0:7-9 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
=============================================================================================================
 Package                       Arch                    Version                 Repository               Size
=============================================================================================================
Installing:
 epel-release                  noarch                  7-9                     extras                   14 k
Transaction Summary
=============================================================================================================
Install  1 Package
Total download size: 14 k
Installed size: 24 k
Downloading packages:
epel-release-7-9.noarch.rpm                                                           |  14 kB  00:00:00     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : epel-release-7-9.noarch                                                                   1/1 
  Verifying  : epel-release-7-9.noarch                                                                   1/1 
Installed:
  epel-release.noarch 0:7-9                                                                                  
Complete!
[root@caq yum.repos.d]# ls      # epel源安装成功,比原来多了一个epel.repo和epel-testing.repo文件
Centos-7.repo  CentOS-Base-163.repo  epel.repo  epel-testing.repo  repo.bak

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


[root@caq yum.repos.d]# wget -O /etc/yum.repos.d/epel-7.repo http://mirrors.aliyun.com/repo/epel-7.repo    # 下载阿里开源镜像的epel源文件
--2018-03-08 20:22:14--  http://mirrors.aliyun.com/repo/epel-7.repo
Resolving mirrors.aliyun.com (mirrors.aliyun.com)... 183.2.199.237, 113.96.109.95, 113.96.109.93, ...
Connecting to mirrors.aliyun.com (mirrors.aliyun.com)|183.2.199.237|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 1084 (1.1K) [application/octet-stream]
Saving to: ‘/etc/yum.repos.d/epel-7.repo’
100%[=================================================================================================>] 1,084       --.-K/s   in 0s      
2018-03-08 20:22:14 (130 MB/s) - ‘/etc/yum.repos.d/epel-7.repo’ saved [1084/1084]
[root@caq yum.repos.d]# ls
CentOS7-Base-163.repo  Centos-7.repo  epel-7.repo  epel.repo  epel-testing.repo  repo_bak

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


[root@caq yum.repos.d]# yum clean all
Loaded plugins: fastestmirror, langpacks
Repository base is listed more than once in the configuration
Repository updates is listed more than once in the configuration
Repository extras is listed more than once in the configuration
Repository centosplus is listed more than once in the configuration
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
Cleaning up list of fastest mirrors
[root@caq yum.repos.d]# yum makecache
Loaded plugins: fastestmirror, langpacks
Repository base is listed more than once in the configuration
Repository updates is listed more than once in the configuration
Repository extras is listed more than once in the configuration
Repository centosplus is listed more than once in the configuration
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
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                                                                                      | 156 kB  00:00:01     
(2/18): base/7/x86_64/filelists_db                                                                                  | 6.7 MB  00:00:07     
(3/18): base/7/x86_64/primary_db                                                                                    | 5.7 MB  00:00:06     
(4/18): epel/x86_64/group_gz                                                                                        | 266 kB  00:00:01     
(5/18): epel/x86_64/updateinfo                                                                                      | 899 kB  00:00:02     
(6/18): epel/x86_64/prestodelta                                                                                     | 7.1 kB  00:00:00     
(7/18): base/7/x86_64/other_db                                                                                      | 2.5 MB  00:00:05     
(8/18): epel/x86_64/primary_db                                                                                      | 6.3 MB  00:00:04     
(9/18): extras/7/x86_64/filelists_db                                                                                | 636 kB  00:00:00     
(10/18): extras/7/x86_64/primary_db                                                                                 | 166 kB  00:00:00     
(11/18): extras/7/x86_64/other_db                                                                                   | 108 kB  00:00:00     
(12/18): extras/7/x86_64/prestodelta                                                                                | 102 kB  00:00:01     
(13/18): epel/x86_64/other_db                                                                                       | 3.0 MB  00:00:01     
(14/18): epel/x86_64/filelists_db                                                                                   |  10 MB  00:00:09     
(15/18): updates/7/x86_64/filelists_db                                                                              | 3.5 MB  00:00:02     
(16/18): updates/7/x86_64/prestodelta                                                                               | 771 kB  00:00:02     
(17/18): updates/7/x86_64/other_db                                                                                  | 621 kB  00:00:00     
(18/18): updates/7/x86_64/primary_db                                                                                | 6.0 MB  00:00:03     
Determining fastest mirrors
 * epel: mirrors.aliyun.com
Metadata Cache Created

7. 测试安装


[root@caq yum.repos.d]# yum install -y nginx
Loaded plugins: fastestmirror
Repository base is listed more than once in the configuration
Repository updates is listed more than once in the configuration
Repository extras is listed more than once in the configuration
Repository centosplus is listed more than once in the configuration
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
Loading mirror speeds from cached hostfile
Package 1:nginx-1.20.1-2.el7.x86_64 already installed and latest version
Nothing to do

相关文章
|
19天前
|
消息中间件 Linux API
centos7 安装rabbitmq自定义版本及配置
centos7 安装rabbitmq自定义版本及配置
|
18天前
|
弹性计算 关系型数据库 MySQL
centos7 mysql安装及配置
本文详细介绍了在阿里云服务器ECS上通过yum源安装MySQL 8.0.12的过程,包括更新yum源、下载并安装MySQL源、解决安装过程中可能遇到的问题等步骤。此外,还介绍了如何启动MySQL服务、设置开机自启、配置登录密码、添加远程登录用户以及处理远程连接异常等问题。适合初学者参考,帮助快速搭建MySQL环境。
95 8
centos7 mysql安装及配置
|
14天前
|
Linux
CentOS 7.x时间同步服务chrony配置详解
文章详细介绍了在CentOS 7.x系统中如何安装和配置chrony服务,以及它与ntpd服务的对比,强调了chrony在时间同步方面的高效性和准确性。
30 1
CentOS 7.x时间同步服务chrony配置详解
|
27天前
|
Ubuntu 网络协议 Linux
liunx各大发行版(centos,rocky,ubuntu,国产麒麟kylinos)网卡配置和包管理方面的区别
本文对比了Linux主要发行版CentOS、Rocky Linux、Ubuntu及国产Kylin在网卡配置与包管理上的差异。
124 1
|
1月前
|
Linux 开发工具
成功解决:CentOS 7中如何配置修改Vim
这篇文章介绍了如何在CentOS 7系统中配置和修改Vim编辑器的设置。文章首先指导读者如何检查Vim是否已经安装,如果未安装完全,提供了安装Vim的命令。接着,文章详细说明了如何编辑`/etc/vimrc`文件来配置Vim,包括设置显示行号、显示当前模式、光标位置信息、自动缩进和语法高亮等。最后,文章通过对比展示了配置前后使用vi和vim打开相同文本的效果差异,强调了Vim配置后的优势。
成功解决:CentOS 7中如何配置修改Vim
|
16天前
|
Linux
centos使用阿里的yum源
centos使用阿里的yum源
|
28天前
|
缓存 Linux 网络安全
解决 CentOS 7 官方 yum 仓库无法使用的最佳实践
【8月更文挑战第18天】若 CentOS 7 的官方 YUM 仓库无法使用,可按以下步骤解决: 1. **检查网络连接**: - 确认服务器能正常上网,可通过访问外部网站或网络诊断测试。 - 检查防火墙设置,避免其阻挡 YUM 的网络访问。 2. **检查 YUM 配置**: - 核实 `/etc/yum.repos.d/` 下的 `CentOS-Base.repo` 文件中仓库地址正确无误。 - 确认配置文件内的 `enabled` 选项设为 `1` 以启用仓库。
345 0
|
1月前
|
Linux Docker 容器
在CentOS操作系统上使用yum安装/使用/卸载Docker容器引擎
在CentOS操作系统上安装、配置、使用和卸载Docker容器引擎的详细步骤,包括配置Docker镜像加速的方法。
155 0
|
1月前
|
安全 Java 应用服务中间件
如何通过 Yum 在 CentOS 7 上安装 Apache Tomcat 7
如何通过 Yum 在 CentOS 7 上安装 Apache Tomcat 7
77 0
|
1月前
|
网络协议 Linux 网络安全
Hyper-v 如何配置 Centos7 虚拟机网络?
Hyper-v 如何配置 Centos7 虚拟机网络?