【Linux专题】Linux -Centos 常见的异常问题&解决技巧

1、yum 安装出现Could not retrieve mirrorlist http://mirrorlist.centos.org/?release=7&arch=x86_64&repo=os&infra=stoc 详细异常如下

root@localhost opt]# yum update

Loaded plugins: fastestmirror

Could not retrieve mirrorlist http://mirrorlist.centos.org/?release=7&arch=x86_64&repo=os&infra=stock error was

12: Timeout on http://mirrorlist.centos.org/?release=7&arch=x86_64&repo=os&infra=stock: (28, 'Resolving timed out after 30568 milliseconds')

One of the configured repositories failed (Unknown),

and yum doesn't have enough cached data to continue. At this point the only

safe thing yum can do is fail. There are a few ways to work "fix" this:

1. Contact the upstream for the repository and get them to fix the problem.

2. Reconfigure the baseurl/etc. for the repository, to point to a working

upstream. This is most often useful if you are using a newer

distribution release than is supported by the repository (and the

packages for the previous distribution release still work).

3. Run the command with the repository temporarily disabled

yum --disablerepo= ...

4. Disable the repository permanently, so yum won't use it by default. Yum

will then just ignore the repository until you permanently enable it

again or use --enablerepo for temporary usage:

yum-config-manager --disable

or

subscription-manager repos --disable=

5. Configure the failing repository to be skipped, if it is unavailable.

Note that yum will try to contact the repo. when it runs most commands,

so will have to try and fail each time (and thus. yum will be be much

slower). If it is a very temporary problem though, this is often a nice

compromise:

yum-config-manager --save --setopt=.skip_if_unavailable=true

Cannot find a valid baseurl for repo: base/7/x86_64

解决方案(出现的原因是服务resolv.conf未配置可用的网关(GATEWAY)或者DNS):

解决方法一:

编辑/etc/resolv.conf这个文件,在文件末尾添加nameserver 8.8.8.8这即可。

PS:8.8.8.8是GOOGLE公司提供的DNS,该地址是全球通用的,相对来说,更适合国外以及访问国外网站的用户使用,或者使用114.114.114.114,它是国内移动、电信和联通通用的DNS,手机和电脑端都可以使用,干净无广告,解析成功率相对来说更高,国内用户使用的比较多,而且速度相对快、稳定,是国内用户上网常用的DNS。

解决方法二:

配置当前网络的网关地址,本人的当前的官网地址是192.168.2.1 , 所以resolv.conf文件配置如下:

# vi /etc/resolv.conf

namaserver 192.168.2.1

2、yum 安装htop 出现No package htop available.Error: Nothing to do 详细异常如下:

[root@localhost~]# yum install htop -y

Loaded plugins: fastestmirror

Loading mirror speeds from cached hostfile

* base: mirror.lzu.edu.cn

* extras: mirror.jdcloud.com

* updates: mirrors.nju.edu.cn

No package htop available.

Error: Nothing to do

解决方案:

添加一个第三方的源,叫:epel

# yum install epel-release -y

安装完epel后,再次安装htop即可

3、解决centos7 下 root用户删除文件提示:Operation not permitted

提示原因:有可能是文件被保护,可以通过lsattr命令来检查一下是否真的被保护了,文件属性中带“i”,说明文件真的被保护了

# lsattr test.txt

---i---------- test.txt

解决方案:

解除保护:# chattr -i test.txt

 

你可能感兴趣的:(工程类)