yum163源配置

本文提供了一套详细的步骤来帮助用户在RedHat 7.4环境中更换YUM源为163源,包括卸载原有YUM、安装新的YUM组件、配置YUM源以及清理缓存等关键环节。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

背景:因为最近在学习Hadoop集群,及构造镜像,需要通过yum安装ntp,发现本地元无法使用,故切换163的yum源,一下为本人操作步骤。 OS redhat 7.4

参考:https://www.cnblogs.com/edward2013/p/5019594.html

1、查看redhat自带的yum

rpm -qa | grep yum

2、删除redhat自带yum

rpm -qa|grep yum|xargs rpm -e --nodeps

3、检查自带的yum是否删除

rpm -qa | grep yum

4、删除RedHat订阅软件包

rpm -qa | grep subscription-manager-* | xargs rpm -e

5、创建目录管理下载软件包(本人习惯)

mkdir  -p tools/yum163
cd tools/yum163

6、 下载对应的软件包

# 下载软件包,若地址不对,到此网站上找http://mirrors.163.com/centos/7/os/x86_64/Packages/
   wget http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-3.4.3-154.el7.centos.noarch.rpm
   wget http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-cron-3.4.3-154.el7.centos.noarch.rpm
   wget http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-metadata-parser-1.1.4-10.el7.x86_64.rpm
   wget http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.31-42.el7.noarch.rpm
   wget http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-utils-1.1.31-42.el7.noarch.rpm
   wget http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-updateonboot-1.1.31-42.el7.noarch.rpm

7、安装对应的yum

# 因为安装yum时会出现依赖问题,因此按照如下命令安装
   rpm -ivh yum-*  --nodeps 
# --force 即使覆盖属于其它包的文件也强迫安装
# --nodeps 如果该RPM包的安装依赖其它包,即使其它包没装,也强迫安装。

8、写 yum163 配置文件

# 此处vim,是在本地源时安装的
vim /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-$7 - Base - 163.com
#mirrorlist=http://mirrorlist.centos.org/?release=$7&arch=$basearch&repo=os
baseurl=http://mirrors.163.com/centos/7/os/$basearch/
gpgcheck=1
gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7

#released updates
[updates]
name=CentOS-$7 - Updates - 163.com
#mirrorlist=http://mirrorlist.centos.org/?release=$7&arch=$basearch&repo=updates
baseurl=http://mirrors.163.com/centos/7/updates/$basearch/
gpgcheck=1
gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7

#additional packages that may be useful
[extras]
name=CentOS-$7 - Extras - 163.com
#mirrorlist=http://mirrorlist.centos.org/?release=$7&arch=$basearch&repo=extras
baseurl=http://mirrors.163.com/centos/7/extras/$basearch/
gpgcheck=1
gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7

#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$7 - Plus - 163.com
baseurl=http://mirrors.163.com/centos/7/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7

9、升级所有包同时也升级软件和系统内核

yum -y update

10、清理yum缓存,使设置生效

yum clean all

11、将服务器上的软件包信息缓存到本地,以提高搜索安装软件的速度

yum makecache

成功

### 配置163网易云Yum的详细方法 在Linux系统中,配置163网易云Yum可以显著提高软件包下载速度,尤其是在国内网络环境下。以下是具体的配置步骤: #### 1. 备份原有Yum源配置文件 在进行任何修改之前,建议先备份原有的Yum源配置文件。可以通过以下命令完成: ```bash cp /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup ``` 这一步确保了如果新配置出现问题,可以快速恢复到原始状态[^1]。 #### 2. 下载163网易云Yum源配置文件 根据不同的CentOS版本,选择对应的Yum源配置文件地址。例如,对于CentOS 7,使用以下命令下载配置文件: ```bash wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.163.com/.help/CentOS7-Base-163.repo ``` 如果是CentOS 6,则需要替换为相应的URL: ```bash wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.163.com/.help/CentOS6-Base-163.repo ``` 此操作会直接将网易云的Yum源配置文件覆盖到系统的默认位置[^2]。 #### 3. 清除并生成缓存 完成配置文件替换后,需要清除旧的Yum缓存并生成新的缓存以使更改生效。执行以下命令: ```bash yum clean all yum makecache ``` 这两条命令分别用于清除所有缓存和重新构建缓存,确保系统能够正确识别新的Yum[^3]。 #### 4. 验证配置是否成功 为了验证新的Yum是否配置成功,可以尝试更新系统或安装一个软件包。例如: ```bash yum update ``` 或者安装一个测试软件包: ```bash yum install vim ``` 如果过程中没有出现错误提示,并且下载速度明显提升,则说明配置成功。 --- ### 注意事项 - 确保系统已经安装了`wget`工具。如果没有安装,可以使用以下命令安装: ```bash yum -y install wget ``` - 如果需要切换回官方Yum,只需将备份的文件重命名回原名即可: ```bash mv /etc/yum.repos.d/CentOS-Base.repo.backup /etc/yum.repos.d/CentOS-Base.repo ``` ---
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值