Linux搭建本地yum仓库

  • 1、挂载yum仓库、并保存到本地
    • 1.1 新建目录
    • 1.2 临时挂载仓库到/mnt
    • 1.3 保存到本地
  • 2、配置文件
    • 2.1 写入配置文件
  • 3、清理yum仓库缓存
  • 4、列出yum的信息
  • 5、常见错误解决
    • 5.1 关于第4步无法列出yum
  • 6、正常列出yum信息

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-7 - Base                            0
extras/7/x86_64                         CentOS-7 - Extras                          0
iso                                     CentOS7.iso                                0
updates/7/x86_64                        CentOS-7 - Updates                         0
repolist: 0
[root@localhost ~]# yum list
已加载插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
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; 未知的错误"One of the configured repositories failed (未知),and yum doesn't have enough cached data to continue. At this point the onlysafe thing yum can do is fail. There are a few ways to work "fix" this:1. Contact the upstream for the repository and get them to fix the problem.2. Reconfigure the baseurl/etc. for the repository, to point to a workingupstream. This is most often useful if you are using a newerdistribution release than is supported by the repository (and thepackages for the previous distribution release still work).3. Run the command with the repository temporarily disabledyum --disablerepo=<repoid> ...4. Disable the repository permanently, so yum won't use it by default. Yumwill then just ignore the repository until you permanently enable itagain or use --enablerepo for temporary usage:yum-config-manager --disable <repoid>orsubscription-manager repos --disable=<repoid>5. Configure the failing repository to be skipped, if it is unavailable.Note that yum will try to contact the repo. when it runs most commands,so will have to try and fail each time (and thus. yum will be be muchslower). If it is a very temporary problem though, this is often a nicecompromise:yum-config-manager --save --setopt=<repoid>.skip_if_unavailable=trueCannot find a valid baseurl for repo: base/7/x86_64
  • 理论上是已经搭建完成了
  • 但是在列表上看不到仓库源内容

5、常见错误解决

5.1 关于第4步无法列出yum

  • 原因是没有打开网络
[root@localhost ~]# ifconfig | head -3
ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500ether 00:0c:29:8a:**:**  txqueuelen 1000  (Ethernet)RX packets 917  bytes 60053 (58.6 KiB)

解决方法

[root@localhost ~]# nmtui选中网卡---回车---启动网络

[root@localhost ~]# ifconfig | head -3
ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500inet 192.168.***.***  netmask 255.255.255.0  broadcast 192.168.***.***inet6 fe80::d404:cd4:6938:****  prefixlen 64  scopeid 0x20<link>

6、正常列出yum信息

[root@localhost ~]# yum repolist
已加载插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile* base: mirrors.163.com* extras: mirrors.aliyun.com* updates: mirrors.163.com
base                                                            | 3.6 kB  00:00:00
extras                                                          | 2.9 kB  00:00:00
iso                                                             | 3.6 kB  00:00:00
updates                                                         | 2.9 kB  00:00:00
(1/6): base/7/x86_64/group_gz                                   | 153 kB  00:00:00
(2/6): iso/group_gz                                             | 166 kB  00:00:00
(3/6): iso/primary_db                                           | 3.1 MB  00:00:00
(4/6): extras/7/x86_64/primary_db                               | 242 kB  00:00:01
(5/6): updates/7/x86_64/primary_db                              | 9.6 MB  00:00:02
(6/6): base/7/x86_64/primary_db                                 | 6.1 MB  00:00:09
源标识                                 源名称                                    状态
base/7/x86_64                          CentOS-7 - Base                           10,072
extras/7/x86_64                        CentOS-7 - Extras                            498
iso                                    CentOS7.iso                                3,971
updates/7/x86_64                       CentOS-7 - Updates                         2,579
repolist: 17,120
[root@localhost ~]# yum list
sysvinit-tools.x86_64                        2.88-14.dsf.el7                  @anaconda
taglib.x86_64                                1.8-7.20130218git.el7            @anaconda
tagsoup.noarch                               1.2.1-8.el7                      @anaconda
tar.x86_64                                   2:1.26-34.el7                    @anaconda
tcp_wrappers.x86_64                          7.6-77.el7                       @anaconda
tcp_wrappers-libs.x86_64                     7.6-77.el7                       @anaconda
......

Linux搭建本地yum仓库相关推荐

  1. Linux 搭建本地yum仓库(yum源)

    准备环境: hostA:使用Centos7的镜像文件 要求: 可以通过yum仓库安装vim,net-tools等工具 方法: 主机A 的设备状态是显示已连接状态的 查看块设备信息: lsblk 显示s ...

  2. Linux那点事儿——搭建本地yum仓库

    搭建本地yum仓库 前言 一.基本镜像的yum仓库 二.搭建内网yun仓库 前言 当我们使用yum目录安装包时,yum会查到/etc/yum.repos.d/*.repo文件获取包下载地址,默认Cen ...

  3. 解决内网搭建本地yum仓库。

    2019独角兽企业重金招聘Python工程师标准>>> 一.使用iso镜像搭建本地yum仓库: 1.挂载镜像到/mnt目录下: [root@Dasoncheng ~]# mount ...

  4. CentOS7 基于http服务搭建本地yum仓库

    由于公司内网服务器无法访问外网,安装软件相对比较麻烦,所以可以选择一台主机搭建本地yum仓库.本文选择使用http服务搭建. 实验环境:CentOS 7 仓库主机:192.168.116.131 测试 ...

  5. CentOS7搭建本地YUM仓库

    文章目录 1. 仓库环境准备 1.1. 系统环境 1.2. 修改yum源 1.3. 检验阿里云源是否正常 2. 部署仓库 2.1. 安装相关软件 2.2. 根据源标识同步源到本地目录 2.2.1. 创 ...

  6. 如何搭建本地yum仓库

    一.yum简介 yum( Yellow dog Updater, Modified)是一个在 Fedora 和 RedHat 以及 SUSE 中的 Shell 前端软件包管理器. 基于 RPM 包管理 ...

  7. 使用光盘搭建本地yum仓库源

    文章目录 项目需求: 实验前准备 一.yum Serve端配置 二.yum Client客户端配置 项目需求: 1.网络管理内部服务器与外网隔离,内部服务器无法通过外网下载软件,只能通过本地局域网使用 ...

  8. 通过挂载系统光盘搭建本地yum仓库的方法

    1.配置本地yum源(挂载光盘) mkdir  /medir/cdrom(创建目录) mount  /dev/cdrom   / medir/cdrom (挂载到/ medir/cdrom目录) 2. ...

  9. linux搭建本地YUM源配置详细步骤

    1.1. 为什么要制作本地YUM源 YUM在Linux上使用源码的方式安装软件非常麻烦,使用yum可以简化安装的过程. 1.2. YUM源的原理 YUM源其实就是一个保存了多个RPM包的服务器,可以通 ...

最新文章

  1. 影像组学视频学习笔记(33)-使用SimpleITK实现医学影像差值、Li‘s have a solution and plan.
  2. python学习-条件语句
  3. python超神之路:创建对象的9种方法
  4. 【CodeForces - 701D】As Fast As Possible(二分,模拟,数学公式)
  5. 外设驱动库开发笔记38:RTD热电阻测温驱动
  6. 解决`向github提交代码是老要输入用户名密码`
  7. bootstrap快速入门_在5分钟内学习Bootstrap 4-快速入门指南
  8. flink streamGraph生成jobGraph
  9. 使用Android OpenGL ES 2.0绘图之一:搭建一个OpenGL ES环境
  10. 大数据分析需注意哪些问题
  11. SSAS: Display measures in Rows
  12. freebsd mysql tmp_FreeBSD下安装MySQL与MySQLdb笔记
  13. 波士顿大学计算机硕士排名,波士顿大学计算机工程研究生排名重点消息重点解析...
  14. 触发器实例精讲-志在必得
  15. 基于协同过滤算法的商品推荐购物电商系统
  16. 利用python模拟ios屏幕点击器_iOS模拟屏幕点击事件
  17. Java底层小开发的面试经历
  18. 广西行政村数据shp_全国 shp 矢量数据汇总(四):全国行政区划基础矢量数据(精确到乡镇级别)...
  19. 欧姆龙PLC HostLink通讯 C-MODE格式
  20. 计算机网络(OSI、TCP/IP、网络协议、常见网络设备工作原理)

热门文章

  1. netflix_每日新闻摘要,19/4/8:Netflix取消了对AirPlay的支持
  2. 10次面试9次被刷?其实更多是面试实力和面试技巧不匹配罢了
  3. vboxmanage 常用命令
  4. 不只测心率,通过AI可以测大学生压力水平
  5. 上王者的正确姿势:OPPO R17 Pro王者定制版
  6. kernel_task 进程 CPU 占用率高导致 mac 卡顿问题
  7. Mybatis 批量插入
  8. 面试官:遇到过什么系统故障?怎么解决?看完后能轻松应对
  9. 国内如何购买Google Colab会员
  10. 你还不了解结构体吗?带你深入了解结构体