一、挂载光盘
[root@localhost /]# mount /dev/sr0 /mnt
mount: /dev/sr0 is write-protected, mounting read-only
[root@localhost /]# cd /mnt
[root@localhost mnt]# ll
total 664
-rw-rw-r--. 3 root root 14 Sep 5 2017 CentOS_BuildTag
drwxr-xr-x. 3 root root 2048 Sep 5 2017 EFI
-rw-rw-r--. 3 root root 227 Aug 30 2017 EULA
-rw-rw-r--. 3 root root 18009 Dec 9 2015 GPL
drwxr-xr-x. 3 root root 2048 Sep 5 2017 images
drwxr-xr-x. 2 root root 2048 Sep 5 2017 isolinux
drwxr-xr-x. 2 root root 2048 Sep 5 2017 LiveOS
drwxrwxr-x. 2 root root 641024 Sep 4 2017 Packages
drwxr-xr-x. 2 root root 4096 Sep 5 2017 repodata
-rw-rw-r--. 3 root root 1690 Dec 9 2015 RPM-GPG-KEY-CentOS-7
-rw-rw-r--. 3 root root 1690 Dec 9 2015 RPM-GPG-KEY-CentOS-Testing-7
-r--r--r--. 1 root root 2883 Sep 6 2017 TRANS.TBL
[root@localhost mnt]#
二、安装vsftpd服务
[root@localhost mnt]# cd Packages/
[root@localhost Packages]# rpm -ivh vsftpd-3.0.2-22.el7.x86_64.rpm
三、安装createrepo工具
[root@localhost Packages]# rpm -ivh createrepo-0.9.9-28.el7.noarch.rpm
warning: createrepo-0.9.9-28.el7.noarch.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
error: Failed dependencies:
deltarpm is needed by createrepo-0.9.9-28.el7.noarch
libxml2-python is needed by createrepo-0.9.9-28.el7.noarch
#在centos7中,安装这个工具需要依赖包,依次安装deltarpm、python-deltarpm、libxml2-python
[root@localhost Packages]# rpm -ivh deltarpm-3.6-3.el7.x86_64.rpm
warning: deltarpm-3.6-3.el7.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
Preparing... ################################# [100%]
Updating / installing...
1:deltarpm-3.6-3.el7 ################################# [100%]
[root@localhost Packages]# rpm -ivh python-deltarpm-3.6-3.el7.x86_64.rpm
warning: python-deltarpm-3.6-3.el7.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
Preparing... ################################# [100%]
Updating / installing...
1:python-deltarpm-3.6-3.el7 ################################# [100%]
[root@localhost Packages]# rpm -ivh libxml2-python-2.9.1-6.el7_2.3.x86_64.rpm
warning: libxml2-python-2.9.1-6.el7_2.3.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
Preparing... ################################# [100%]
Updating / installing...
1:libxml2-python-2.9.1-6.el7_2.3 ################################# [100%]
#最后再安装createrepo工具
[root@localhost Packages]# rpm -ivh createrepo-0.9.9-28.el7.noarch.rpm
warning: createrepo-0.9.9-28.el7.noarch.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
Preparing... ################################# [100%]
Updating / installing...
1:createrepo-0.9.9-28.el7 ################################# [100%]
四、拷贝
[root@localhost mnt]# cp -rv Packages /var/ftp/pub/ #拷贝包
[root@localhost repodata]# cp 38b60f66d52704cffb8696750b2b6552438c1ace283bc2cf22408b0ba0e4cbfa-c7-x86_64-comps.xml ~ #拷贝分组信息
五、重新指定分组信息
[root@localhost ~]# cd /var/ftp/pub/Packages/
[root@localhost Packages]# createrepo -g ~/38b60f66d52704cffb8696750b2b6552438c1ace283bc2cf22408b0ba0e4cbfa-c7-x86_64-comps.xml .
#对当前rpm包进行索引
#如果没有拷贝分组信息就不加 -g 选项
六、编辑repo文件
[base]
name=CentOS-$releasever - Base
baseurl=file:///var/ftp/pub/Packages
gpgcheck=0 #校验,0表示关闭校验
七、清除缓存yum clean all
最后yum list 能列出来就可以了