yum163源配置

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/User_meng/article/details/79793636

背景:因为最近在学习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、升级所有包同时也升级软件和系统内核

扫描二维码关注公众号,回复: 5782695 查看本文章
yum -y update

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

yum clean all

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

yum makecache

成功

猜你喜欢

转载自blog.csdn.net/User_meng/article/details/79793636