[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



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

YoungerChina

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值