zoukankan      html  css  js  c++  java
  • 更换yum源

    在使用linux系统时,默认安装的国外yum源(软件仓库)下载比较慢,所以一般使用的阿里云yum源。但是前不久遇到阿里云出现问题,无法下载软件。一直以为是我的机器出现问题,最后才发现是阿里云的问题,现在特别整理了一下华为源和网易源的替换

    阿里云yum源

    #1、备份
    [root@qls ~]# mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
    
    #2、下载新的CentOS-Base.repo 到/etc/yum.repos.d/
    [root@qls ~]# curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
    
    #3.添加epel源
    [root@qls ~]# curl -o /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
    
    

    网易yum源

    
    wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.163.com/.help/CentOS7-Base-163.repo
    
    或
    
    curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.163.com/.help/CentOS7-Base-163.repo
    
    或
    去网易镜像站下载
    
    #运行以下命令生成缓存
    yum clean all
    yum makecache
    
    #安装epel-release.noarch包,上面已经配置好CentOS源,可以直接yum安装:
    1.yum install epel-release -y
    2.安装完成之后,会在/etc/yum.repo.d/ 目录下生成两个yum源的repo文件:
    3.epel.repo #正式版,所有的软件都是稳定可以信赖的
    4.epel-testing.repo #测试版,使用时需要慎重
    5.但是默认情况下,只有正式版是有效状态的,如果想试试测试版的话,需要修改/etc/yum.repos.d/epel-testing.repo,把enabled=0改成enabled=1即可
    
    epel安装好之后,默认使用的是国外的源(Fedora 官网提供),速度比较慢,如果想要速度快些,可以做下更改,将源更改成国内的源,如中科大(ustc)的EPEL源,执行如下命令即可,详细配置,请见http://mirrors.ustc.edu.cn/help/epel.html
    
    sudo sed -e 's|^metalink=|#metalink=|g' \
             -e 's|^#baseurl=https\?://download.fedoraproject.org/pub/epel/|baseurl=https://mirrors.ustc.edu.cn/epel/|g' \
             -i.bak \
             /etc/yum.repos.d/epel.repo
    
    
    #yum下载软件报错提示缺少秘钥,执行下面命令
    wget -O /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7 https://archive.fedoraproject.org/pub/epel/RPM-GPG-KEY-EPEL-7
    
    

    华为yum源

    
    #华为镜像站
    https://mirrors.huaweicloud.com/
    
    #清理已经存在的yum源
    cd /etc/yum.repos.d && rm -rf * 
    
    wget -O /etc/yum.repos.d/CentOS-Base.repo https://repo.huaweicloud.com/repository/conf/CentOS-7-reg.repo   //下载华为mirrors
    
    #新增epel源
    yum remove  -y  epel-release
    
    yum install -y  https://repo.huaweicloud.com/epel/epel-release-latest-7.noarch.rpm
    
    cd /etc/yum.repo.d/
    
    rm -rf epel-testing.repo
    
    sed -i "s/#baseurl/baseurl/g" /etc/yum.repos.d/epel.repo
    sed -i "s/mirrorlist/#mirrorlist/g" /etc/yum.repos.d/epel.repo
    sed -i "s@http://download.fedoraproject.org/pub@https://repo.huaweicloud.com@g" /etc/yum.repos.d/epel.repo
    
    03、清理缓存测试#
    yum clean all     //清除原有yum缓存
    yum makecache  //刷新缓存
    yum repolist all    //查看所有配置可以使用的文件,会自动刷新缓存
    
    #说明:
    执行命令yum makecache后,如果回显信息为“Another app is currently holding the yum lock”,则需执行命令rm -rf /var/run/yum.pid删除yum.pid文件,然后再执行命令yum makecache生成缓存。
    执行命令yum makecache后,如果回显报错“Error: Cannot retrieve metalink for repository: epel. Please verify its path and try again”,则需执行以下命令,更新证书临时禁用epel源即可。
    yum --disablerepo=epel -y update ca-certificates
    
    如果使用过程中发现某些包不可用,可能是数据正在同步,请过几个小时后再重试。
    
    
  • 相关阅读:
    每天一道LeetCode--141.Linked List Cycle(链表环问题)
    每天一道LeetCode--119.Pascal's Triangle II(杨辉三角)
    每天一道LeetCode--118. Pascal's Triangle(杨辉三角)
    CF1277D Let's Play the Words?
    CF1281B Azamon Web Services
    CF1197D Yet Another Subarray Problem
    CF1237D Balanced Playlist
    CF1239A Ivan the Fool and the Probability Theory
    CF1223D Sequence Sorting
    CF1228D Complete Tripartite
  • 原文地址:https://www.cnblogs.com/backz/p/15329070.html
Copyright © 2011-2022 走看看