CentOS7如何手工创建自己的YUM仓库?

2020-01-30 16:57:40王振洲

Preparing...                          ################################# [100%]

package createrepo-0.9.9-23.el7.noarch is already installed

3、运行createrepo命令建立索引

createrepo /yum-packages/

完成后会在yum-packages文件夹下建立一个repodata的文件夹,里面保存索引信息。

4、添加配置文件

在/etc/yum.repos.d/文件夹下添加配置文件。

[root@localhost yum-packages]# cd /etc/yum.repos.d/

[root@localhost yum.repos.d]# vim ownyum.repo

[root@localhost yum.repos.d]# cat ownyum.repo 

[centos]

name = centos yum

baseurl = file:///yum-packages/

[root@localhost yum.repos.d]#

这里进行了最简单的配置,[centos]、name 任意取名字就行,enabled、gpgcheck可配置也可不配置。

5、清空YUM Cache

使用yum clean all命令清空,并用yum list命令查看yum库

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

Loaded plugins: fastestmirror, langpacks

Cleaning repos: centos

Cleaning up everything

Cleaning up list of fastest mirrors

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

可以看到自己建立的yum仓库信息

xorg-x11-xbitmaps.noarch               1.1.1-6.el7                     centos   

xpp3.noarch                            1.1.3.8-11.el7                  centos   

xrestop.x86_64                         0.4-14.el7                      centos   

xsane-common.x86_64                    0.999-9.el7                     centos   

xsane-gimp.x86_64                      0.999-9.el7                     centos