redhat配置yum源

方法1:
   
1.把redhat镜像ISO上传到服务器/root(可任意目录,以后不要更改目录)
  使用SecureFXPortable软件上传镜像
2.mkdir /yum   在/ 下新建yum目录,用于挂载ISO文件
3.修改yum配置文件(修改前先备份配置文件):
  cp /etc/yum.repos.d/rhel-source.repo /etc/yum.repos.d/rhel-source.repo.bak
  vi /etc/yum.repos.d/rhel-source.repo
    [rhel-source]  ---(仓库名称)
    name=cdrom     ---(名称随意)
    baseurl=file:///yum            -- (这个就是你要挂在的本地目录)
    enabled=1
    gpgcheck=0
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release


    [rhel-source-beta]
    name=Red Hat Enterprise Linux $releasever Beta - $basearch - Source
    baseurl=ftp://ftp.redhat.com/pub/redhat/linux/beta/$releasever/en/os/SRPMS/
    enabled=0
    gpgcheck=1
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-beta,file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
4.修改yum.conf文件,相同选项尽量保持一致
  vi /etc/yum.conf
    [rhel-source]   ---(仓库名称,尽量保持一致)
    name=cdrom      ---(尽量保持一致)
    baseurl=file:///yum       ---(这个就是你要挂在的本地目录,必须保持一致)
    enable=1
    cachedir=/var/cache/yum/$basearch/$releasever
    keepcache=0
    debuglevel=2
    logfile=/var/log/yum.log
    exactarch=1
    obsoletes=1
    gpgcheck=0
    plugins=1
    installonly_limit=3
5.配置自动挂载,添加一行挂载命令,或直接在命令行下执行,再查看是否可以自动挂载,应该是可以
  vi /etc/rc.local 
    #!/bin/sh
    #
    # This script will be executed *after* all the other init scripts.
    # You can put your own initialization stuff in here if you don't
    # want to do the full Sys V style init stuff.


    touch /var/lock/subsys/local
    mount -o loop /root/rhel-server-6.8-x86_64-dvd.iso /yum  ---(添加这一行)
6.重启yum,或重启服务器
  yum update
7.查看yum目录下是否已经有安装包
  cd /yum
  ls


方法2:
   把镜像加载到光驱中,把镜像中所有文件cp到/home/redhat-iso(目录随意),修改配置同上
1.mkdir /mnt/cdrom  
2.mount /dev/cdrom /mnt/cdrom  #挂着镜像,光盘
3.mkdir /home/redhat-iso
4.cp -Rf /mnt/cdrom/* /home/redhat-iso   #将光盘内的内容copy到某个路径下
5.cp /etc/yum.repos.d/rhel-source.repo /etc/yum.repos.d/rhel-source.repo.bak
6.vi /etc/yum.repos.d/rhel-source.repo  #编辑repo文件,编辑前先备份
    [rhel-source]  ---(仓库名称)
    name=cdrom     ---(名称随意)
    baseurl=file:///home/redhat-iso       -- (这个就是你要挂在的本地目录)
    enabled=1
    gpgcheck=0
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release


    [rhel-source-beta]
    name=Red Hat Enterprise Linux $releasever Beta - $basearch - Source
    baseurl=ftp://ftp.redhat.com/pub/redhat/linux/beta/$releasever/en/os/SRPMS/
    enabled=0
    gpgcheck=1
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-beta,file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
7.vi /etc/yum.conf   #修改yum.conf文件,相同选项尽量保持一致
    [rhel-source]   ---(仓库名称,尽量保持一致)
    name=cdrom      ---(尽量保持一致)
    baseurl=file:///home/redhat-iso    ---(这个就是你要挂在的本地目录,必须保持一致)
    enable=1
    cachedir=/var/cache/yum/$basearch/$releasever
    keepcache=0
    debuglevel=2
    logfile=/var/log/yum.log
    exactarch=1
    obsoletes=1
    gpgcheck=0
    plugins=1
    installonly_limit=3
8.重启yum,或重启服务器
  yum update
9.查看yum目录下是否已经有安装包
  cd /yum
  ls




方法:3


1.修改reop文件,修改上面配置,删除下面配置
2.mount /dev/sr0 /yum
  • 1
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值