1. 环境
环境&软件 | 版本 | 备注 |
---|
VirtualBox | Virtual Box 7.0 | 虚拟机软件 |
CentOS7 | CentOS-7-x86_64-Everything-2207-02.iso | 大小大约10G |
2. 挂载ISO镜像到文件系统
- 将iso镜像文件CentOS-7-x86_64-Everything-2207-02.iso上传到Linux系统/data/目录下;
- 创建/yum/local目录,将镜像挂载到该目录下;
mkdir -p /yum/local
cd /data
mount -o loop ./CentOS-7-x86_64-Everything-2207-02.iso /yum/local
[root@localhost data]# mount -o loop ./CentOS-7-x86_64-Everything-2207-02.iso /yum/local
mount: /dev/loop0 is write-protected, mounting read-only
[root@localhost data]# df -h
Filesystem Size Used Avail Use% Mounted on
...... ... ... ... ... ...
/dev/loop0 9.6G 9.6G 0 100% /yum/local
[root@localhost data]# ls /yum/local/
CentOS_BuildTag GPL LiveOS RPM-GPG-KEY-CentOS-7
EFI images Packages RPM-GPG-KEY-CentOS-Testing-7
EULA isolinux repodata TRANS.TBL
3. 创建一个调用本地yum源的repo文件
[root@localhost data]# vim /etc/yum.repos.d/local.repo
[root@localhost data]# touch /etc/yum.repos.d/local.repo
[root@localhost data]# vim /etc/yum.repos.d/local.repo
[root@localhost data]# cat /etc/yum.repos.d/local.repo
[local]
name=local
baseurl=file:/
enable=1
gpgcheck=0
gpgkey=file:/
4. 备份历史yum源
[root@localhost data]# mkdir -p /etc/yum.repos.d/history
[root@localhost data]# mv /etc/yum.repos.d/
CentOS-Base.repo CentOS-Sources.repo
CentOS-CR.repo CentOS-Vault.repo
CentOS-Debuginfo.repo CentOS-x86_64-kernel.repo
CentOS-fasttrack.repo history/
CentOS-Media.repo local.repo
[root@localhost data]# mv /etc/yum.repos.d/history/local.repo /etc/yum.repos.d/
[root@localhost data]# ls /etc/yum.repos.d/
history local.repo
5. 更新yum源
[root@localhost data]# yum update
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
local | 3.6 kB 00:00
(1/2): local/group_gz | 153 kB 00:00
(2/2): local/primary_db | 6.1 MB 00:00
6. 安装ntp测试本地源
在这里插入代码片[root@localhost data]# yum install -y ntp
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
Resolving Dependencies
--> Running transaction check
---> Package ntp.x86_64 0:4.2.6p5-29.el7.centos.2 will be installed
--> Processing Dependency: libopts.so.25()(64bit) for package: ntp-4.2.6p5-29.el7.centos.2.x86_64
--> Running transaction check
---> Package autogen-libopts.x86_64 0:5.18-5.el7 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
============================================================================ Package Arch Version Repository
Size
============================================================================Installing:
ntp x86_64 4.2.6p5-29.el7.centos.2 local 549 k
Installing for dependencies:
autogen-libopts x86_64 5.18-5.el7 local 66 k
Transaction Summary
============================================================================Install 1 Package (+1 Dependent package)
Total download size: 615 k
Installed size: 1.5 M
Downloading packages:
----------------------------------------------------------------------------Total 31 MB/s | 615 kB 00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : autogen-libopts-5.18-5.el7.x86_64 1/2
Installing : ntp-4.2.6p5-29.el7.centos.2.x86_64 2/2
Verifying : autogen-libopts-5.18-5.el7.x86_64 1/2
Verifying : ntp-4.2.6p5-29.el7.centos.2.x86_64 2/2
Installed:
ntp.x86_64 0:4.2.6p5-29.el7.centos.2
Dependency Installed:
autogen-libopts.x86_64 0:5.18-5.el7
Complete!