我们以centos6为范例演示

1、[root@Centos6 ~]# cd /etc/yum.repos.d/
[root@Centos6 yum.repos.d]# ls

CentOS-Base.repo CentOS-fasttrack.repo CentOS-Vault.repo
CentOS-Debuginfo.repo CentOS-Media.repo
先罗列出相关文件

2、[root@Centos6 yum.repos.d]# vim CentOS-Base.repo
# CentOS-Base.repo
#
# The mirror system uses the connecting IP address of the client and the
# update status of each mirror to pick mirrors that are updated to and
# geographically close to the client.  You should use this for CentOS updates
# unless you are manually picking other mirrors.
#
# If the mirrorlist= does not work for you, as a fall back you can try the
# remarked out baseurl= line instead.
#
#
[epel]
name=aliyun-epel
baseurl=https://mirrors.aliyun.com/epel/6/x86_64/
gpgcheck=0
gpgkey=https://mirrors.aliyun.com/epel/RPM-GPG-KEY-EPEL-6 [base]
name=CentOS-$releasever - Base
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os&infra=$infra
baseurl=https://mirrors.aliyun.com/centos/6/os/x86_64/
gpgcheck=0
gpgkey=https://mirrors.aliyun.com/centos/6/os/x86_64/RPM-GPG-KEY-CentOS-6  #released updates
[updates]
name=CentOS-$releasever - Updates
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates&infra=$infra
baseurl=https://mirrors.aliyun.com/centos/6/updates/x86_64/
gpgcheck=0
#gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras&infra=$infra
baseurl=https://mirrors.aliyun.com/centos/6/extras/x86_64/
gpgcheck=0
#gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus&infra=$infra
baseurl=https://mirrors.aliyun.com/centos/6/centosplus/x86_64/
gpgcheck=0
enabled=1
#gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6#contrib - packages by Centos Users
[contrib]
name=CentOS-$releasever - Contrib
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=contrib&infra=$infra
baseurl=https://mirrors.aliyun.com/centos/6/contrib/x86_64/
gpgcheck=0
enabled=1
#gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6

在https://opsx.alibaba.com/mirro中查询相关配置文件的路径

3、[root@Centos6 yum.repos.d]# yum clean all

Loaded plugins: fastestmirror, refresh-packagekit, security
Cleaning repos: base centosplus contrib epel extras updates
Cleaning up Everything
Cleaning up list of fastest mirrors
清除一下yum缓存

4、[root@Centos6 yum.repos.d]# yum repolist

Loaded plugins: fastestmirror, refresh-packagekit, security
Determining fastest mirrors
base | 3.7 kB 00:00
base/primary_db | 4.7 MB 00:00
centosplus | 3.4 kB 00:00
centosplus/primary_db | 1.7 MB 00:00
contrib | 2.9 kB 00:00
contrib/primary_db | 1.2 kB 00:00
epel | 4.7 kB 00:00
epel/primary_db | 6.0 MB 00:00
extras | 3.4 kB 00:00
extras/primary_db | 27 kB 00:00
updates | 3.4 kB 00:00
updates/primary_db | 3.0 MB 00:00
repo id repo name status
base CentOS-6 - Base 6,713
centosplus CentOS-6 - Plus 50
contrib CentOS-6 - Contrib 0
epel aliyun-epel 12,517
extras CentOS-6 - Extras 35
updates CentOS-6 - Updates 311
repolist: 19,626

5、此时表明yum源列表已生成,yum源已配好

我们就可以下载自己需要的东西了,示例如下:

[root@Centos6 yum.repos.d]# yum -y install lrzsz
Loaded plugins: fastestmirror, refresh-packagekit, security
Setting up Install Process
Loading mirror speeds from cached hostfile
Resolving Dependencies
--> Running transaction check
---> Package lrzsz.x86_64 0:0.12.20-27.1.el6 will be installed
--> Finished Dependency ResolutionDependencies Resolved=====================================================================Package     Arch         Version                   Repository  Size
=====================================================================
Installing:lrzsz       x86_64       0.12.20-27.1.el6          base        71 kTransaction Summary
=====================================================================
Install       1 Package(s)Total download size: 71 k
Installed size: 159 k
Downloading Packages:
lrzsz-0.12.20-27.1.el6.x86_64.rpm             |  71 kB     00:00
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running TransactionInstalling : lrzsz-0.12.20-27.1.el6.x86_64                     1/1 Verifying  : lrzsz-0.12.20-27.1.el6.x86_64                     1/1 Installed:lrzsz.x86_64 0:0.12.20-27.1.el6                                    Complete!

转载于:https://blog.51cto.com/14128387/2347672

配置本地及网络yum源(详细步骤)相关推荐

  1. linux yum安装分区工具,搭建本地和网络yum源、源码编译安装软件及磁盘分区管理...

    1.自建yum仓库,分别为网络源和本地源 1)挂载光盘镜像 [root@centos7 ~]#mount /dev/sr0 /mnt/ [root@centos7 ~]# df -h Filesyst ...

  2. 配置本地和共享yum源,定制属于自己的yum仓库

    使用yum安装软件 命令:####查看软件包yum list all ##列出yum源仓库里面的所有可用的安装包 yum list installed ##列出所有已经安装的安装包 yum list ...

  3. Linux笔记-配置本地光盘未yum源

    cd /etc/yum.repos.d/ vim CentOS-Media.repo 可知只要把光盘挂载到 /media/CentOS/ /media/cdrom/ /media/cdrecorder ...

  4. CentOS8 配置本地yum源详细教程

    CentOS8 配置本地yum源详细教程 1.创建目录 mkdir /mnt/cdrom 2.挂载你的cdrom文件 2.1光驱方式(我使用了这一种方式成功,在这里只介绍这种,其他方式就不介绍了,因为 ...

  5. Centos7配置yum源(本地yum源和阿里网络yum源)

    一.centos7配置yum源 yum源分为本地yum源和网络yum源 1.配置本地yum源 步骤一:在centos虚拟机中挂载光盘 1.创建挂载点目录 [root@localhost ~]# mkd ...

  6. linux配置本地YUM源及网络YUM源

    在使用Linux的日常工作中,经常会遇到缺少包的情况,而当我们单独下载缺少的包进行安装时,大多都会因为依赖或版本与操作系统版本不兼容的问题,这个时候配置yum就显得很有必要 配置yum源一般分两种情况 ...

  7. Centos7网络yum源配置,精简版

    配置网络yum源没有那么麻烦,不需要下载什么软件包之类,只需简单修改配置文件就可以了 一般的yum源都选自163或阿里的,我选的是163的源. 进入/etc/yum.repo.d目录,下面估计有好多r ...

  8. centos配置ADSL拨号 配置阿里云的yum源

    如果系统yum源有问题可以更改yum源 配置阿里云的yum源 1)下载repo文件 wget http://mirrors.aliyun.com/repo/Centos-7.repo (没有 wget ...

  9. Linux使用本地光盘制作yum源

    为什么要使用本地光盘制作yum源? 在系统不能联网的情况下,就需要我们在Linux系统下使用光盘制作yum源. 具体操作步骤如下: 1.挂载光盘. 2.删除/etc/yum.repos.d目录下的所有 ...

最新文章

  1. 春意袭人,春装网店大比拼!
  2. 最新版 | 2020李沐《动手学深度学习》
  3. 4行代码再现《黑客帝国》数字雨,在终端实现的那种
  4. idea 提示vue插件_Vue + SpringBoot + MyBatis 音乐网站
  5. python编写成绩及格不及格_python小练习:读入一个考试得分,判断这个分数是哪个等级,并输出,考虑异常场景...
  6. Linux 命令之 curl 的选项(英文版)
  7. android 时间控件使用,android 时间控件的使用
  8. 正则表达式与html信息提取,基于正则表达式的HTML信息提取.pdf
  9. linux下安装svn1.7
  10. mysql 修改最大连接数
  11. 出现红字是电脑问题吗_婚姻出现问题,生个孩子就能解决,这是真的吗?
  12. spring 4.0下集成webservice
  13. Oracle的方案(Schema)和用户(User)的区别
  14. Quartus II 13.1与Modelsim SE的安装
  15. 在 iOS 设备上安装和使用 OpenSSH
  16. Visual Studio vs软件下载 vax Visual Assist X VAssistX
  17. nginx反向代理进行统一鉴权
  18. 安装驱动时提示文件的哈希值不在指定的目录文件中
  19. 计算机毕业论文致谢,精选毕业论文致谢语6篇
  20. SVM-支持向量机算法(一)

热门文章

  1. 会返回两次_嫦娥五号为何用独特的半弹道式返回方式?原来有更深远的考虑……...
  2. xd可以用ui动效效果吗_通过动画使UI设计栩栩如生:Adobe XD和After Effects
  3. 什么?在 VSCode 里也能用 Postman了?
  4. 零基础学习 Python 之条件语句
  5. 17、【 商品管理模块开发】——后台商品图片的springmvc和富文本上传以及ftp文件服务器的开发...
  6. 一个在线编写前端代码的好玩的工具
  7. Jfinal 显示欢迎页 index.jsp
  8. Shell 脚本——测试命令
  9. asp.net 检测访问者是iphone,android,web(摘录)
  10. Excel VBA - Workbook对象