美文网首页
Linux基础:常用配置(1) —— Yum配置

Linux基础:常用配置(1) —— Yum配置

作者: dadahai | 来源:发表于2017-11-16 12:55 被阅读0次

    一、配置CentOS 6 网络Yum

    配置centos7 原理一致,只需下载对应版本的repo文件即可。

    1、备份

    yum clean all
    mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
    

    2、下载

    wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.163.com/.help/CentOS6-Base-163.repo
    yum makecache
    

    ######################

    3、如需 epel源,配置如下

    yum install https://mirrors.tuna.tsinghua.edu.cn/epel/6/x86_64/epel-release-6-8.noarch.rpm -y
    yum makecache
    
    导入key:  
    rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6        #可省略
    

    二、配置CentOS 6 本地Yum

    一、挂载镜像文件
    #### 方法1:光驱挂载镜像   (常用)
    [root@localhost ~]# mkdir /mnt/cdrom
    [root@localhost ~]# mount -t iso9660 /dev/cdrom  /mnt/cdrom
    mount: block device /dev/sr0 is write-protected, mounting read-only
    
    #### 方式2:复制光盘文件
    文件/tmp/rehl6.tar.gz是从光盘打包复制过来的,顺便解压到到指定目录/mnt/cdrom
    [root@localhost ~]# mkdir /mnt/cdrom/
    [root@localhost ~]# tar zxvf /tmp/rehl6.tar.gz -C /mnt/cdrom/
    
    #### 方式3:本地已经有iso文件  (常用)
    [root@localhost ~]# mount -o loop /home/redhat6.6-x86_64.iso /mnt/cdrom/
    
    二:配置本地YUM源
    [root@localhost ~]#  cd /etc/yum.repos.d/
    [root@localhost yum.repos.d]# ls
    redhat.repo   rhel-source.repo
    
    [root@localhost yum.repos.d]# vi rhel-media.repo 
    [media]
    name=Red Hat Enterprise Linux 6.6                                
    baseurl=file:///mnt/cdrom                                         
    enabled=1                                                         
    gpgcheck=1                                                        
    gpgkey=file:///mnt/cdrom/RPM-GPG-KEY-redhat-release  
    
    [root@localhost ~]# yum clean all
    [root@localhost ~]# yum makecache
    

    三、报错解决

    > 配置本地yum,出现Errno 14 Could not open/read repomd.xml 错误的解决办法
    1. 把 /etc/yum.repo.d/ 163的repo 或者 系统自带的repo 里的enable=0 禁用就好了
    2. 然后 yum clean all
    3. 最后 yum makecache

    四、其他

    repo资源

    • 网易163 repo源地址:
      CentOS 6 http://mirrors.163.com/.help/CentOS6-Base-163.repo
      CentOS 7 http://mirrors.163.com/.help/CentOS7-Base-163.repo

    • 阿里云 repo源地址:
      CentOS 6 http://mirrors.aliyun.com/repo/Centos-6.repo
      CentOS 7 http://mirrors.aliyun.com/repo/Centos-6.repo

    相关文章

      网友评论

          本文标题:Linux基础:常用配置(1) —— Yum配置

          本文链接:https://www.haomeiwen.com/subject/vlflvxtx.html