zoukankan      html  css  js  c++  java
  • centos挂载本地镜像作为yum源

    1、安装Centos后默认的Yum源如下
    ll /etc/yum.repos.d/
     
    [root@localhost ~]# ll /etc/yum.repos.d/
    total 32
    -rw-r--r--. 1 root root 1664 Nov 23 21:16 CentOS-Base.repo
    -rw-r--r--. 1 root root 1309 Nov 23 21:16 CentOS-CR.repo
    -rw-r--r--. 1 root root 649 Nov 23 21:16 CentOS-Debuginfo.repo
    -rw-r--r--. 1 root root 314 Nov 23 21:16 CentOS-fasttrack.repo
    -rw-r--r--. 1 root root 630 Nov 23 21:16 CentOS-Media.repo
    -rw-r--r--. 1 root root 1331 Nov 23 21:16 CentOS-Sources.repo
    -rw-r--r--. 1 root root 5701 Nov 23 21:16 CentOS-Vault.repo

    2、把默认Yum源备份(可选)
     
    [root@localhost ~]# mkdir /opt/centos-yum.bak
    [root@localhost ~]# mv /etc/yum.repos.d/* /opt/centos-yum.bak/

    3、将iso镜像上传到虚机上
    mkdir /mnt/iso 放到该目录下
     
    4、然后挂载:
    mount -t iso9660 /mnt/iso/CentOS-7-x86_64-DVD-1810.iso /opt/centos
    mount -t iso9660 /mnt/iso/CentOS-7-x86_64-DVD-1810.iso /opt/centos

    5、编写repo文件并指向镜像的挂载目录
     
    # vi /etc/yum.repos.d/local.repo
    添加下面的内容:
     
    [local]
    name=local
    baseurl=file:///opt/centos
    enabled=1
    gpgcheck=0

    6、清除缓存
    # yum clean all
    # yum makecache 把Yum源缓存到本地,加快软件的搜索好安装速度
    # yum list 列出了yum包
     
    [root@localhost ~]# yum clean all
    Loaded plugins: fastestmirror
    Cleaning repos: local
    Cleaning up list of fastest mirrors
    Other repos take up 68 M of disk space (use --verbose for details)
    [root@localhost ~]# yum makecache
    Loaded plugins: fastestmirror
    Determining fastest mirrors
    local | 3.6 kB 00:00:00
    (1/4): local/group_gz | 166 kB 00:00:00
    (2/4): local/primary_db | 6.0 MB 00:00:00
    (3/4): local/filelists_db | 7.1 MB 00:00:00
    (4/4): local/other_db | 2.6 MB 00:00:00
    Metadata Cache Created
     
     
    7、查看yum仓库列表
     
    # yum repolist

    8、开机自动挂载
    在/etc/fstab表中,添加最后的一行,将iso文件永久挂载到系统中
     
     
    # vi /etc/fstab
    /mnt/iso/CentOS-7-x86_64-DVD-1810.iso /opt/centos iso9660 loop 0 0
     
    9、取消挂载(需要的时候再执行):
    卸载挂载目录: # umount /opt/centos
     
  • 相关阅读:
    jQuery 选择器:元素选择器、#id 选择器、.class 选择器
    jQuery 语法:文档就绪事件
    jQuery 安装:多种方法在网页中添加 jQuery
    jQuery 简介:什么事jQuery?为什么要学jQuery?
    SQL 快速参考:SQL语句语法
    SQL FORMAT() 函数:对字段的显示进行格式化
    Mybatis-Plus逻辑删除
    Mybatis-Plus中的ActiveRecord
    Mybatis-Plus使用Oracle的序列
    SpringBoot整合Mybatis-Plus
  • 原文地址:https://www.cnblogs.com/jylee/p/10955434.html
Copyright © 2011-2022 走看看