下面来示范一下如何使用光盘文件配置yum库。注意:一定要把/etc/yum.repos.d里的其他文件移到其他地方,否则会报错

  1. 进入到/etc/yum.repos.d目录中后创建Yum配置文件:
  2. [root@linuxprobe ~]# cd /etc/yum.repos.d/
  3. [root@linuxprobe yum.repos.d]# vim rhel7.repo
  4. [rhel7]
  5. name=rhel7
  6. baseurl=file:///media/cdrom
  7. enabled=1
  8. gpgcheck=0
  9. [root@linuxprobe yum.repos.d]# mkdir -p /media/cdrom
  10. [root@linuxprobe yum.repos.d]# mount /dev/cdrom /media/cdrom //挂载
  11. mount: /dev/sr0 is write-protected, mounting read-only
  12. [root@linuxprobe yum.repos.d]# vim /etc/fstab //开机自动挂载
  13. /dev/cdrom /media/cdrom iso9660 defaults 0 0

配置好之后,可以使用yum list查看是否配置成功,如果配置成功会显示一堆可用的安装包。如果有报错的话,可以试着把除了这个配置文件外的其他配置文件全部删除(因为其他文件可能都是需要联网的,一旦连不了网,yum list 好像就会异常中断了)

下面这些是关于yum配置文件的介绍,有兴趣可以看一下
yum主配置文件

  1. [root@bogon ~]# cat /etc/yum.conf
  2. [main] //所有仓库公共的配置
  3. cachedir=/var/cache/yum/$basearch/$releasever //缓存目录
  4. keepcache=0 //程序包在安装完成后不再保存至缓存中
  5. debuglevel=2 // 程序安装时的输出信息,数字越大输出信息越多。生产环境中关闭最好,但是开启可以让我们快速定位安装中出现问题的所在
  6. logfile=/var/log/yum.log //日志路径
  7. exactarch=1 //安装程序的版本和当前平台保持一致
  8. obsoletes=1 //检查包已被废弃
  9. gpgcheck=1 //检查源合法性和包的完整性
  10. plugins=1 //支持插件
  11. installonly_limit=5 //每次安装包的数量限制为5个
  12. bugtracker_url=http://bugs.centos.org/set_project.php?project_id=23&ref=http://bugs.centos.org/bug_report_page.php?category=yum //bug追踪的路径
  13. distroverpkg=centos-release //判断当前系统信息
  14. # This is the default, if you make this bigger yum won't see if the metadata
  15. # is newer on the remote and so you'll "gain" the bandwidth of not having to
  16. # download the new metadata and "pay" for it by yum not having correct
  17. # information.
  18. # It is esp. important, to have correct metadata, for distributions like
  19. # Fedora which don't keep old packages around. If you don't like this checking
  20. # interupting your command line usage, it's much better to have something
  21. # manually check the metadata once an hour (yum-updatesd will do this).
  22. # metadata_expire=90m
  23. # PUT YOUR REPOS HERE OR IN separate files named file.repo
  24. # in /etc/yum.repos.d
  25. [root@bogon ~]#

各配置文件

  1. [root@bogon ~]# ls /etc/yum.repos.d/
  2. CentOS-Base.repo CentOS-Debuginfo.repo CentOS-Media.repo CentOS-Vault.repo
  3. CentOS-CR.repo CentOS-fasttrack.repo CentOS-Sources.repo
  4. [root@bogon ~]# cat /etc/yum.repos.d/CentOS-Media.repo
  5. # CentOS-Media.repo
  6. #
  7. # This repo can be used with mounted DVD media, verify the mount point for
  8. # CentOS-7. You can use this repo and yum to install items directly off the
  9. # DVD ISO that we release.
  10. #
  11. # To use this repo, put in your DVD and use it with the other repos too:
  12. # yum --enablerepo=c7-media [command]
  13. #
  14. # or for ONLY the media repo, do this:
  15. #
  16. # yum --disablerepo=\* --enablerepo=c7-media [command]
  17. [c7-media]
  18. name=CentOS-$releasever - Media
  19. baseurl=file:///media/CentOS/
  20. file:///media/cdrom/
  21. file:///media/cdrecorder/
  22. gpgcheck=1
  23. enabled=0 //此仓库不被使用
  24. gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
  25. [root@bogon ~]#
  26. [root@bogon ~]# cat /etc/yum.repos.d/CentOS-Base.repo
  27. # CentOS-Base.repo
  28. #
  29. # The mirror system uses the connecting IP address of the client and the
  30. # update status of each mirror to pick mirrors that are updated to and
  31. # geographically close to the client. You should use this for CentOS updates
  32. # unless you are manually picking other mirrors.
  33. #
  34. # If the mirrorlist= does not work for you, as a fall back you can try the
  35. # remarked out baseurl= line instead.
  36. #
  37. #
  38. [base]
  39. name=CentOS-$releasever - Base
  40. mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os&infra=$infra
  41. #baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/
  42. gpgcheck=1
  43. gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
  44. #released updates
  45. [updates]
  46. name=CentOS-$releasever - Updates
  47. mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates&infra=$infra
  48. #baseurl=http://mirror.centos.org/centos/$releasever/updates/$basearch/
  49. gpgcheck=1
  50. gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
  51. #additional packages that may be useful
  52. [extras]
  53. name=CentOS-$releasever - Extras
  54. mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras&infra=$infra
  55. #baseurl=http://mirror.centos.org/centos/$releasever/extras/$basearch/
  56. gpgcheck=1
  57. gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
  58. #additional packages that extend functionality of existing packages
  59. [centosplus]
  60. name=CentOS-$releasever - Plus
  61. mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus&infra=$infra
  62. #baseurl=http://mirror.centos.org/centos/$releasever/centosplus/$basearch/
  63. gpgcheck=1
  64. enabled=0
  65. gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
  66. [root@bogon ~]#

yum -y install httpd 自动确认安装httpd
yum list //列出全部程序包

yum源更换为本地光盘的更多相关文章

  1. 超简单将Centos的yum源更换为国内的阿里云源

    自己的yum源不知道什么时候给改毁了……搜到了个超简单的方法将yum源更换为阿里的源 完全参考 http://mirrors.aliyun.com/help/centos?spm=5176.bbsr1 ...

  2. CentOS7 中把默认yum源更换成163源

    163源是目前国内最好用的源,速度是相当快的,现在我们把CentOS7中的源改为163源 1.进入yum源配置文件 cd /etc/yum.repos.d 2.备份一下当前的源,以防出错后可以还原回来 ...

  3. 【转载】将Centos的yum源更换为国内的阿里云源

    自己的yum源不知道什么时候给改毁了--搜到了个超简单的方法将yum源更换为阿里的源 完全参考 http://mirrors.aliyun.com/help/centos?spm=5176.bbsr1 ...

  4. centos下将系统预置yum源更换为阿里云源

    参考:http://mirrors.aliyun.com/help/centos?spm=5176.bbsr150321.0.0.d6ykiD 步骤1:备份/etc/yum.repos.d/下的Cen ...

  5. linux替换yum源及配置本地源

    linux系统安装后自带的bash源由于在国外,安装软件包的时候会非常慢,最好替换一下yum源. ​关于yum源的简单介绍 ​           yum的主要功能是更方便地添加,删除和更新rpmba ...

  6. VMware Linux虚拟机yum源更换成国内阿里源

    [虚拟机系统] Centos 6.8 阿里源:https://opsx.alibaba.com/mirror 网易源:http://mirrors.163.com/ 更换yum源时请保证虚拟机和外网是 ...

  7. centos7 阿里云yum源更换

    个人比较喜欢阿里云yum源,同时使用centos7 首先 cd /etc/yum.repos.d/ wget -O /etc/yum.repos.d/CentOS-Base.repo http://m ...

  8. 将Centos的yum源更换为国内的阿里云源

    阿里云是最近新出的一个镜像源.得益于阿里云的高速发展,这么大的需求,肯定会推出自己的镜像源.阿里云Linux安装镜像源地址:http://mirrors.aliyun.com/ CentOS系统更换软 ...

  9. 将Centos的yum源更换为阿里云源

    阿里云Linux安装软件镜像源 阿里云是最近新出的一个镜像源.得益与阿里云的高速发展,这么大的需求,肯定会推出自己的镜像源.阿里云Linux安装镜像源地址:http://mirrors.aliyun. ...

随机推荐

  1. 简单选择排序(Simple Selection Sort)

    body, table{font-family: 微软雅黑; font-size: 13.5pt} table{border-collapse: collapse; border: solid gra ...

  2. 类型重命名 typedef

    所谓数据重命名就是给数据类型起一个新的名字,比如int 这个数据类型,可以给他起一个新的名字叫 my int.他俩的用法.特点.属性等是一模一样,仅仅名字不同而已. 作用:1,增加代码的可读性.2,让 ...

  3. main.jsbundle 脱离掉本地服务

    我们在本地调试的时候,可以使用index.js来开启本地服务,在局域网内运行app. 但是你会发现一旦你脱离了这个局域网就会造成app无法显示 这时候我们使用main.jsbundle 1.在Reac ...

  4. AngularJs和Vue比较

    http://jimhoskins.com/2012/12/17/angularjs-and-apply.html

  5. opencv3.0+vs2013安装记录

    为了能够更好的学习图像,我觉得opencv是一个必不可少的库,因此在以后的研究上使用opencv作为研究工具,与大家共同进步. 话归正题:先搭建opencv的环境. 1.下载安装包3.0 a,官网打开 ...

  6. h5视频配置

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...

  7. .tar.gz 和.tgz 解压

    wget   {url} 下载 eg: wget http://mirrors.tuna.tsinghua.edu.cn/apache/tomcat/tomcat-8/v8.5.24/bin/apac ...

  8. 从原理上理解如何由震源机制一个节面的解:strike,dip,rake可以求出另一个节面的解

    首先,需要回到最原始的地震矩的表达式: 已知strike,dip,rake 根据strike和dip可以求出v,根据strike,dip,rake,可以求出u. 把求出来的v和u互换,相当于原来的位错 ...

  9. Python 基础的应用day2

    1 用户交互input,将用户输入的内容赋值给 name 变量 后只能是字符串str.      区别2和3: ps :python2:raw_input python3:input 例 :1 nam ...

  10. shell 批量计算MD5值

    #!/bin/sh #需要计算MD5文件列表 # list=`ls` list="file list" for file in $list do file1=`` echo &qu ...