CentOS使用163镜像

本文介绍如何将CentOS系统的默认源更换为163镜像,包括备份原有配置、下载并配置新的repo文件及清理缓存等步骤。适用于希望提高更新速度的用户。

在使用RedHat企业版的时候,用yum install软件的时候指向的是RedHat的官方地址,如果没有注册是不能使用的,所以当时就想换成CentOS的镜像,后来重新安装了CentOS系统,又觉得163的源比较快,所以就又将默认的源换成了163的镜像。按照163镜像官网上的提示进行操作即可:

http://mirrors.163.com/.help/centos.html)。

1、  首先备份/etc/yum.repos.d/CentOS-Base.repo: mv /etc/yum.repos.d/CentOS-Base.repo/etc/yum.repos.d/CentOS-Base.repo.backup

       2、下载对应版本的repo文件,放入/etc/yum.repo.d/中,我安装的是CentOS6的系统,所以下载的是6版本的文件。文件内容如下,可以将其拷贝并保存为CentOS-Base.repo。CentOS6-Base-163

#CentOS-Base.repo

#

# Themirror system uses the connecting IP address of the client and the

# updatestatus of each mirror to pick mirrors that are updated to and

#geographically close to the client.  Youshould use this for CentOS updates

# unlessyou are manually picking other mirrors.

#

# If themirrorlist= does not work for you, as a fall back you can try the

# remarkedout baseurl= line instead.

#

#

 

[base]

name=CentOS-$releasever- Base - 163.com

baseurl=http://mirrors.163.com/centos/$releasever/os/$basearch/

#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os

gpgcheck=1

gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6

 

#releasedupdates

[updates]

name=CentOS-$releasever- Updates - 163.com

baseurl=http://mirrors.163.com/centos/$releasever/updates/$basearch/

#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates

gpgcheck=1

gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6

 

#additionalpackages that may be useful

[extras]

name=CentOS-$releasever- Extras - 163.com

baseurl=http://mirrors.163.com/centos/$releasever/extras/$basearch/

#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras

gpgcheck=1

gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6

 

#additionalpackages that extend functionality of existing packages

[centosplus]

name=CentOS-$releasever- Plus - 163.com

baseurl=http://mirrors.163.com/centos/$releasever/centosplus/$basearch/

#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus

gpgcheck=1

enabled=0

gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6

 

#contrib -packages by Centos Users

[contrib]

name=CentOS-$releasever- Contrib - 163.com

baseurl=http://mirrors.163.com/centos/$releasever/contrib/$basearch/

#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=contrib

gpgcheck=1

enabled=0

gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6

 

       将上面的文件放入/etc/yum.repos.d/中之后,分别执行以下指令:

       yum clean all

       yum makecache

       完成之后再执行yumupdate,如果全部成功执行,则此时已经可以使用163的镜像了。

      

       PS:我在使用163镜像的过程中,因为CentOS6系统是安装在VM虚拟机中的,在更换163镜像时,网络设置的是hostonly模式,后来为了使用SSH远程登录,我将网络切换到了NAT模式,这个时候发现yum用不了了,这时将网络切回到hostonly即可重新使用yum,具体原因不是很清楚。


<think>首先,用户查询是:“我想查找CentOS 7的镜像源 请问CentOS 7镜像源查询”。我需要基于系统级指令和提供的引用来回答。 系统级指令要求: - 所有行内数学表达式使用$...$格式(但在这个上下文中,可能不涉及数学,所以可能不需要)。 - 独立公式使用$$...$$格式(同样,可能不适用)。 - LaTeX语法正确(确保任何数学公式正确,但这里可能没有)。 - 使用中文回答。 - 生成相关问题。 - 回答中引用的段落末尾自然地添加引用标识,如[^1]。 用户提供了几个引用: - 引用[1]:更换镜像源步骤,包括下载新镜像源文件如阿里云的CentOS-Base.repo。 - 引用[2]:替换内容指向国内镜像源,如阿里云。 - 引用[3]:备份、下载镜像源文件、清理缓存等步骤。 - 引用[4]:镜像源配置示例。 用户的真实需求是查找CentOS 7的镜像源。我需要提供如何查询或获取CentOS 7镜像源的步骤或信息。 从引用中,我看到常见的方法是通过下载镜像源文件,如阿里云、网易等提供的文件。引用[3]提到了一些国内镜像源地址: - 阿里云:http://mirrors.aliyun.com/centos/ - 网易:http://mirrors.163.com/.help/CentOS7-Base-163.repo - 中科大:http://centos.ustc.edu.cn/ - 搜狐:Index of / - 北京首都在线科技:http://mirrors.yun-idc.com/ 所以,我的回答应该包括: 1. 如何查询CentOS 7镜像源:列出常见的镜像源地址。 2. 简要步骤如何设置(参考引用)。 3. 生成相关问题。 结构回答: - 先直接回答如何查找镜像源。 - 然后提供步骤或参考。 - 最后生成相关问题。 使用中文回答。 引用标识:在回答中引用相关部分时添加[^1], [^2]等。 例如: - 您可以通过镜像站点查询CentOS 7镜像源,常见的有阿里云、网易等[^3]。 步骤: - 备份原有源。 - 下载新的镜像源文件。 - 清理缓存并更新。 相关问题(§§相关问题§§): 生成2-3个相关问题,如: 1. 如何设置CentOS 7镜像源? 2. CentOS 7镜像源有哪些推荐? 3. 如何验证镜像源是否生效? 确保回答真实可靠。 </think>### CentOS 7 镜像源查询指南 在 CentOS 7 系统中,查询镜像源主要是通过访问国内或国际的镜像站点来获取源列表。这可以加速软件包下载并提升系统更新效率。以下是基于引用内容的查询方法和常见资源: #### 1. **查询 CentOS 7 镜像源的方法** - **访问官方镜像站点列表**: 您可以直接访问 CentOS 官方或国内镜像站的网址浏览可用源。常见的国内镜像源(速度快且稳定)包括: - **阿里云镜像源**: http://mirrors.aliyun.com/centos/ (提供 CentOS 7 的完整资源)[^3] - **网易镜像源**: http://mirrors.163.com/.help/CentOS7-Base-163.repo (专为 CentOS 7 设计的配置文件)[^3] - **中科大镜像源**: http://centos.ustc.edu.cn/ (学术机构维护,高稳定性)[^3] - **搜狐镜像源**: http://mirrors.sohu.com/centos/ (提供多个版本的源)[^3] - **北京首都在线科技镜像源**: http://mirrors.yun-idc.com/ (企业级镜像服务)[^3] - **通过命令行快速查询**: 如果您在 CentOS 7 系统中,可以使用 `wget` 或 `curl` 命令下载镜像源配置文件,并在文件中查看具体地址。例如,查询阿里云源的配置内容: ```bash wget -O /tmp/aliyun.repo http://mirrors.aliyun.com/repo/Centos-7.repo cat /tmp/aliyun.repo # 查看文件内容,获取镜像源地址 ``` 这将显示类似以下内容(部分示例): ``` [base] name=CentOS-$releasever - Base - Aliyun baseurl=http://mirrors.aliyun.com/centos/$releasever/os/$basearch/ gpgcheck=1 ``` 此方法可快速检索镜像源 URL[^1][^4]。 #### 2. **如何设置镜像源(简要参考)** 查询到镜像源后,您可能需要设置它(这不是查询的核心,但常需后续操作): - **备份原有源**:`mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup`[^3]。 - **下载新源文件**:例如,阿里云源:`wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo`[^1][^3]。 - **清理并更新缓存**:运行 `yum clean all` 和 `yum makecache`,然后测试 `yum update`(可选 `--exclude=kernel*` 避免内核更新)[^3][^4]。 #### 3. **注意事项** - 镜像源地址中的 `$releasever` 和 `$basearch` 会自动替换为您的系统版本(如 CentOS 7)和架构(如 x86_64)[^2][^4]。 - 推荐使用国内镜像源(如阿里云或网易),以解决国际源访问慢的问题[^1][^2]。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值