地址规划:vsftp服务器的地址为172.16.1.61

 使用的环境:

 [root@nfs01 scripts]# uname -a 

Linux nfs01 2.6.32-431.el6.x86_64 #1 SMP Fri Nov 22 03:15:09 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux

首先在yum服务器上挂载本地光盘

mkdir /media/cdrom ;mount /dev/cdrom /media/cdrom

cat >>/etc/yum.repos.d/CentOS.repo<

[Centos_yum]

name=Centos

baseurl=file:///media/cdrom

enabled=1

gpgcheck=0

QUIT

rm -rf /etc/yum.repos.d/CentOS-*

yum clean all

yum list

#使用vsftp软件来搭建ftp server

[root@m01 ~]# yum -y install vsftpd.x86_64

[root@m01 ~]# /etc/init.d/vsftpd start

Starting vsftpd for vsftpd:                                [  OK  ]

[root@m01 ~]# /etc/init.d/vsftpd status

vsftpd (pid 6840) is running...

#设置成开机自动启动

[root@m01 ~]# chkconfig --level 3 vsftpd on

#在默认的ftp目录下创建一个目录,一会用来存放制定的软件包

[root@m01 ~]#mkdir  /var/ftp/yum_packet

#把一会别的服务器需要用到的软件包放到这个目录里。

[root@m01 yum_packet]# cp /media/cdrom/Packages/nfs* ./

[root@m01 yum_packet]# cp /media/cdrom/Packages/httpd* ./

[root@m01 yum_packet]#cp /media/cdrom/Packages/rsync-3.0.6-9.el6_4.1.x86_64.rpm ./

#安装createrepo软件,用来创建yum索引数据库

[root@m01 yum_packet]#yum -y install createrepo-0.9.9-18.el6.noarch

#在这个rpm包目录下生成yum索引数据库

[root@m01 yum_packet]#createrepo ./

然后到客户端上:

[root@backup yum.repos.d]# vim CentOS.repo

[Centos_yum]

name=Centos

baseurl=ftp://172.16.1.61/yum_packet  #使用ftp作为yum仓库

enabled=1

gpgcheck=0

[root@backup yum.repos.d]# yum clean all

[root@backup yum.repos.d]# yum list

 

如果碰到这个错误可能是:

[root@backup yum.repos.d]# yum list

Loaded plugins: fastestmirror

Determining fastest mirrors

ftp://172.16.1.61/yum_packet/repodata/repomd.xml: [Errno 14] PYCURL ERROR 9 - "Server denied you to change to the given directory"

Trying other mirror.

Error: Cannot retrieve repository metadata (repomd.xml) for repository: Centos_yum. Please verify its path and try again

没有用createrepo来生成yum的索引库