1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
Could not retrieve mirrorlist http:
//mirrorlist
.centos.org/?release=7&arch=x86_64&repo=os&infra=stock32 error was
14: curl
#6 - "Could not resolve host: mirrorlist.centos.org; Unknown error"
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. Disable the repository, 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>
4. 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
|
googel了一下這個錯誤,發現報錯原因是“本機無法連接網絡的網絡設置”的原因。
於是參照“How to Setup network on centos 7”這篇博文,配置了下DHPC,最終解決了這個error。
配置CentOS 7的網絡,步驟如下:
1.在終端中輸入以下命令,查看安裝在本機的網卡:
1
2
3
4
5
6
|
[xi@localhost ~]$ nmcli d
//
以下顯示是已經配置到網絡后的本機網絡狀況。
DEVICE TYPE STATE CONNECTION
virbr0 bridge connected virbr0
eno16777736 ethernet connected eno16777736
virbr0-nic ethernet disconnected --
lo loopback unmanaged --
|
2.GUI 或 命令模式的網絡配置:
GUI模式:
Step #1 » 在終端中輸入以下命令,打開網絡管理員。接着選擇“Edit a connection”后按回車鍵(使用TAB鍵進行選擇的選項)。
1
|
[xi@localhost ~]$ nmtui
|
Step #2 » 現在你可以看到所有的網絡接口,選擇一個(我選擇了“eno16777736”),然后點擊“ Edit “。
Step 3 » 動態配置 或 靜態配置
» 動態配置
1.在“IPv4 CONFIGURATION”配置選擇“<Automatic>”;
2.選擇“Automatically connect”復選框;
3.點擊OK鍵,退出網絡管理器。最后,通過鍵入以下命令重新啟動網絡服務。
1
|
[xi@localhost ~]$ systemctl restart network
|
現在你的服務器將從DHCP獲得IP地址。
» 靜態配置
1.在“IPv4 CONFIGURATION”配置選擇”Manual”;
2.添加與子網掩碼,網關和DNS服務器(參見下圖)的IP地址;
3.選擇“Automatically connect”復選框;
4.點擊OK鍵,退出網絡管理器。現在,通過鍵入以下命令重新啟動網絡服務。
1
|
[xi@localhost ~]$ systemctl restart network
|
現在你的服務器具有靜態IP。
命令模式:
Step #1 » 切換到/etc/sysconfig/network-scripts/目錄下,打開“ifcfg-eno16777736”文件:
1
|
xi@localhost network-scripts]$
cd
/etc/sysconfig/network-scripts/
|
1
|
[xi@localhost network-scripts]$ vim ifcfg-eno16777736
|
打開ifcfg-eno16777736文件,展開如下:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
1 TYPE=Ethernet
2 BOOTPROTO=none
3 DEFROUTE=
yes
4 IPV4_FAILURE_FATAL=no
5 IPV6INIT=
yes
6 IPV6_AUTOCONF=
yes
7 IPV6_DEFROUTE=
yes
8 IPV6_FAILURE_FATAL=no
9 NAME=enp0s17
10 UUID=7f1aff2d-b154-4436-9497-e3a4dedddcef
11 ONBOOT=no
12 HWADDR=00:0C:29:A1:B5:D6
13 PEERDNS=
yes
14 PEERROUTES=
yes
15 IPV6_PEERDNS=
yes
16 IPV6_PEERROUTES=
yes
|
Step #3 » 動態配置 或 靜態配置
» 動態配置
依次將第2行和第11行替換為:
BOOTPROTO=dhcp
ONBOOT=yes
然后,通過鍵入以下命令重新啟動網絡服務:
1
|
[xi@localhost ~]$ systemctl restart network
|
連接外網,測試網絡是否成功:
1
|
xi@localhost ~]$
ping
www.baidu.com
|
» 靜態配置
依次將第2行和第11行替換為:
BOOTPROTO=static
ONBOOT=yes
然后,在文件末尾添加以下4行:
1
2
3
4
|
IPADDR=172.27.0.32
NETMASK=255.255.255.0
GATEWAY=172.27.0.1
DNS1=172.27.0.5
|
最后,通過鍵入以下命令重新啟動網絡服務:
1
|
[xi@localhost ~]$ systemctl restart network
|
現在你的服務器具有靜態IP。
此外,你可以通過打開文件/ etc / sysconfig / network來修改主機名和DNS。
centos查詢本機的外網輸入 curl ifconfig.me 命令即可查看:
centos查詢上網網關IP,tracepath www.baidu.com
1
2
3
4
|
HOSTNAME = server.krizna.com
DNS1 = 192.168.1.5
DNS2 = 8.8. 8.8
SEARCH = krizna.com
|