1、创建rpm包的存放目录

mkdir  -p   /yum/yum-sum/package

2、准备rpm包,可以通过自带yum只下载不安装工具下载

yum install --downloadonly --downloaddir=/yum/yum-sum/package  <package-name>

如:yum install --downloadonly --downloaddir=/yum/yum-sum/package   gcc  gcc-c++

3、下载createrepo工具

yum -y install createrepo

4、创建repo

createrepo -u -d /yum/yum-sum

5、配置repo文件

vi /etc/yum.repos.d/CentOS-Media.repo
[c7-media]
name=CentOS-$releasever - Media
baseurl=file:///yum/yum-sum/
gpgcheck=0
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

6、制作cache

[root@min-base ~]# yum clean all
Loaded plugins: fastestmirror
Cleaning repos: c7-media
Cleaning up everything
Cleaning up list of fastest mirrors
[root@min-base ~]#
[root@min-base ~]# yum makecache
Loaded plugins: fastestmirror
c7-media | 3.0 kB 00:00:00
(1/3): c7-media/filelists_db | 880 B 00:00:00
(2/3): c7-media/primary_db | 1.8 kB 00:00:00
(3/3): c7-media/other_db | 1.3 kB 00:00:00
Determining fastest mirrors
Metadata Cache Created

  

05-11 13:18