当前位置: 首页 > news >正文

Linux学习笔记 CenOS6.3 yum No package xxx available

环境CenOS

[root@hncuc ~]# cat /etc/issue
CentOS release 6.2 (Final)
Kernel \r on an \m

安装gcc的时候提示没有包

[root@hncuc ~]# sudo yum install gcc  gcc-c++ libstdc++-devel
Loaded plugins: refresh-packagekit, security
Setting up Install Process
No package gcc available.
No package gcc-c++ available.
Nothing to do

设置阿里云镜像
参考centos6 yum源失效的最新操作方式,解决:[Errno 14] PYCURL ERROR 22
1、备份

mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup

在这里插入图片描述
2、下载新文件

wget --no-check-certificate -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-6.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-$releasever - Base - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/$releasever/os/$basearch/http://mirrors.aliyuncs.com/centos/$releasever/os/$basearch/http://mirrors.cloud.aliyuncs.com/centos/$releasever/os/$basearch/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-6#released updates 
[updates]
name=CentOS-$releasever - Updates - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/$releasever/updates/$basearch/http://mirrors.aliyuncs.com/centos/$releasever/updates/$basearch/http://mirrors.cloud.aliyuncs.com/centos/$releasever/updates/$basearch/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-6#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/$releasever/extras/$basearch/http://mirrors.aliyuncs.com/centos/$releasever/extras/$basearch/http://mirrors.cloud.aliyuncs.com/centos/$releasever/extras/$basearch/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-6#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/$releasever/centosplus/$basearch/http://mirrors.aliyuncs.com/centos/$releasever/centosplus/$basearch/http://mirrors.cloud.aliyuncs.com/centos/$releasever/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-6#contrib - packages by Centos Users
[contrib]
name=CentOS-$releasever - Contrib - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/$releasever/contrib/$basearch/http://mirrors.aliyuncs.com/centos/$releasever/contrib/$basearch/http://mirrors.cloud.aliyuncs.com/centos/$releasever/contrib/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-6

3、替换源文件配置, 使用https://mirrors.aliyun.com/centos-vault/

sed -i -e '/mirrors.cloud.aliyuncs.com/d' -e '/mirrors.aliyuncs.com/d' /etc/yum.repos.d/CentOS-Base.repo
sed -i  's/http/https/g' /etc/yum.repos.d/CentOS-Base.repo

我CenOS版本6.2

sed -i  's/$releasever/6.2/g' /etc/yum.repos.d/CentOS-Base.repo
sed -i  's/centos/centos-vault/g' /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-6.2 - Base - mirrors.aliyun.com
failovermethod=priority
baseurl=https://mirrors.aliyun.com/centos-vault/6.2/os/$basearch/
gpgcheck=1
gpgkey=https://mirrors.aliyun.com/centos-vault/RPM-GPG-KEY-CentOS-6#released updates 
[updates]
name=CentOS-6.2 - Updates - mirrors.aliyun.com
failovermethod=priority
baseurl=https://mirrors.aliyun.com/centos-vault/6.2/updates/$basearch/
gpgcheck=1
gpgkey=https://mirrors.aliyun.com/centos-vault/RPM-GPG-KEY-CentOS-6#additional packages that may be useful
[extras]
name=CentOS-6.2 - Extras - mirrors.aliyun.com
failovermethod=priority
baseurl=https://mirrors.aliyun.com/centos-vault/6.2/extras/$basearch/
gpgcheck=1
gpgkey=https://mirrors.aliyun.com/centos-vault/RPM-GPG-KEY-CentOS-6#additional packages that extend functionality of existing packages
[centos-vaultplus]
name=CentOS-6.2 - Plus - mirrors.aliyun.com
failovermethod=priority
baseurl=https://mirrors.aliyun.com/centos-vault/6.2/centos-vaultplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=https://mirrors.aliyun.com/centos-vault/RPM-GPG-KEY-CentOS-6#contrib - packages by Centos Users
[contrib]
name=CentOS-6.2 - Contrib - mirrors.aliyun.com
failovermethod=priority
baseurl=https://mirrors.aliyun.com/centos-vault/6.2/contrib/$basearch/
gpgcheck=1
enabled=0
gpgkey=https://mirrors.aliyun.com/centos-vault/RPM-GPG-KEY-CentOS-6

4、
清除缓存

yum clean all

重新生成缓存

yum makecache

在这里插入图片描述

gcc可以正常安装了
在这里插入图片描述

http://www.lryc.cn/news/248608.html

相关文章:

  • 【探索Linux】—— 强大的命令行工具 P.18(进程信号 —— 信号捕捉 | 信号处理 | sigaction() )
  • vue3+ts v-model 深度学习
  • 网络通信概述
  • <avue-crud/>,二级表头,children下字典项的dicUrl失效问题
  • FastApi接收不到Apifox发送的from-data字符串_解决方法
  • Python高级数据结构——堆(Heap)
  • linux 讨论题合集(个人复习)
  • 浅析SD-WAN技术如何加强企业网络安全
  • 测试相关-面试高频
  • 基于Java web的多功能游戏大厅系统的开发与实现
  • 【MySQL工具】my2sql-快速解析binlog
  • vueRouter常用属性
  • Qt5.15.2的镜像网址
  • Python隐藏特性:字符串驻留、常量折叠
  • 2-Python与设计模式--工厂类相关模式
  • PGP 遇上比特币
  • 项目demo —— GPT 聊天机器人
  • Airtest进阶使用篇!提高脚本稳定性 + 批量运行脚本!
  • 数据库系统概述之数据库优化
  • 【error:Custom elements in iteration require ‘v-bind:key‘ directives】元素绑定:key
  • TA-Lib学习研究笔记(二)——Overlap Studies下
  • 三.排序与分页
  • 第一个php扩展开发的demo
  • A stop job is running for Session c1 of user root (25s 1min 30s)问题
  • C语言进阶之笔试题详解(2)
  • 【开源】基于Vue和SpringBoot的独居老人物资配送系统
  • Linux常用命令----cp 命令
  • 前端:HTML鼠标样式及其对应的CSS属性值
  • Linux 命令chgrp chown chmod
  • 网络篇---第七篇