zoukankan      html  css  js  c++  java
  • centos 配置yum源

    1、yum配置

    yum的配置文件在  /etc/yum.conf  

    [root@mini ~]# cat /etc/yum.conf 
    [main]
    cachedir=/var/cache/yum/$basearch/$releasever   # yum缓存的目录,下载安装软件包时存放的目录
    keepcache=0       #安装完成后是否保留软件包 0:不保留,1:保留
    debuglevel=2
    logfile=/var/log/yum.log    # yum日志文件,查询过去所做的更新更改
    exactarch=1
    obsoletes=1
    gpgcheck=1           #是否是否进行gpg(GNU Private Guard)校验
    plugins=1
    installonly_limit=5
    bugtracker_url=http://bugs.centos.org/set_project.php?project_id=23&ref=http://bugs.centos.org/bug_report_page.php?category=yum
    distroverpkg=centos-release

    $releasever 当前系统的发行版本,$basearch  CPU体系,使用命令 arch 查看

    2、配置yum源

    yum源文件在 /etc/yum.repos.d/  中

    [root@mini ~]# ls /etc/yum.repos.d/
    CentOS-Base.repo  CentOS-Debuginfo.repo  CentOS-Media.repo  CentOS-Vault.repo

    看到  .repo 结尾的文件都是yum文件,其中,CentOS-Base.repo 是yum 网络源的配置文件,CentOS-Media.repo 是yum 本地源的配置文件,默认使用网络源进行软件包安装与更新

    1)配置本地yum源

    配置本地首先要将网络yum源文件更改后缀名,或者将除了 CentOS-Media.repo 之外的文件全备份到一个目录中,不然默认的还是使用网络yum源

    [root@mini yum.repos.d]# mv CentOS-Base.repo CentOS-Base.repo.backup
    [root@mini yum.repos.d]# cat CentOS-Media.repo 
    # CentOS-Media.repo
    #
    #  This repo can be used with mounted DVD media, verify the mount point for
    #  CentOS-7.  You can use this repo and yum to install items directly off the
    #  DVD ISO that we release.
    #
    # To use this repo, put in your DVD and use it with the other repos too:
    #  yum --enablerepo=c7-media [command]
    #  
    # or for ONLY the media repo, do this:
    #
    #  yum --disablerepo=* --enablerepo=c7-media [command]
    
    [c7-media]
    name=CentOS-$releasever - Media
    baseurl=file:///media/CentOS/
            file:///media/cdrom/
            file:///media/cdrecorder/
    gpgcheck=1
    enabled=0
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

    baseurl 为本地yum源的地址,一般是安装光盘中的安装包,要确保光盘已连接

    重新生成yum缓存

    [root@mini yum.repos.d]# yum clean all
    [root@mini yum.repos.d]# yum makecache

    这样本地yum源就已经配置完成

    2)配置网络yum源

    centos默认的网络源为官方源,官方源为国外的站点,下载与更新速度有点慢,这时将网络源设置为国内的就会比较完美了,国内的开源镜像站点主要有

    阿里云           https://opsx.alibaba.com/mirror
    网易               http://mirrors.163.com/
    清华大学       https://mirrors.tuna.tsinghua.edu.cn/

    在这里我将以阿里云、网易的进行演示

    (1)先备份 CentOS-Base.repo,以后可随时恢复

    (2)下载新的CentOS-Base.repo 到/etc/yum.repos.d/

    阿里的 ,根据自己的版本选择下载

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

    网易的,根据自己的版本选择下载

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

     

    (3)重新生成yum缓存

    [root@mini yum.repos.d]# yum clean all
    [root@mini yum.repos.d]# yum makecache
  • 相关阅读:
    我爱Java系列之---【SpringBoot打成war包部署】
    279. Perfect Squares
    矩阵dfs--走回路
    112. Path Sum
    542. 01 Matrix
    106. Construct Binary Tree from Inorder and Postorder Traversal
    105. Construct Binary Tree from Preorder and Inorder Traversal
    Invert Binary Tree
    563 Binary Tree Tilt
    145 Binary Tree Postorder Traversal
  • 原文地址:https://www.cnblogs.com/yhongji/p/9384780.html
Copyright © 2011-2022 走看看