服务器之家:专注于VPS、云服务器配置技术及软件下载分享
分类导航

Linux|Centos|Ubuntu|系统进程|Fedora|注册表|Bios|Solaris|Windows7|Windows10|Windows11|windows server|

服务器之家 - 服务器系统 - Centos - CentOS7配置阿里云yum源的方法代码

CentOS7配置阿里云yum源的方法代码

2022-07-21 08:55石志远 Centos

这篇文章主要介绍了CentOS7配置阿里云yum源的方法代码,小编觉得挺不错的,现在分享给大家,也给大家做个参考。一起跟随小编过来看看吧

打开centos的yum文件夹

输入命令cd /etc/yum.repos.d/

用wget下载repo文件

输入命令wget http://mirrors.aliyun.com/repo/Centos-7.repo

如果wget命令不生效,说明还没有安装wget工具,输入yum -y install wget 回车进行安装。

当前目录是/etc/yum.repos.d/,刚刚下载的Centos-7.repo也在这个目录上

备份

?
1
2
3
4
5
[root@bogon ~]# cd /etc/yum.repos.d/
[root@bogon yum.repos.d]# mkdir repo_bak
[root@bogon yum.repos.d]# mv *.repo repo_bak/
[root@bogon yum.repos.d]# ls
repo_bak

下载新的CentOS-Base.repo 到/etc/yum.repos.d/

?
1
wget -O /etc/yum.repos.d/CentOS-Base.repo
?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
[root@bogon yum.repos.d]# wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
--2018-02-09 16:33:46-- http://mirrors.aliyun.com/repo/Centos-7.repo
Resolving mirrors.aliyun.com (mirrors.aliyun.com)... 124.14.2.234, 124.14.2.235, 124.14.2.217, ...
Connecting to mirrors.aliyun.com (mirrors.aliyun.com)|124.14.2.234|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 2573 (2.5K) [application/octet-stream]
Saving to: ‘/etc/yum.repos.d/CentOS-Base.repo'
 
100%[========================================================================================>] 2,573    --.-K/s  in 0s  
 
2018-02-09 16:33:47 (182 MB/s) - ‘/etc/yum.repos.d/CentOS-Base.repo' saved [2573/2573]
 
[root@bogon yum.repos.d]# ls
CentOS-Base.repo repo_bak

之后运行yum clean all 清除缓存,运行 yum makecache 生成新的缓存

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
[root@bogon yum.repos.d]# yum clean all
Loaded plugins: fastestmirror
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@bogon yum.repos.d]# yum makecache
Loaded plugins: fastestmirror
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                                       | 156 kB 00:00:00  
(2/12): extras/7/x86_64/filelists_db                                    | 636 kB 00:00:07  
(3/12): extras/7/x86_64/primary_db

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持服务器之家。

原文链接:https://segmentfault.com/a/1190000016356979

延伸 · 阅读

精彩推荐