[CentOS]更新repo源到本地

前端之家收集整理的这篇文章主要介绍了[CentOS]更新repo源到本地前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

1 本地目录作为repo源

将repo源更新到本地可以加速rpm包的安装

1. 将包含rpm包的文件夹存在指定目录,(本文中是/opt/centos-repo)

2. 创建centos.repo

在目录/etc/yum.repo.d/下创建repo配置文件centos.repo

[centos]
name=centos
baseurl=file:///opt/centos-repo
gpgcheck=0
enabled=1

3. 创建索引更新索引

[root@node0 centos-repo]# createrepo /opt/centos-repo/; yum clean all;yum makecache
Spawning worker 0 with 33 pkgs
Workers Finished
Saving Primary Metadata
Saving file lists Metadata
Saving other Metadata
Generating sqlite DBs
sqlite DBs complete
Spawning worker 0 with 3705 pkgs
Workers Finished
Saving Primary Metadata
Saving file lists Metadata
Saving other Metadata
Generating sqlite DBs
sqlite DBs complete
Loaded plugins: fastestmirror,langpacks
Cleaning repos: centos ceph
Cleaning up everything
Loaded plugins: fastestmirror,langpacks
centos | 2.9 kB 00:00
ceph | 2.9 kB 00:00
(1/6): centos/filelists_db | 2.9 MB 00:00
(2/6): centos/primary_db | 2.8 MB 00:00
(3/6): centos/other_db | 1.2 MB 00:00
(4/6): ceph/filelists_db | 9.2 kB 00:00
(5/6): ceph/other_db | 2.9 kB 00:00
(6/6): ceph/primary_db | 26 kB 00:00
Determining fastest mirrors
Metadata Cache Created
[root@node0 centos-repo]# cat /etc/yum.repos.d/
backup/ centos.repo ceph.repo
[root@node0 centos-repo]# cat /etc/yum.repos.d/centos.repo
[centos]
name=centos
baseurl=file:///opt/centos-repo
gpgcheck=0
enabled=1
[root@node0 centos-repo]#

/etc/yum.repo.d/下还存在联网的repo源配置文件:
[root@node0 yum.repos.d]# ls
CentOS-Base.repo CentOS-fasttrack.repo CentOS-Vault.repo
CentOS-CR.repo CentOS-Media.repo epel.repo
CentOS-Debuginfo.repo CentOS-Sources.repo epel-testing.repo
[root@node0 yum.repos.d]#

将如上repo配置文件都移入到backup目录,如下:

[root@node0 yum.repos.d]# ls
backup centos.repo
[root@node0 yum.repos.d]#

2 光盘作为repo源

设置repo源配置文件

在/etc/yum.repo.d/下创建repo源配置文件:cdrom.repo

[cdrom]
name=CentOS7 - cdrom
baseurl=file:///media/
enable=1
gpgcheck=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

清除缓存 建立新缓存
[root@node0 ~]# yum clean all
[root@node0 ~]# yum makecache

猜你在找的CentOS相关文章