zoukankan      html  css  js  c++  java
  • yum centos 修改镜像源

    参考:https://blog.csdn.net/sj349781478/article/details/78736873

    3、清除yum缓存

     

     yum clean all  

    yum makecache  

    先说下安装网络源的步骤:

    修改CentOS默认yum源为mirrors.163.com

    1、首先备份系统自带yum源配置文件/etc/yum.repos.d/CentOS-Base.repo
    1

    [root@localhost ~]# mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup


    2、进入yum源配置文件所在的文件夹
    1

    [root@localhost ~]# cd /etc/yum.repos.d/


    3、下载163的yum源配置文件到上面那个文件夹内

    CentOS7
    1

    [root@localhost yum.repos.d]# wget http://mirrors.163.com/.help/CentOS7-Base-163.repo


    CentOS6
    1

    [root@localhost yum.repos.d]# wget http://mirrors.163.com/.help/CentOS6-Base-163.repo


    CentOS5
    1

    [root@localhost yum.repos.d]# wget http://mirrors.163.com/.help/CentOS5-Base-163.repo


    4、运行yum makecache生成缓存
    1

    [root@localhost yum.repos.d]# yum makecache


    5、这时候再更新系统就会看到以下mirrors.163.com信息
    1
    2
    3
    4
    5
    6

    [root@localhost yum.repos.d]# yum -y update
    已加载插件:fastestmirror, refresh-packagekit, security
    设置更新进程Loading mirror speeds from cached hostfile
    * base: mirrors.163.com
    * extras: mirrors.163.com
    * updates: mirrors.163.com


    修改CentOS默认yum源为mirrors.aliyun.com
    1、首先备份系统自带yum源配置文件/etc/yum.repos.d/CentOS-Base.repo
    1

    [root@localhost ~]# mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup


    2、下载ailiyun的yum源配置文件到/etc/yum.repos.d/
    CentOS7
    1

    [root@localhost ~]# wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo


    CentOS6
    1

    [root@localhost ~]# wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo


    CentOS5
    1

    [root@localhost ~]# wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-5.repo


    3、运行yum makecache生成缓存
    1

    [root@localhost ~]# yum makecache


    4、这时候再更新系统就会看到以下mirrors.aliyun.com信息
    1
    2
    3
    4
    5
    6

    [root@localhost ~]# yum -y update
    已加载插件:fastestmirror, refresh-packagekit, security
    设置更新进程Loading mirror speeds from cached hostfile
    * base: mirrors.aliyun.com
    * extras: mirrors.aliyun.com
    * updates: mirrors.aliyun.com
    是不是很Easy!

    -----------------------------------------------------------------------------------------------------------

    其实我也是按照这个步骤操作的,但是报了错:

    [root@manager yum.repos.d]# yum makecache
    Loaded plugins: fastestmirror, security
    Error: File contains no section headers.
    file: file:///etc/yum.repos.d/6CentOS-Base.repo, line: 1
    '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> '

    这是啥情况,问题在于你下载的不对,这里建议使用浏览器下载,然后上传至服务器。

    [root@manager yum.repos.d]# file CentOS6-Base-163.repo
    CentOS6-Base-163.repo: ASCII English text

    当你使用wget下载的时候,请确认下file出来是否为ASCII English text,必须是这个格式。


    当然了,你可用另外一种方式装
    rpm -ivh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
    你会发现又报错了,百思不得其解~~
    [root@manager yum.repos.d]# rpm -ivh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
    Retrieving http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
    error: /var/tmp/rpm-tmp.COfzVl: not an rpm package (or package manifest):

    还是相同的解决办法,在浏览器输入http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm,然后上传至服务器。

    [root@manager yum.repos.d]# yum install fail2ban
    Loaded plugins: fastestmirror
    Setting up Install Process
    Determining fastest mirrors
    epel | 4.2 kB 00:00
    http://download.fedoraproject.org/pub/epel/6/x86_64/repodata/repomd.xml: [Errno -1] Error importing repomd.xml for epel: Damaged repomd.xml file
    Trying other mirror.
    Error: Cannot retrieve repository metadata (repomd.xml) for repository: epel. Please verify its path and try again


    ---------------------
    作者:JetBrains_孙健
    来源:CSDN
    原文:https://blog.csdn.net/sj349781478/article/details/78736873
    版权声明:本文为博主原创文章,转载请附上博文链接!

  • 相关阅读:
    PHP用curl发送get post put delete patch请求
    ubuntu中设置php7.0-fpm开机自启动
    对计算机领域中间层的理解
    后端程序猿怎能不会的linux命令
    查看磁盘空间和目录大小的命令
    Http协议详解
    supervisor使用总结
    vmware中扩充磁盘
    HDU 4946 共线凸包
    Codeforces_GYM Flight Boarding Optimization
  • 原文地址:https://www.cnblogs.com/lshan/p/10677213.html
Copyright © 2011-2022 走看看