- 积分
- 16844
在线时间 小时
最后登录1970-1-1
|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?开始注册
x
CentOS7 yum安装报错“Could not resolve host: mirrorlist.centos.org; Name or service not known“之解决办法(换源)3 e6 e0 G1 b- C5 b, E0 B, Y
2 Z, |( g6 ]* R! W' i
& z H/ i1 G' `8 Y8 E' A. A' s[root@zabbix-server ~]# yum install devtoolset-11-gcc*
( O. i p& ^& N7 j) P/ gLoaded plugins: fastestmirror+ V( k2 m! {4 D" f/ {
Loading mirror speeds from cached hostfile" B# \. H m0 H
Could not retrieve mirrorlist http://mirrorlist.centos.org/?re ... =os&infra=stock error was
- R8 d3 N: f# `( N* q& p14: curl#6 - "Could not resolve host: mirrorlist.centos.org; Unknown error"
, v* b, `% @8 q1 ^8 T$ r' r0 t
' A$ f% D- B% k4 j2 P U
1 v8 d$ k7 v% r5 b+ D One of the configured repositories failed (Unknown),
" v( M6 C. }, x) D; D4 \7 y and yum doesn't have enough cached data to continue. At this point the only
* w4 b, C" V; P( N* }8 C9 P$ c safe thing yum can do is fail. There are a few ways to work "fix" this:
' L9 G# a/ n0 t( p; K; W, z* |( y3 z8 H" g* Z
1. Contact the upstream for the repository and get them to fix the problem.
1 ?# C, d6 ~. f/ J. B" m; E7 S- _. X% A
2. Reconfigure the baseurl/etc. for the repository, to point to a working" B: E* L0 Y# Y6 D3 _
upstream. This is most often useful if you are using a newer
. x" q0 D/ J6 n/ `+ e distribution release than is supported by the repository (and the. V2 Z( U' R A5 T1 d1 t. M
packages for the previous distribution release still work).
4 W+ T5 _' \& D- L
$ [. c. \7 t6 a, G 3. Run the command with the repository temporarily disabled4 D( Z3 F1 H/ s! r! E" O
yum --disablerepo=<repoid> ...& T5 m% `9 l- {
6 h: w2 C: S2 W) I: c
4. Disable the repository permanently, so yum won't use it by default. Yum
1 ?" j9 h" o7 P$ F' d will then just ignore the repository until you permanently enable it
# l0 L. ~* W: A8 m/ C- R again or use --enablerepo for temporary usage:
, J+ K( O i/ I& D- B1 z- Z# ~' p- O; l6 p2 ~0 j: i0 x, u8 G0 f
yum-config-manager --disable <repoid>0 Z$ q: g3 p& ^ T) i# i( w* F( ^
or
D6 p# l( L+ D5 _ L/ x subscription-manager repos --disable=<repoid>
% ?/ a6 |, r/ B. q& f" {5 l. B5 v, x$ u2 M9 R4 _- S0 [% ~5 Q
5. Configure the failing repository to be skipped, if it is unavailable.
+ f- y, f) K6 [; a. ?/ f Note that yum will try to contact the repo. when it runs most commands,
2 L+ k) Q! O, x1 ^8 b so will have to try and fail each time (and thus. yum will be be much
$ a4 V" _) B E slower). If it is a very temporary problem though, this is often a nice7 B/ f1 J) j2 O
compromise:9 \; m8 p8 ~) }
& T! z% M8 ], d: P1 C yum-config-manager --save --setopt=<repoid>.skip_if_unavailable=true/ }" D- s0 x9 q! [2 L) K
) P/ E* t5 M% B# K' `/ }2 ]/ r
Cannot find a valid baseurl for repo: base/7/x86_64 F; v! s& q( R1 q: K
* [: g* R0 ?% w/ I3 G% I6 E' [
, t# e# `' {: g3 Z0 A
9 w# T. e, |1 `【解决办法】* _$ {9 A8 Y+ }* a
8 T7 D# k, T# H$ n3 p* h9 l
6 O/ _, }! s2 d
! V% z, D E8 P4 }$ d+ @' _' u看到报错日志中加粗的字体,命令行ping mirrorlist.centos.org 不通。试着ping www.baidu.com是正常的,说明DNS解析没问题。基本确认是yum源的问题。- h$ C8 t( `0 Y4 _
i' \& f* [+ ~
0 t1 _8 ?6 X$ H3 C( z) ]3 y" A; A, g) z; e9 W* k
CentOS7更换镜像源
: F/ @, }/ y8 F1、先安装wget
1 L. N8 B9 k2 a# _6 X* |* }: U7 z3 O7 U' |+ h
yum install -y wget, ]) S; ^6 l7 u2 {$ d$ ^5 N; O, k
: {% K' w( W6 s: {5 z0 @" I) _; y) \$ Z0 W% l
% \; |" _" n8 A9 @
2、打开阿里镜像http://mirrors.aliyun.com/& |2 q7 F* _' C) ^7 j) F- t
2 e! E" k4 j( W% M' u
点击,帮助,查看详情:
; u# y1 H4 Q1 I! h1 g4 A9 {/ [% s0 a
9 j8 J1 g v4 Z. f( l1 b, D. @4 g, s- r
3、下载CentOS 7的对应的repo文件! \8 }, l- k* X% c' i7 B2 [
( \! M4 j( @6 x5 }5 @8 mwget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo3 W0 T' @$ C0 n" z. J, o- G0 j# x
) B+ @+ B/ H3 H. u( j#或者
8 `/ W% j! p* d- t: W( q5 z4 U, C; D! B* W; m+ r" u" |% T3 ~
curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo. u2 [# s9 v; q
* w1 u/ ~3 ]- B
% q$ |& b0 O7 N) w4 a l6 ?& q5 m. r8 b: o& |
|
|