CentOS遇到问题汇总记录

1 yum 安装软件时提示 File contains no section headers
原因是没有配置yum源

直接暴力解决

  • 删除yum.repos.d目录下所有文件
rm -f /etc/yum.repos.d/*  
  • 然后重新下载阿里的
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo

注:之前没安装wget要先安装

yum -y install wget
  • 清理缓存
yum clean all  

清理缓存时还是会提示File contains no section headers的话就是阿里云的坑了

打开/etc/yum.repos.d/下的目录 会发现有两个文件
一个 Centos-7.repo,一个CentOS-Base.repo
我们发现删除之前的CentOS-Base.repo内容与新的CentOS-Base.repo不一样,反而是新的Centos-7.repo与之前的CentOS-Base.repo内容格式差不多,那就猜测是不是文件名写错了,大胆改正,将Centos-7.repo名字改为CentOS-Base.repo

  • 重命名文件
mv Centos-7.repo CentOS-Base.repo

好了重复第三个步骤,再使用yum安装需要的软件试试?

2 安装完centos 用yum安装软件遇到的问题

  • q1---> fastestmirror不能使用不能使用
    第一步:
[root@localhost ~]# vi  /etc/yum/pluginconf.d/fastestmirror.conf 

文件改动如下

[main]
enabled=1//把1改为0  
verbose=0
always_print_best_host = true
socket_timeout=3
#  Relative paths are relative to the cachedir (and so works for users as well
# as root).
hostfilepath=timedhosts.txt
maxhostfileage=10
maxthreads=15
#exclude=.gov, facebook
#include_only=.nl,.de,.uk,.ie

第二步:

[root@localhost ~]# vi /etc/yum.conf

文件如下

[main]
cachedir=/var/cache/yum/$basearch/$releasever
keepcache=0
debuglevel=2
logfile=/var/log/yum.log
exactarch=1
obsoletes=1
gpgcheck=1
plugins=1//将plugins的值修改为0
installonly_limit=5
bugtracker_url=http://bugs.centos.org/set_project.php?project_id=23&ref=http://bugs.centos.org/bug_report_page.php?category=yum
distroverpkg=centos-release

#  This is the default, if you make this bigger yum won't see if the metadata
# is newer on the remote and so you'll "gain" the bandwidth of not having to
# download the new metadata and "pay" for it by yum not having correct
# information.
#  It is esp. important, to have correct metadata, for distributions like
# Fedora which don't keep old packages around. If you don't like this checking
# interupting your command line usage, it's much better to have something
# manually check the metadata once an hour (yum-updatesd will do this).
# metadata_expire=90m

# PUT YOUR REPOS HERE OR IN separate files named file.repo
# in /etc/yum.repos.d

  • q2--->could not retrieve mirrorlist 错误
    需要root用户或者sudo执行
1.   $ sudo vim /etc/sysconfig/network-scripts/ifcfg-ens33 
  1. 将ONBOOT改为yes,wq!保存退出
  2. 重新启动网络
$ service network restart
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • Linux程序包的管理需要依赖程序包管理工具,程序包管理工具可以实现程序的安装、升级、卸载、查询和校验,等等相关操...
    piziyang12138阅读 4,421评论 0 0
  • Linux程序包的管理需要依赖程序包管理工具,程序包管理工具可以实现程序的安装、升级、卸载、查询和校验,等等相关操...
    Dream_wdl阅读 3,813评论 0 3
  • 转载:http://blog.51cto.com/ywzhou/1577335作用:自动为客户端配置YUM源,为使...
    SkTj阅读 3,730评论 0 0
  • 等待 文/小人鱼 等待是夕阳的诉说 等待是恋人的离别 等待这个词 有时候会让人觉得伤感 等待有时候是为了一种更好的...
    小人鱼_a1a7阅读 5,734评论 39 66
  • 严格意义上来说,大概是在六月份决定考研,七月份定下了专业和书籍,八月份正式开始准备。庆幸的是当时七月份在选择...
    May555阅读 780评论 0 0