1.放置iso文件,并挂载iso文件,永久挂载,修改/etc/fstab
参考:https://blog.csdn.net/qq_36119192/article/details/82222175#%E4%B8%80%EF%BC%9A%E9%85%8D%E7%BD%AE%E6%9C%AC%E5%9C%B0yum%E6%BA%90
或者搜索:Linux配置yum源(本地源和网络源) - 谢公子的博客
2.到该目录/etc/yum.repos.d删除所有文件rm -rf *,并创建base.repo
[bash]
name=my new repo
baseurl=file:///Archive/RedHat-Enterprise-Linux/7.4
enabled=1
gpgcheck=0
解读如下
[name] #括号中的名称为仓库源名称,要对应上,通常为字母和数字,必须填写
name=my new repo #对yum的描述,可写可不写
baseurl=file:///mnt/cdrom #baseurl表示声明yum可以管理并使用的rpm包路径,必须填写
enabled=1 #enabled表示当前仓库是否开启,1为开启,0为关闭,此项不写默认为开启
gpgcheck=0 #gpgcheck表示安装rpm包时,是否基于公私钥对匹配包的安全信息,1表示开启,
#0表示关闭,此项不写默认为验证
下面每一步都要做
3.清空
[[email protected] yum.repos.d]# yum clean all
Loaded plugins: product-id, search-disabled-repos, subscription-manager
This system is not registered with an entitlement server. You can use subscription-manager to register.
Cleaning repos: base
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
4.查看一下repolist
[[email protected] yum.repos.d]# yum repolist
Loaded plugins: product-id, search-disabled-repos, subscription-manager
This system is not registered with an entitlement server. You can use subscription-manager to register.
base | 4.1 kB 00:00
(1/2): base/group_gz | 137 kB 00:00
(2/2): base/primary_db | 4.0 MB 00:00
repo id repo name status
base Base 4,986
repolist: 4,986
5.yum包存储到本地
[[email protected] yum.repos.d]# yum makecache
Loaded plugins: product-id, search-disabled-repos, subscription-manager
This system is not registered with an entitlement server. You can use subscription-manager to register.
base | 4.1 kB 00:00
Metadata Cache Created
6.列出yum包
[[email protected] yum.repos.d]# yum list |wc -l
5096
原文地址:https://blog.51cto.com/weiruoyu/2453166
时间: 2024-11-09 11:48:42