我们接着上一篇,继续搭建YUM服务

1.挂载光盘镜像

先接着把光盘镜像挂载起来,因为YUM数据仓库的RPM包都要先从安装光盘中拷贝出来

# mount /dev/cdrom /media/
mount: block device /dev/sr0 is write-protected, mounting read-only


2.将光盘中的内容,复制到/var/ftp/pub目录下

/var/ftp/pub目录在vsftp安装完成后,一般会自动生成

# cp -a /media/* /var/ftp/pub/


3.更新数据仓库中的依赖关系,及分组信息

# createrepo -g /var/ftp/pub/repodata/2727fcb43fbe4c1a3588992af8c19e4d97167aee2f6088959221fc285cab6f72-c6-x86_64-comps.xml /var/ftp/pub/
Spawning worker 0 with 3955 pkgs
Workers Finished
Gathering worker results
Saving Primary metadata
Saving file lists metadata
Saving other metadata
Generating sqlite DBs
Sqlite DBs complete


4.启动vsftp并检查监听是否正常

# service vsftpd start
Starting vsftpd for vsftpd:                                [  OK  ]
# netstat -nlptu |grep vsftpd
tcp        0      0 0.0.0.0:21                  0.0.0.0:*                   LISTEN      2806/vsftpd


5.本地登陆,查看是否可以正常看到/var/ftp/pub目录中的内容

# ftp 127.0.0.1
Connected to 127.0.0.1 (127.0.0.1).
220 (vsFTPd 2.2.2)
Name (127.0.0.1:root): ftp
331 Please specify the password.
Password:
230 Login successful.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp> ls
227 Entering Passive Mode (127,0,0,1,195,194).
150 Here comes the directory listing.
drwxr-xr-x    7 0        0            4096 Nov 06 13:48 pub
226 Directory send OK.
ftp> cd pub
250 Directory successfully changed.
ftp> ls
227 Entering Passive Mode (127,0,0,1,142,7).
150 Here comes the directory listing.
-r--r--r--    1 0        0              14 Mar 05  2013 CentOS_BuildTag
dr-xr-xr-x    3 0        0            4096 Mar 05  2013 EFI
-r--r--r--    1 0        0             212 Mar 02  2013 EULA
-r--r--r--    1 0        0           18009 Mar 02  2013 GPL
dr-xr-xr-x    2 0        0          282624 Mar 05  2013 Packages
-r--r--r--    1 0        0            1354 Mar 02  2013 RELEASE-NOTES-en-US.html
-r--r--r--    1 0        0            1706 Mar 02  2013 RPM-GPG-KEY-CentOS-6
-r--r--r--    1 0        0            1730 Mar 02  2013 RPM-GPG-KEY-CentOS-Debug-6
-r--r--r--    1 0        0            1730 Mar 02  2013 RPM-GPG-KEY-CentOS-Security-6
-r--r--r--    1 0        0            1734 Mar 02  2013 RPM-GPG-KEY-CentOS-Testing-6
-r--r--r--    1 0        0            3380 Mar 05  2013 TRANS.TBL
dr-xr-xr-x    3 0        0            4096 Mar 05  2013 p_w_picpaths
dr-xr-xr-x    2 0        0            4096 Mar 05  2013 isolinux
drwxr-xr-x    2 0        0            4096 Nov 06 13:48 repodata
226 Directory send OK.
ftp>

可以看到,一切ok,下面到CentOS2上面配置客户端


2号机上配置客户端与前文所说的配置本地客户端基本一致,只是把basurl的指向改为1号机的ftp

# cd /etc/yum.repos.d/
# rename repo repo.bak *
# cp -a CentOS-Debuginfo.repo.bak CentOS-Ftp.repo
# vim CentOS-Ftp.repo
[ftp]
name=CentOS-6 - FTPinfo
baseurl=ftp://192.168.80.3/pub
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
enabled=1
# yum clean all
Loaded plugins: fastestmirror, security
Cleaning repos: ftp
Cleaning up Everything
# yum repolist all
Loaded plugins: fastestmirror, security
Loading mirror speeds from cached hostfile
repo id                                                                         repo name                                                                                   status
ftp                                                                             CentOS-6 - FTPinfo                                                                          enabled: 3,955
repolist: 3,955