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=<repoid> ...
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 <repoid>
or
subscription-manager repos --disable=<repoid>
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=<repoid>.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