搭建本地yum
环境Redhat7.4
检查是否存在挂载驱动
[root@anes ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 20G 0 disk
├─sda1 8:1 0 1G 0 part /boot
└─sda2 8:2 0 19G 0 part
├─rhel-root 253:0 0 17G 0 lvm /
└─rhel-swap 253:1 0 2G 0 lvm [SWAP]
sr0 11:0 1 3.8G 0 rom /run/media/root/RHEL-7.4 Server.x86_64 \\此为挂载驱动
不存在挂载驱动
右击小光盘进行链接
如果您不小心把镜像文件删除
请访问 Linux系统下载站 进行下载(此链接与本文作者无关,建议使用Google Chrome浏览器)
请任选一种进行操作
复制光盘内容到yum服务器 (第一种)
为了安全起见建议您把光盘中的镜像拷贝到服务器中
[root@anes ~]# cp -r /run/media/root/RHEL-7.4\ Server.x86_64/ /opt/myrepo
配置repo文件
编辑repo文件
[root@anes myrepo]# vim /etc/yum.repos.d/local.repo
[local]
name=local
baseurl=file:///opt/myrepo/RHEL-7.4\ Server.x86_64/
gpgcheck=0
enabled=1
清空yum缓存
[root@anes ~]# yum clean all
已加载插件:langpacks, product-id, search-disabled-repos, subscription-manager
This system is not registered with an entitlement server. You can use subscription-manager to register.
正在清理软件源: local
Cleaning up everything
Maybe you want: rm -rf /var/cache/yum, to also free up space taken by orphaned data from disabled or removed repos
重新加载缓存
[root@anes ~]# yum makecache
已加载插件:langpacks, product-id, search-disabled-repos, subscription-manager
This system is not registered with an entitlement server. You can use subscription-manager to register.
local | 4.1 kB 00:00:00
(1/5): local/group_gz | 137 kB 00:00:00
(2/5): local/filelists_db | 3.4 MB 00:00:00
(3/5): local/primary_db | 4.0 MB 00:00:00
(4/5): local/other_db | 1.5 MB 00:00:00
(5/5): local/productid | 1.6 kB 00:00:00
元数据缓存已建立
检查
是否存在源
[root@anes ~]# yum repolist
已加载插件:langpacks, product-id, search-disabled-repos, subscription-manager
This system is not registered with an entitlement server. You can use subscription-manager to register.
源标识 源名称 状态
local local 4,986
repolist: 4,986
直接挂载光盘(第二种)
编辑挂载文件
[root@anes ~]# vim /etc/fstab
#
# /etc/fstab
# Created by anaconda on Mon Mar 2 03:51:00 2020
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
/dev/mapper/rhel-root / xfs defaults 0 0
UUID=7e99ca32-a1f0-4cdb-a3e2-a68c192e7a87 /boot xfs defaults 0 0
/dev/mapper/rhel-swap swap swap defaults 0 0
/dev/cdrom /mnt iso9660 defaults 0 0
刷新挂载
[root@anes ~]# mount -a
mount: /dev/sr0 写保护,将以只读方式挂载
编辑repo配置文件
[root@anes ~]# vim /etc/yum.repos.d/local.repo
[local]
name=local
baseurl=file:///mnt/
gpgcheck=0
enabled=1
清除缓存
[root@anes ~]# yum clean all
已加载插件:langpacks, product-id, search-disabled-repos, subscription-manager
This system is not registered with an entitlement server. You can use subscription-manager to register.
正在清理软件源: local
Cleaning up everything
Maybe you want: rm -rf /var/cache/yum, to also free up space taken by orphaned data from disabled or removed repos
重新缓存
[root@anes ~]# yum makecache
已加载插件:langpacks, product-id, search-disabled-repos, subscription-manager
This system is not registered with an entitlement server. You can use subscription-manager to register.
local | 4.1 kB 00:00:00
(1/5): local/group_gz | 137 kB 00:00:00
(2/5): local/primary_db | 4.0 MB 00:00:00
(3/5): local/filelists_db | 3.4 MB 00:00:00
(4/5): local/other_db | 1.5 MB 00:00:00
(5/5): local/productid | 1.6 kB 00:00:00
元数据缓存已建立
检查
[root@anes ~]# yum repolist
已加载插件:langpacks, product-id, search-disabled-repos, subscription-manager
This system is not registered with an entitlement server. You can use subscription-manager to register.
源标识 源名称 状态
local local 4,986
repolist: 4,986