Linux搭建本地yum仓库

本文详细介绍了如何在Linux系统中搭建本地yum仓库,包括新建目录、临时挂载仓库、配置文件、清理缓存及解决常见错误。在完成步骤后,能够成功列出yum信息。
摘要由CSDN通过智能技术生成

1、挂载yum仓库、并保存到本地

1.1 新建目录

[root@localhost ~]# mkdir /iso

1.2 临时挂载仓库到/mnt

[root@localhost ~]# mount /dev/cdrom /mnt/
mount: /dev/sr0 写保护,将以只读方式挂载

1.3 保存到本地

[root@localhost ~]# cp -r /mnt/* /iso/
[root@localhost ~]# ls -lh /iso/
总用量 320K
-rw-r--r--. 1 root root   14 8月  25 19:25 CentOS_BuildTag
drwxr-xr-x. 3 root root   35 8月  25 19:25 EFI
-rw-r--r--. 1 root root  227 8月  25 19:25 EULA
-rw-r--r--. 1 root root  18K 8月  25 19:25 GPL
drwxr-xr-x. 3 root root   57 8月  25 19:25 images
drwxr-xr-x. 2 root root  198 8月  25 19:25 isolinux
drwxr-xr-x. 2 root root   43 8月  25 19:26 LiveOS
drwxr-xr-x. 2 root root 216K 8月  25 19:27 Packages
drwxr-xr-x. 2 root root 4.0K 8月  25 19:27 repodata
-rw-r--r--. 1 root root 1.7K 8月  25 19:27 RPM-GPG-KEY-CentOS-7
-rw-r--r--. 1 root root 1.7K 8月  25 19:27 RPM-GPG-KEY-CentOS-Testing-7
-r--r--r--. 1 root root 2.9K 8月  25 19:27 TRANS.TBL

2、配置文件

  • 配置文件目录在:/etc/yum.repos.d/下
  • 在目录下新建以.repo结尾的文档
  • vim /etc/yum.repos.d/yum.repo

2.1 写入配置文件

[root@localhost ~]# vim /etc/yum.repos.d/yum.repo

[iso]						#yum源的名字
name=CentOS7.iso			#描述信息
baseurl=file:///iso			#yum源的本地镜像目录
enabled=1					#yum源是否启用 1-启用 0-不启用
gpgcheck=0					#安全检查是否启用 1-启用 0-不启用

3、清理yum仓库缓存

[root@localhost ~]# yum clean all
已加载插件:fastestmirror, langpacks
正在清理软件源: base extras iso updates
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
Cleaning up list of fastest mirrors

4、列出yum的信息

[root@localhost ~]# yum repolist 
已加载插件:fastestmirror, langpacks
Determining fastest mirrors
Could not retrieve mirrorlist http://mirrorlist.centos.org/?release=7&arch=x86_64&repo=os&infra=stock error was
14: curl#6 - "Could not resolve host: mirrorlist.centos.org; 未知的错误"
Loading mirror speeds from cached hostfile
Loading mirror speeds from cached hostfile
Loading mirror speeds from cached hostfile
Loading mirror speeds from cached hostfile
源标识                                  源名称                                     状态
base/7/x86_64                           CentOS
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值