1.检查是yum和createrepo包是否安装
[[email protected] ~]# rpm -qa |grep yum
yum-updatesd-0.9-2.el5
yum-metadata-parser-1.1.2-2.el5
yum-3.2.19-18.el5
yum-security-1.1.16-13.el5
yum-rhn-plugin-0.5.3-30.el5

[[email protected] ~]# rpm -qa |grep createrepo
createrepo-0.4.11-3.el5
 
2.安装vsftpd(这里也可以有使用http)
[[email protected] ~]# mount /dev/cdrom /mnt/
mount: block device /dev/cdrom is write-protected, mounting read-only
[[email protected] ~]# cd /mnt/Server/
[[email protected] Server]# rpm -ivh vsftpd-2.0.5-12.el5.i386.rpm
warning: vsftpd-2.0.5-12.el5.i386.rpm: Header V3 DSA signature: NOKEY, key ID 37017186
Preparing... (1########################################### [100%]
1:vsftpd ( ########################################### [100%]
[[email protected] Server]# service vsftpd start
Starting vsftpd for vsftpd: [ OK ]
[[email protected] Server]# chkconfig --level 35 vsftpd on
 
3.复制光盘到指定目录,光盘现在挂载在/mnt下,仅做一个Server目录的,其他三个包目录,制作方法相同。
[[email protected] ~]# mkdir /var/ftp/yum
[[email protected] mnt]# cp Server/ -rfp /var/ftp/yum/ 
4.删除旧的索引信息,并建立新的索引信息
[[email protected] ~]# rm -rf /var/ftp/yum/Server/repodata/
 
 
[[email protected] mnt]# cd /var/ftp/yum/
[[email protected] yum]# createrepo Server/
 
 
5.修改yum的repository配置文件
[[email protected] ~]# cd /etc/yum.repos.d/
[[email protected] ~]# mv rhel-debuginfo.repo local_yum.repo   #(也可以不改名,只要是.repo结尾就行)
 
[[email protected] ~]#vi local_yum.repo
 
[Server]
name=Server
baseurl=file:///var/ftp/yum/Server/            #yum 仓库位置,这里是服务器端,客户端   就 不能这么写了
enabled=1                                                       #这里默认是0需要改为1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
 
 
7.清除以前安装时yum缓存的包头文件信息。
[[email protected] yum]# yum clean all
 
[[email protected] yum]# yum list   如果看到包列表,说明成功。
#8. 这一步骤平常也可不做,不
[[email protected] yum]# vi /usr/lib/python2.4/site-packages/yum/yumRepo.py
/remote =                                             #正向查找remote =,找到如下行
 
remote = url + '/' + relative                     #把url替换为你的仓库目录
remote = “/var/ftp/yum” + '/' + relative 
 
 
二、客户端测试
1、修改.repo配置文件
[[email protected] ~]#vi /etc/yum.repos.d/rhel-debuginfo.repo
 
[rhel-debuginfo]
name=Red Hat Enterprise Linux $releasever - $basearch - Debug
baseurl=ftp://192.168.10.2/yum/Server/    #需要修改这里为仓库目录,10.2为服务器ip
enabled=1                                                      #这里为1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
 
 
2.清除以前安装时yum缓存的包头文件信息。
[[email protected] yum]# yum clean all
 
3.yum list
yum install bind
 
RHEL 5.3通过安装光盘构建本地yum 服务器
 
客户端常用的一些命令(转)
# yum install [-y ]package
-y:不提示用户确认直接安装
# yum localinstall package
install与localinstall的区别:install直接通过yum服务器端安装指定包及所有依赖关系,而localinstall是本地已有rpm文件,只要到yum服务器上安装依赖关系。
# yum grouplist
显示所有yum服务器定义的组
# yum groupinstall packagegroup
一次性安装yum服务器上定义的一组包
# yum remove package
# yum groupremove packagegroup
# yum search searcherm
查找yum服务器上所有符合searcherm关键字的内容
# yum list [all]
列出yum服务器所有可用的包
# yum info package
# yum groupinfo grouppackgroup
# yum whatprovides filename
查找指定文件属于那个包
#yum install --installroot /要安装目录    rpm包
指定安装到其他位置