Redhat7.6更换配置yum源

1 问题

安装的Linux(Redhat7.6纯净系统),内在工具很少

1.1 如果没有注册的话,就没法使用yum源,也就没办法用yum install来安装软件包

1.2 内置没有wget安装包。无法用rpm -ivh wget 来安装。

2 解决思路

2.1 在镜像网站找到wget包,传到Linux上。通过rpm完成wget的安装。## 问题1.2解决

2.2 在镜像网站找到yum安装包,使用wget下载,再用rpm -ivh安装。

2.3 配置.repo文件

2.4 验证yum是否成功。 ##问题1.1解决

3 实现过程

镜像网站:Index of /centos-vault/7.6.1810/os/x86_64/Packages/ (163.com)
3.1
在镜像网站下载wget包,传至.repo文件下。(这里使用XFTP 7)
Image
切换至 /etc/yum.repos.d/ 文件夹下,通过rpm安装wget。

[root@localhost ~]# cd /etc/yum.repos.d/
[root@localhost ~]# yum.repos.d]# rpm -ivh wget-1.14-18.el7.x86_64.rpm

Image

3.2
查看系统版本及已安装的yum包

[root@localhost yum.repos.d]# cat /etc/redhat-release
[root@localhost yum.repos.d]# rpm -qa|grep yum

Image
删除所有yum包并再次查看

[root@localhost yum.repos.d]# rpm -qa | grep yum | xargs rpm -e --nodeps
[root@localhost yum.repos.d]# rpm -qa|grep yum

Image
通过wget到镜像网站下载所需要的包。


wget http://mirrors.163.com/centos-vault/7.6.1810/os/x86_64/Packages/rpm-4.11.3-35.el7.x86_64.rpm
wget http://mirrors.163.com/centos-vault/7.6.1810/os/x86_64/Packages/python-urllib3-1.10.2-5.el7.noarch.rpm
wget http://mirrors.163.com/centos-vault/7.6.1810/os/x86_64/Packages/yum-3.4.3-161.el7.centos.noarch.rpm
wget http://mirrors.163.com/centos-vault/7.6.1810/os/x86_64/Packages/yum-metadata-parser-1.1.4-10.el7.x86_64.rpm
wget http://mirrors.163.com/centos-vault/7.6.1810/os/x86_64/Packages/yum-rhn-plugin-2.0.1-10.el7.noarch.rpm
wget http://mirrors.163.com/centos-vault/7.6.1810/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.31-50.el7.noarch.rpm

Image
下载后进行强制安装

rpm -ivh --force rpm-4.11.3-35.el7.x86_64.rpm python-urllib3-1.10.2-5.el7.noarch.rpm yum-3.4.3-161.el7.centos.noarch.rpm yum-metadata-parser-1.1.4-10.el7.x86_64.rpm yum-rhn-plugin-2.0.1-10.el7.noarch.rpm yum-plugin-fastestmirror-1.1.31-50.el7.noarch.rpm

Image
安装完成,进行.repo文件的配置
vi redhat.repo 将下面内容粘贴进去,报存并退出。
vi redhat.repo
Image

# 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 - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/7/os/$basearch/
        http://mirrors.aliyuncs.com/centos/7/os/$basearch/
        http://mirrors.cloud.aliyuncs.com/centos/7/os/$basearch/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7

#released updates
[updates]
name=CentOS-$releasever - Updates - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/7/updates/$basearch/
        http://mirrors.aliyuncs.com/centos/7/updates/$basearch/
        http://mirrors.cloud.aliyuncs.com/centos/7/updates/$basearch/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7

#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/7/extras/$basearch/
        http://mirrors.aliyuncs.com/centos/7/extras/$basearch/
        http://mirrors.cloud.aliyuncs.com/centos/7/extras/$basearch/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7

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

#contrib - packages by Centos Users
[contrib]
name=CentOS-$releasever - Contrib - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/7/contrib/$basearch/
        http://mirrors.aliyuncs.com/centos/7/contrib/$basearch/
        http://mirrors.cloud.aliyuncs.com/centos/7/contrib/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7

再将文件名改为CentOS-Base.repo
mv redhat.repo CentOS-Base.repo

3 结果

最后清除缓存并更新
yum clean all
yum makecache
最后进行测试:
yum -y install vim
成功搞定!

参考引用文章网址:

  1. (65条消息) red hat7安装wget_圆公子的博客-CSDN博客
  2. (65条消息) RedHat7.6 配置yum源_redhat yum源_TAM·的博客-CSDN博客
  3. (65条消息) RedHat7.6更新换阿里yum源_redhot7.6 阿里更新_CatchDreamCoder的博客-CSDN博客
  4. redhat6怎么配置yum源 - 建站服务器 - 亿速云 (yisu.com)
  5. (65条消息) Redhat更换yum源_Softnothings的博客-CSDN博客
  6. Redhat7.6Linux本地的yum源配置 - tomhaha - 博客园 (cnblogs.com)
  • 2
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值