更新yum源解决:centos7 安装 Redis ,make编译报错,安装gcc 提示:没有可用软件包 gcc

全程使用的是XShell敲的命令。

首先说一下遇到的问题:

我的centos是虚拟机。我在物理机上下载好了redis压缩包redis-5.0.5.tar.gz,然后 rz 命令上传到虚拟机,解压,编译。

问题出现了:编译失败  

[root@slave1 redis-5.0.5]# make
cd src && make all
make[1]: 进入目录“/softwares/redis-5.0.5/src”
    CC Makefile.dep
make[1]: 离开目录“/softwares/redis-5.0.5/src”
make[1]: 进入目录“/softwares/redis-5.0.5/src”
    CC adlist.o
/bin/sh: cc: 未找到命令
make[1]: *** [adlist.o] 错误 127
make[1]: 离开目录“/softwares/redis-5.0.5/src”
make: *** [all] 错误 2

解决:更新yum  repo源 

1、备份,为了更新失败时切换回去,(好像从来也没有还原过)

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


2、进入yum源配置文件夹

cd /etc/yum.repos.d/

3、根据centos版本下载对应的新源

CentOS7

wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo

                                                                                6
                                                                                5
                                        如果是centos 6  或者 centos 5  更改一下数字即可

因为是最小安装linux,我的centos上没有wget。

因此我使用主机访问: http://mirrors.aliyun.com/repo/Centos-7.repo

下载成功后使用 rz 命令  上传到当前目录(/etc/yum.repos.d/)

 

4、yum makecache 生成缓存,会把新下载CentOS-Base.repo源生效。
更新时会报某个aliyun timeout,他会自动尝试阿里其他镜像,最后自己会用基础镜像,然后自动更新一部分。因为基础镜像过时了。

[root@slave1 yum.repos.d]# yum makecache
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.aliyun.com
 * extras: mirrors.aliyun.com
 * updates: mirrors.aliyun.com
base                                                                                                                                           | 3.6 kB  00:00:00     
bintray--sbt-rpm                                                                                                                               | 1.3 kB  00:00:00     
docker-ce-stable                                                                                                                               | 3.5 kB  00:00:00     
extras                                                                                                                                         | 2.9 kB  00:00:00     
updates                                                                                                                                        | 2.9 kB  00:00:00     
base/7/x86_64/primary_db       FAILED                                          
http://mirrors.cloud.aliyuncs.com/centos/7/os/x86_64/repodata/04efe80d41ea3d94d36294f7107709d1c8f70db11e152d6ef562da344748581a-primary.sqlite.bz2: [Errno 14] curl#6 - "Could not resolve host: mirrors.cloud.aliyuncs.com; Unknown error"
正在尝试其它镜像。
(1/14): base/7/x86_64/group_gz                                                                                                                 | 165 kB  00:00:00     
(2/14): bintray--sbt-rpm/other                                                                                                                 | 1.6 kB  00:00:01     
(3/14): bintray--sbt-rpm/filelists                                                                                                             | 8.6 kB  00:00:01     
(4/14): extras/7/x86_64/filelists_db                                                                                                           | 217 kB  00:00:00     
(5/14): extras/7/x86_64/primary_db                                                                                                             | 165 kB  00:00:00     
(6/14): docker-ce-stable/x86_64/other_db                                                                                                       | 113 kB  00:00:00     
(7/14): extras/7/x86_64/other_db                                                                                                               | 106 kB  00:00:00     
(8/14): updates/7/x86_64/filelists_db                                                                                                          | 4.5 MB  00:00:00     
(9/14): docker-ce-stable/x86_64/filelist
  • 4
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值