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 

相关文章
|
7月前
|
应用服务中间件 Linux 网络安全
Centos 8.0中Nginx配置文件和https正书添加配置
这是一份Nginx配置文件,包含HTTP与HTTPS服务设置。主要功能如下:1) 将HTTP(80端口)请求重定向至HTTPS(443端口),增强安全性;2) 配置SSL证书,支持TLSv1.1至TLSv1.3协议;3) 使用uWSGI与后端应用通信(如Django);4) 静态文件托管路径设为`/root/code/static/`;5) 定制错误页面(404、50x)。适用于Web应用部署场景。
777 87
|
3月前
|
安全 关系型数据库 MySQL
CentOS 7 yum 安装 MySQL教程
在CentOS 7上安装MySQL 8,其实流程很清晰。首先通过官方Yum仓库来安装服务,然后启动并设为开机自启。最重要的环节是首次安全设置:需要先从日志里找到临时密码来登录,再修改成你自己的密码,并为远程连接创建用户和授权。最后,也别忘了在服务器防火墙上放行3306端口,这样远程才能连上。
690 16
|
5月前
|
存储 Linux Apache
在CentOS上配置SVN至Web目录的自动同步
通过上述配置,每次当SVN仓库中提交新的更改时,`post-commit`钩子将被触发,SVN仓库的内容会自动同步到指定的Web目录,从而实现代码的连续部署。
198 16
|
5月前
|
NoSQL 安全 Linux
设置Redis在CentOS7上的自启动配置
这些步骤总结了在CentOS 7系统上设置Redis服务自启动的过程。这些命令提供了一个直接且明了的方式,确保Redis作为关键组件在系统启动时能自动运行,保障了依赖于Redis服务的应用的稳定性和可用性。
506 9
|
7月前
|
Linux
Centos6配置阿里云yum源报错
在CentOS 6配置阿里云Yum源时,可能出现EPEL仓库访问报错(404 Not Found)。解决方法:编辑`/etc/yum.repos.d/epel.repo`文件,将`enabled`和`gpgcheck`参数设为0 ``` 此设置可解决仓库无法访问的问题。
1731 29
|
7月前
|
Ubuntu 安全 Linux
CentOS与Ubuntu中防火墙配置命令集汇
有了这些,你就能遨游在 CentOS 和 Ubuntu 的海洋中,频繁地改变你的防火墙设置,快速地应对各种安全威胁,同时也能保证你的系统可以正常工作。出发吧,勇敢的编程者,随着这些命令集的涌动,扬帆起航,走向安全的网络世界!
248 5
|
8月前
|
关系型数据库 MySQL Linux
CentOS 7系统下详细安装MySQL 5.7的步骤:包括密码配置、字符集配置、远程连接配置
以上就是在CentOS 7系统下安装MySQL 5.7的详细步骤。希望这个指南能帮助你顺利完成安装。
2108 26
|
8月前
|
安全 Linux 网络安全
在Linux(CentOS和AWS)上安装更新的git2的方法并配置github-ssh
经过以上这些步骤,你现在就能在GitHub上顺利往返,如同海洋中的航海者自由驰骋。欢迎你加入码农的世界,享受这编程的乐趣吧!
381 10
|
10月前
|
缓存 Ubuntu Linux
Linux中yum、rpm、apt-get、wget的区别,yum、rpm、apt-get常用命令,CentOS、Ubuntu中安装wget
通过本文,我们详细了解了 `yum`、`rpm`、`apt-get`和 `wget`的区别、常用命令以及在CentOS和Ubuntu中安装 `wget`的方法。`yum`和 `apt-get`是高层次的包管理器,分别用于RPM系和Debian系发行版,能够自动解决依赖问题;而 `rpm`是低层次的包管理工具,适合处理单个包;`wget`则是一个功能强大的下载工具,适用于各种下载任务。在实际使用中,根据系统类型和任务需求选择合适的工具,可以大大提高工作效率和系统管理的便利性。
1186 25
下一篇