CentOS安装yum

执行 yum install vim 命令后发现报错

Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
YumRepo Error: All mirror URLs are not using ftp, http[s] or file.
 Eg. Invalid release/repo/arch combination/
removing mirrorlist with no valid mirrors: /var/cache/yum/x86_64/6/base/mirrorlist.txt
Error: Cannot find a valid baseurl for repo: base

解决办法:

1.备份 /etc/yum.repos.d 目录下文件

[root@node0 ~]# cd /etc/yum.repos.d/
[root@node0 yum.repos.d]# mkdir backup
[root@node0 yum.repos.d]# mv CentOS* backup

2.下载安装源

 网址:http://mirrors.aliyun.com/repo/Centos-6.repo 下载repo文件, 放入/etc/yum.repos.d/  

3.生成缓存

 将 Centos-6.repo 文件中$releasever 修改为7 不然后期可能会报错

  yum clean all--清除yum缓存

  yum makecache--把服务器的包信息下载到本地电脑缓存起来

执行yum makecache 时报错,错误信息

注释掉上述Centos-6.repo中updates第二行代码

[updates]
name=CentOS-7 - 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-6

重新执行yum makecache 成功解决

有的时候因为网络问题不允许联网,需要将yum源本地化

1.将Centos-6.repo 备份

   cp Centos-6.repo Centos-6.repo.back

2.删除base下所有数据并修改 Centos-6.repo信息

# CentOS-6.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=local
baseurl=file:///mnt
gpgcheck=1
enable=1

重新执行yum clean all   yum makecache 报错

df -h  发现磁盘没有挂载

[root@node0 yum.repos.d]# df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/sda3        18G  1.2G   16G   7% /
tmpfs           491M     0  491M   0% /dev/shm
[root@node0 yum.repos.d]# mount /dev/cdrom /mnt
[root@node0 yum.repos.d]# df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/sda3        18G  1.2G   16G   7% /
tmpfs           491M     0  491M   0% /dev/shm
/dev/sda1       194M   28M  157M  15% /boot

重新执行yum makecache 成功

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
要在CentOS安装yum,可以按照以下步骤进行操作: 1. 首先,下载最新的yum软件包。你可以使用wget命令下载最新的yum-3.2.28.tar.gz文件,并解压它。命令如下: ``` wget http://yum.baseurl.org/download/3.2/yum-3.2.28.tar.gz tar xvf yum-3.2.28.tar.gz ``` 2. 下载所需的依赖包。你可以使用FileZilla等工具将依赖包上传到服务器的一个目录下,然后切换到该目录。命令如下: ``` cd /mnt ``` 3. 安装依赖包和yum软件包。你可以使用rpm命令安装依赖包和yum软件包。命令如下: ``` rpm -ivh python-2.7.5-89.el7.x86_64.rpm --force --nodeps rpm -ivh yum-metadata-parser-1.1.4-10.el7.x86_64.rpm --force --nodeps rpm -ivh yum-3.4.3-168.el7.centos.noarch.rpm --force --nodeps rpm -ivh yum-plugin-fastestmirror-1.1.31-54.el7_8.noarch.rpm --force --nodeps ``` 4. 安装完成后,你就成功在CentOS安装yum。 请注意,上述步骤中的软件包版本可能会有所不同,具体的安装命令可能需要根据你的系统和软件包版本进行调整。同时,强烈建议在安装软件包之前备份你的系统数据,以防止意外情况的发生。 #### 引用[.reference_title] - *1* [CentOS安装yum](https://blog.csdn.net/dfgwang1202/article/details/102338002)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insert_down28v1,239^v3^insert_chatgpt"}} ] [.reference_item] - *2* [Centos安装yum(完整教程)](https://blog.csdn.net/u014212540/article/details/127886486)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insert_down28v1,239^v3^insert_chatgpt"}} ] [.reference_item] - *3* [【CentOSCentOS安装yum](https://blog.csdn.net/qq_45797116/article/details/120501064)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insert_down28v1,239^v3^insert_chatgpt"}} ] [.reference_item] [ .reference_list ]

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值