zoukankan      html  css  js  c++  java
  • CentOS 7配置网卡信息,并设置yum为阿里云的镜像源

    一、问题场景

      使用virtualbox创建的centos 7版本的linux虚拟机,使用ping mirrors.aliyun.com有返回,但是wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo报超时。

    二、网卡配置(wifi模式)

      虚拟机需要关机

      1.配置网卡1,使虚拟机可以访问互联网

      

       2.配置网卡2,使虚拟机可以与本机建立通信,并且可以访问局域网(wifi模式设置为桥接网卡)

      

      配置好之后就可以启动虚拟机了,这个时候可以在虚拟机里面ping 本机的ip,同时执行wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo能够下载成功(注意:如果单只是配置了桥接网卡,而没有配网络地址转换则会出现笔者的这种情况

    三、配置yum阿里云镜像

      1.禁用yum插件fastestmirror

        1) 修改插件的配置文件

          # cp /etc/yum/pluginconf.d/fastestmirror.conf /etc/yum/pluginconf.d/fastestmirror.conf.bak     (备份)

          # vi  /etc/yum/pluginconf.d/fastestmirror.conf

          #  修改enabled的值,由1改为0,禁用该插件

        2) 修改yum的配置文件

          # cp /etc/yum.conf /etc/yum.conf.bak       (备份)

          # vi /etc/yum.conf

          #  修改plugins的值,由1改为0,不使用该插件

      2.下载阿里云repo覆盖本地配置

        1) 备份CentOS-Base.repo文件

          #  cp /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.bak

        2) 下载并覆盖

          #  wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo

        3) 备份epel.repo文件(本地可能没有,如果本地没有可以不用执行备份操作)

          #  cp /etc/yum.repos.d/epel.repo /etc/yum.repos.d/epel.repo.bak

        4) 下载并覆盖

          #  wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo

      3.清除原来的缓存并生成新的缓存

        #  yum clean all

        #  yum makecache

  • 相关阅读:
    Linux开发环境必备十大开发工具
    mysql executemany与 insert ... ON DUPLICATE KEY UPDATE 一起使用
    python LD_LIBRARY_PATH 靠谱解决办法
    搭建简单ftp,满足windows和ubuntu共享文件
    用类方法作为装饰器装饰同属于本类的另一个方法
    通过类方法名调用类方法
    java将jpg文件转化为base64字节(互转)
    CSS元素居中的方式
    T-SQL语法学习一(持续更新)
    SVN的使用教程(一)
  • 原文地址:https://www.cnblogs.com/yilichentu/p/13356429.html
Copyright © 2011-2022 走看看