|
|
CentOS7 yum安装报错“Could not resolve host: mirrorlist.centos.org; Name or service not known“之解决办法(换源)/ Y3 l) J. V Q+ `
9 {9 `7 x# Y E3 K/ A/ u6 O4 \6 t
5 k; R, X3 K1 I5 n1 e$ ?[root@zabbix-server ~]# yum install devtoolset-11-gcc*9 z2 i& U) h! ~3 X2 q @$ A8 }
Loaded plugins: fastestmirror
1 o: W7 E& V2 b9 M7 g7 eLoading mirror speeds from cached hostfile
$ Q* w/ D+ g" s# j: r0 u" d7 bCould not retrieve mirrorlist http://mirrorlist.centos.org/?re ... =os&infra=stock error was9 \# i1 d3 j- C, {2 `
14: curl#6 - "Could not resolve host: mirrorlist.centos.org; Unknown error"0 U' ~3 Q3 c1 n0 r* e/ i l
2 n$ H& u. w! e; p
( k# l9 F/ [% G7 y# A One of the configured repositories failed (Unknown),; j" ?+ s' `1 q# {
and yum doesn't have enough cached data to continue. At this point the only5 ?9 h# v8 U: [! C, p
safe thing yum can do is fail. There are a few ways to work "fix" this:- o5 t; g% A% I* T8 v' B
/ {4 g1 ~' P, H' a5 D; i 1. Contact the upstream for the repository and get them to fix the problem.
: Y# u5 }) D1 j
. Y0 p7 E& s: D, M3 m2 ~ 2. Reconfigure the baseurl/etc. for the repository, to point to a working
8 M+ a j6 X: Q9 v' s; q upstream. This is most often useful if you are using a newer) c* W: u# a4 D* R
distribution release than is supported by the repository (and the
7 Y3 j3 g! K2 Q% C packages for the previous distribution release still work).2 Z& g4 O0 {; q" N; X
2 [# @2 b( F6 ]' a7 `
3. Run the command with the repository temporarily disabled3 V- F! \. M8 u1 I% g# Z- n
yum --disablerepo=<repoid> ...
3 z9 d, b/ W% z6 J$ s' I
" i( G$ }' g) {* l* ]- a 4. Disable the repository permanently, so yum won't use it by default. Yum3 H; g0 V' Y/ Q& K; x
will then just ignore the repository until you permanently enable it
/ h: {1 U* N1 {% t' u8 Y again or use --enablerepo for temporary usage:
6 d* G/ p" W( a0 o' ?
S V$ n9 R% X% U1 | D7 B4 P) z+ M) e yum-config-manager --disable <repoid>' D2 H# G3 l' D. w1 z* Q
or
* W, ]; x3 p* S2 X% r" ~" n# u+ D subscription-manager repos --disable=<repoid>
: N, b. ^0 O; P
- e' e. B# l8 s4 A$ h! [( ^ 5. Configure the failing repository to be skipped, if it is unavailable.
# a' e1 N5 g+ O; ~. G$ p Note that yum will try to contact the repo. when it runs most commands," M& A) M, B6 R2 {: x8 [
so will have to try and fail each time (and thus. yum will be be much0 I; c( \, H% t4 b! B! {1 i
slower). If it is a very temporary problem though, this is often a nice
$ j% A# P5 K% I compromise:
) R8 N# h. W! }3 h5 b6 o7 L0 ?( I8 ~' M; k5 w/ m9 P+ A3 S
yum-config-manager --save --setopt=<repoid>.skip_if_unavailable=true# O0 j3 a8 D6 J9 x& ?- F3 U* \
+ h, @" S) s9 B. C+ fCannot find a valid baseurl for repo: base/7/x86_64" @0 I+ N& f/ ? |
4 ?* |) Y) g/ o& Q. I
2 q' [3 m5 W0 w6 |3 P( ~$ G$ r- K- V7 ^1 Q2 O. }# K5 [
【解决办法】2 M$ ^' [+ a" K( {& f
' Y0 \. N$ l# C# u& B
# m) W2 U6 g' v1 l4 {) J# w% c( O' R, I; |. }0 Q2 T
看到报错日志中加粗的字体,命令行ping mirrorlist.centos.org 不通。试着ping www.baidu.com是正常的,说明DNS解析没问题。基本确认是yum源的问题。' W! x! ]& ]8 B+ g9 V
: Z1 S9 }/ t! g5 o; h
7 R M' m1 c. f7 @1 @8 Q* Y2 j. J- S( a" Y: F0 W
CentOS7更换镜像源' m L4 s' ]4 E3 ^
1、先安装wget6 @! Y% b+ m7 E" g& v2 [- F
9 E) @( R3 P1 e' o1 kyum install -y wget/ V$ W: s( F1 _- A
$ H3 ]6 Y9 a0 {+ R
5 _+ c; o) W% _0 E8 `
8 T; e( L- m+ ?+ g1 ?+ Q* n2、打开阿里镜像http://mirrors.aliyun.com/% t$ e/ E6 H# t8 K; x
, ?% z7 F% Q8 I9 P' t
点击,帮助,查看详情:
& E. d9 U8 M" H2 y
1 Z, s5 I) k$ _, Q1 N1 u: V# Z( Y8 Y& Z; P! I( c: i+ f% S. E
: {2 l# X9 p" s
3、下载CentOS 7的对应的repo文件6 L1 L/ j( m: B* i" q
& d0 _1 I( y2 @8 t: {5 K
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo" }, k7 t6 l* V5 g1 N; d* q1 i
. f7 |7 k6 ^* b" V#或者0 \; f" N; j- T( @
2 ~# o/ i) i# o% h( w3 _' i' ^
curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
9 M9 `; P) T9 D# R" Q- S# Z' Q3 {0 K
1 e1 {6 E4 W' C# e: u. D& F
' V3 H) s& q$ k5 q; H3 K
|
|