centos7配置国内yum源

文章目录

    • 1、什么是yum仓库?
    • 2、yum仓库配置
      • 2.1、阿里镜像仓库配置
        • 2.1.1、配置步骤
        • 2.1.2、epel源 安装和配置
        • 2.1.3、查看yum源
      • 2.2、配置 清华大学镜像仓库

1、什么是yum仓库?

yum仓库就是使用yum命令下载软件的镜像地址。

我们通常使用 yum install 命令来在线安装 linux系统的软件, 这种方式可以自动处理依赖性关系,并且一次安装所有依赖的软体包,但是经常会遇到从国外镜像下载速度慢,无法下载的情况。那么此时我们就需要把我们的yum 源改为国内的镜像。

yum的配置文件

yum 的配置文件在 /etc/yum.repos.d 目录下, 其中有多个配置文件,每一个配置文件中都可以配置一个或多个repository, 但是最终会被合并为一个交给系统,所以多个文件只是为了方便管理。

2、yum仓库配置

下面提供了多个镜像仓库配置说明,实际使用时,选择其中一个配置即可。

2.1、阿里镜像仓库配置

进入阿里镜像仓库网站 https://opsx.alibaba.com/mirror

找到centos,点击右边的 帮助 ,看到阿里镜像仓库给出的yum的配置说明。

2.1.1、配置步骤

根据官网的说明,我们详细说说每步骤的意思。

(1)、备份,将 CentOS-Base.repoCentOS-Base.repo.backup

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

(2)、下载新的 http://mirrors.aliyun.com/repo/Centos-7.repo,并命名为CentOS-Base.repo

wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
或者
curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo

(3)、清除缓存

yum clean all     # 清除系统所有的yum缓存
yum makecache     # 生成yum缓存
yum update

2.1.2、epel源 安装和配置

(1)、查看可用的epel源

[[email protected] yum.repos.d]$ yum list | grep epel-release
epel-release.noarch                         7-11                       extras
[[email protected] yum.repos.d]$ 

(2)、安装 epel

[[email protected] yum.repos.d]$ yum install -y epel-release
......省略.....

(3)、配置阿里镜像提供的epel源

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

4、清除缓存

yum clean all     # 清除系统所有的yum缓存
yum makecache     # 生成yum缓存
yum update 

2.1.3、查看yum源

查看所有的yum源:

yum repolist all

查看可用的yum源:

yum repolist enabled

2.2、配置 清华大学镜像仓库

地址: https://mirrors.cnnic.cn/

点击 ? 进入帮助说明页面 https://mirrors.cnnic.cn/help/centos/。

页面提供了 CentOS5CentOS6CentOS7 的镜像仓库配置,下面列出的是CentOS7的配置。

(1)、首先备份 CentOS-Base.repo

mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.bak

(2)、之后启用 TUNA 软件仓库, 将清华大学镜像仓库信息写入 /etc/yum.repos.d/CentOS-Base.repo

# CentOS-Base.repo
#
# The mirror system uses the connecting IP address of the client and the
# update status of each mirror to pick mirrors that are updated to and
# geographically close to the client.  You should use this for CentOS updates
# unless you are manually picking other mirrors.
#
# If the mirrorlist= does not work for you, as a fall back you can try the
# remarked out baseurl= line instead.
#
#

[base]
name=CentOS-$releasever - Base
baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/os/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

#released updates
[updates]
name=CentOS-$releasever - Updates
baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/updates/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras
baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/extras/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus
baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/centosplus/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

(3)、清除缓存

yum clean all     # 清除系统所有的yum缓存
yum makecache     # 生成yum缓存
yum update 

原文地址:https://blog.csdn.net/xiaojin21cen/article/details/84726193

原文地址:https://www.cnblogs.com/jpfss/p/10929258.html

时间: 2024-08-10 20:39:20

centos7配置国内yum源的相关文章

CentOS7 配置163 yum源(详细步骤)

CentOS7 配置163 yum源 1)下载repo文件 wget http://mirrors.163.com/.help/CentOS7-Base-163.repo 2)备份并替换系统的repo文件 cp CentOS7-Base-163.repo /etc/yum.repos.d/ cd /etc/yum.repos.d/ mv CentOS-Base.repo CentOS-Base.repo.bak mv CentOS7-Base-163.repo CentOS-Base.repo

虚拟机centos7配置本地yum源

在虚拟机中要使用yum命令,就要先配置一下yum源,下面就分享一下这个过程: 1. 挂载iso到vmware,首先得确保CD/DVD连接到镜像.可以这样操作 2. 执行下面的命令 # mkdir /mnt/cdrom # mount /dev/cdrom /mnt/cdrom 3. 建立本地的yum源配置文件local.repo,配置文件内容如下: [serid] name=lty   ---->名字可以随意取 baseurl=file:///mnt/cdrom   ---->上面创建的目录

Centos配置国内yum源

网易(163)yum源是国内最好的yum源之一 ,无论是速度还是软件版本,都非常的不错,将yum源设置为163yum,可以提升软件包安装和更新的速度,同时避免一些常见软件版本无法找到.具体设置方法如下: 1,进入yum源配置目录cd /etc/yum.repos.d 2,备份系统自带的yum源mv CentOS-Base.repo CentOS-Base.repo.bk下载163网易的yum源:wget http://mirrors.163.com/.help/CentOS6-Base-163.

CentOS7配置本地Yum源

从CentOS7官网下载DVD中存在需要的大部分软件,所以在没有网络的情况下可以配置yum源为本地的DVD,下载速度快,软件稳定.1. 如果使用虚拟机,那么就在虚拟机中挂载DVD的iso文件.2. 使用如下命令新建一个挂载点并挂载修改yum源配置 mkdir /media/CentOS mount -t auto /dev/cdrom /media/CentOS 通过命令mount可以查看已挂载的结果如下所示: 3. 修改yum源配置,把CentOS-Base.repo文件备份 cd /etc/

CentOS-7配置阿里YUM源

配置阿里云YUM源:1,备份 #cd /etc/yum.repo.d/#mkdir repos#mv *.repo repos2,下载 #wget wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo 3,#yum install -y epel-release.noarch 按装epel扩展源4,之后运行yum makecache生成缓存 原文地址:https://blog.

centos7配置本地yum源 使用安装镜像安装软件

1. 在cdrom挂载安装镜像.(物理机则插入光盘,虚拟机则在CD/DVD中选择iso镜像.如果虚拟机mount时提示找不到则在选择iso镜像上方勾选“已连接”和“启动时连接”,或者点击 虚拟机下方状态栏的光盘图标.) 2. 创建挂载点mkdir /media/centos 3. 挂载镜像 mount -t auto /dev/cdrom /media/centos (现在可以使用rpm安装镜像里的rpm包,安装nano编辑器命令如下:rpm -ivh /media/centos/Package

为centos7配置阿里yum源遇到的问题以及解决方法

[问题背景] 卸载安装的Ambari,之前都是因为卸载不干净.这次重写安装,卸载完之后,发现httpd无法启动,所以想卸载httpd进行重新安装,但是执行命令yum list | grep httpd报错. [遇到的问题] 配置过程很简单,去https://opsx.alibaba.com/mirror 获得执行命令: 但是我在执行yum makecache时报错,报错信息如下: Loaded plugins: fastestmirror, langpacks, priorities Repos

CentOS7.2配置本地yum源

1.检查是否有本地yum源 1)检查是否能连网 ping www.baidu.com 2)检查是否有本地yum源 yum list 2.挂载镜像文件 以上检查,说明确实是内网,也确实没有本地yum源,那我们就需要配置一个本地yum源,去解决某些软件的依赖安装 1)查看操作系统 cat /etc/redhat-release 2)上传相应的镜像文件至服务器 3)挂载镜像文件 将刚刚上传的镜像文件挂载到/home/iso/目录下(你可以挂载到自己的目录下,如果是挂载到镜像文件的路径,之前的镜像文件会

Centos7.2环境准备_配置本地yum源 关闭firewalld和selinux

一.配置本地yum源 #查看yum源目录[[email protected] ~]# ll /etc/yum.repos.d/总用量 28-rw-r--r--. 1 root root 1664 12月 9 2015 CentOS-Base.repo-rw-r--r--. 1 root root 1309 12月 9 2015 CentOS-CR.repo-rw-r--r--. 1 root root 649 12月 9 2015 CentOS-Debuginfo.repo-rw-r--r--.