美文网首页
CentOS遇到问题汇总记录

CentOS遇到问题汇总记录

作者: DDstar | 来源:发表于2020-04-04 10:52 被阅读0次

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

相关文章

网友评论

      本文标题:CentOS遇到问题汇总记录

      本文链接:https://www.haomeiwen.com/subject/nnudphtx.html