- 积分
- 16843
在线时间 小时
最后登录1970-1-1
|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?开始注册
x
CentOS7 yum安装报错“Could not resolve host: mirrorlist.centos.org; Name or service not known“之解决办法(换源)( T2 ?' c( h& x! ~# {' ~- h+ f; f+ b
* }" ]0 Q1 ^! @2 g; N2 n9 B6 Z# g: j8 W1 z' {: Z
[root@zabbix-server ~]# yum install devtoolset-11-gcc*
* L! k7 l2 Y% r8 H7 jLoaded plugins: fastestmirror, z+ t! u1 X$ T
Loading mirror speeds from cached hostfile
. z0 |/ e) t3 `9 A6 aCould not retrieve mirrorlist http://mirrorlist.centos.org/?re ... =os&infra=stock error was$ h! O m# q6 [9 H# }! ]) z1 h
14: curl#6 - "Could not resolve host: mirrorlist.centos.org; Unknown error"
- X/ k' C; W$ R6 S- v0 P2 R& R
" ?) W X! y' ^4 j2 G! h, J9 U; Y4 V/ x5 J# V; Y# k ^- j
One of the configured repositories failed (Unknown),
+ ~ m8 s+ {) w$ E4 ^3 j' g3 d and yum doesn't have enough cached data to continue. At this point the only$ Z$ { u1 D' }) P( `
safe thing yum can do is fail. There are a few ways to work "fix" this:" o+ d7 d! H1 ^1 l( m+ k- R* G& P
7 ]4 H7 f/ x* e7 |
1. Contact the upstream for the repository and get them to fix the problem.
6 Q' _' D$ q6 m& z x5 J4 Q1 B `) Q3 T2 ?1 T& q, V
2. Reconfigure the baseurl/etc. for the repository, to point to a working8 g" _+ j r9 O2 G) K! L
upstream. This is most often useful if you are using a newer
5 f. a* b2 @# U distribution release than is supported by the repository (and the- x, r `5 h1 m0 I6 T' E8 M2 V1 u
packages for the previous distribution release still work).
- D: t R* h! b- [( E4 V- x* {" \+ u- L1 v# v" j" ]
3. Run the command with the repository temporarily disabled
# O- l3 H% x! e# }! F0 A yum --disablerepo=<repoid> ...5 m' j% O- _6 v2 }
+ ?; M/ `. l ~3 q6 o% ^1 Q* A 4. Disable the repository permanently, so yum won't use it by default. Yum
8 j: j. Q: l, g# b! T6 Q+ M' M will then just ignore the repository until you permanently enable it' p# \0 f. B% x, N
again or use --enablerepo for temporary usage:' j9 C7 I' `5 {9 T
/ c/ n8 y+ @- w" F
yum-config-manager --disable <repoid>- q+ A* q2 g% v9 [# T
or2 @+ N& P! t$ B9 y
subscription-manager repos --disable=<repoid>
; Y6 c3 H& s2 k1 P
* }& W% V. [7 x0 | 5. Configure the failing repository to be skipped, if it is unavailable. _" |8 t* u2 X' g' w* {
Note that yum will try to contact the repo. when it runs most commands,
2 R- l7 w0 h) p- y! K2 j: S4 I so will have to try and fail each time (and thus. yum will be be much
' V. v, S- Y% ^0 N- n7 O( Y slower). If it is a very temporary problem though, this is often a nice. q9 c* X: L' B5 V
compromise:* v! G8 [( t- \" n: W% f
& ]: }2 ]+ i* `' r7 r& Z7 ? yum-config-manager --save --setopt=<repoid>.skip_if_unavailable=true
5 V3 }" m w; i- d7 R
; v6 o: X. g6 m+ UCannot find a valid baseurl for repo: base/7/x86_646 T! F; v4 A) G, Z# _/ u, T0 w7 s
0 X/ Q0 ~/ k' _' b X, M% w3 H% Z( p0 o) j; d3 n! ^2 j- ]' o
" }8 B* s4 a, B: m
【解决办法】+ X6 I) G4 [- v, D% ?
6 Q4 G7 I# d$ C/ z2 ?' ^( A9 K: k$ c4 x6 \8 C
+ k1 {; ]& y) f# d+ |看到报错日志中加粗的字体,命令行ping mirrorlist.centos.org 不通。试着ping www.baidu.com是正常的,说明DNS解析没问题。基本确认是yum源的问题。
) R3 @. f% C, t$ ^2 |' z2 J0 \9 V+ z/ g |2 X
% s* J2 }5 l1 {" N& t3 D5 N J- ]2 Q1 ?/ U; w1 n" ~
CentOS7更换镜像源; d; F: C6 x( \' H: T i$ U
1、先安装wget
! S8 s) K; ?: o# Z9 C4 x; J, A2 P& L- K: E; A
yum install -y wget0 E7 Y' W3 N* l! I% j
0 y. k6 b7 w; h2 H% }" t1 e% |3 z$ _5 C1 B4 ~- Z# C+ l' Y8 F
( v1 U" y4 }6 _" j+ A! T
2、打开阿里镜像http://mirrors.aliyun.com/
( d4 P4 s; ` O3 Y" a7 j0 S5 |' W& p# i1 V4 K
点击,帮助,查看详情:3 u% n0 Y _/ S0 D
6 T4 d s% ]# Z9 I5 U* T( J/ U5 E
) F$ ~+ U8 A5 J4 S
7 U( m" k5 y: X# I3 ^6 Y3、下载CentOS 7的对应的repo文件( r- f; f2 Y2 Q- }2 W1 ^- h
2 p5 w0 ]) D0 n9 @& C" r% L* dwget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
/ ]1 D. P1 u8 N6 u7 N4 s0 ^; Q2 d8 Z, `8 N8 |( a& W! J
#或者
" |3 Q8 p f; G$ d9 F% o& R1 Q y" V5 B9 d
curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
* t" _5 z" _! W! x2 H2 J: @( S& O3 [6 b0 `. Z
% u1 ] P a) ]: S) @ Q' r
8 ?, q- Y% v( g, R |
|