1. 程式人生 > >redhat配置yum源

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