RHEL下本地yum仓库的配置方法

yum是RedHat 5版本上新赠的功能,方便用户安装软件,可以一次安装相关联的软件,具体配置如下:

1.首先进入目录  /etc/yum.repos.d,在目录下面会发现文件 rhel-debuginfo.repo ,具体内容如下:

[rhel-debuginfo]
name=Red Hat Enterprise Linux $releasever - $basearch - Debug
baseurl=ftp://ftp.redhat.com/pub/redhat/linux/enterprise/$releasever/en/os/$basearch/Debuginfo/
enabled=0 --------是否开启yum功能,0为关闭,1为开启。
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release

2.把文件rhel-debuginfo.repo 作为模板使用,
cp rhel-debuginfo.repo server.repo
修改其中的相关文件:(红色字体部分包括使用何种协议下载内容,下载文件的路径

[rhel]
name=Red Hat Enterprise Linux
baseurl=http://ip/Server
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release


[cluster]
name=Red Hat Enterprise Linux cluster
baseurl=http://ip/Cluster
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release



[vt]
name=Red Hat Enterprise Linux vt
baseurl=http://ip/VT
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release

3.整理软件仓库组目录,下面以Server目录为例:
createrepo -g /var/www/html/iso/Server/repodata/comps-rhel5-servver-core.xml 
/var/www/html/iso/Server/

4.在启动http服务。

5.安装完成后,就可以使用yum了,例如安装vsftp服务:

[root@RHCE yum.repos.d]# yum -y install vsftp




1.挂载光盘

mount /dev/cdrom /mnt #将光盘挂载到 /下的mnt中.

2.修改 YUM 文件.

YUM 文件位置如下 /etc/yum.repos.d/rhel-debuginfo.repo

cp /etc/yum.repos.d/rhel-debuginfo.repo my.repo #复制并命名为my.repo

vi my.repo #使用vi编辑器对my.repo文件进行修改,如下所示:

[rhel]

name=Red Hat #根据自己实际情况

baseurl=file:///mnt/Server #因为我们用的是文件,所以是file://因为是在根目录下,所以会有三个/

enable=1 #重要,一定要变为1,否则不可用

gpgcheck=1 //此行以后不变.

保存退出

3.安装 createrepo及vsftpd

cd /mnt/Server/

rpm -ivh createrepo-0.4.4-2.fc6.noarch.rpm

rpm -ivh vsftpd-2.0.5-10.el5.i386.rpm

4.复制光盘下的Server目录至 /var/ftp/pub 下,因为以后要为网内所有Linux客户端提供yum源服务,所以使用FTP服务.

cp /mnt/Server /var/ftp/pub

5.重新生成分组文件及依赖关系

createrepo -g /var/ftp/pub/Server/repodata/comps-rhel5-server-core.xml /var/ftp/pub/Server #此处要使用绝对路径.

到这里YUM源就已经设置完成,以下为验证过程.

 

yum clean all

yum list all

yum -y install dhcp.i* #安装dhcp来测试是否成功.

若出现如下提示则说明分组及依赖关系生成错误,请重新生成.

---> Downloading header for yum-utils to pack into transaction set.
media://1192663619.181374%234/xxxxxxxxxx: [Errno 4] IOError:
Trying other mirror.
Error: failed to retrieve yum-utils-1.0.4-3.el5.noarch.rpm from dvd-server
error was [Errno 4] IOError:
---------------分割---------------

以下为在客户机上设置YUM源.

cp /etc/yum.repos.d/rhel-debuginfo.repo my.repo

vi my.repo

将baseurl处修改为 ftp://ip_address/pub/Server

其它地方相同,保存退出即可.


你可能感兴趣的:(RHEL下本地yum仓库的配置方法)