ubuntu 16.10 konsole 连接 gb.archive.ubuntu.com 非常慢

ubuntu 16.10 konsole 连接 gb.archive.ubuntu.com 非常慢

为什么apt-get install下面这一行总是很慢?

0% [Connecting to gb.archive.ubuntu.com (2001:67c:1560:8001::14)]

有时需要 5 到 10 分钟。大多数时候它就卡在那里。

例如:

$ sudo apt-get install php-pgsql
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages were automatically installed and are no longer required:
  gyp libjs-inherits libjs-node-uuid libuv1 libuv1-dev linux-headers-4.8.0-22 linux-headers-4.8.0-22-generic linux-image-4.8.0-22-generic linux-image-extra-4.8.0-22-generic
  node-abbrev node-ansi node-ansi-color-table node-archy node-async node-block-stream node-combined-stream node-cookie-jar node-delayed-stream node-forever-agent node-form-data
  node-fstream node-fstream-ignore node-github-url-from-git node-glob node-graceful-fs node-gyp node-inherits node-ini node-json-stringify-safe node-lockfile node-lru-cache
  node-mime node-minimatch node-mkdirp node-mute-stream node-node-uuid node-nopt node-normalize-package-data node-npmlog node-once node-osenv node-qs node-read
  node-read-package-json node-request node-retry node-rimraf node-semver node-sha node-sigmund node-slide node-tar node-tunnel-agent node-underscore node-which
Use 'sudo apt autoremove' to remove them.
The following additional packages will be installed:
  php7.0-pgsql
The following NEW packages will be installed
  php-pgsql php7.0-pgsql
0 to upgrade, 2 to newly install, 0 to remove and 1 not to upgrade.
Need to get 57.7 kB of archives.
After this operation, 223 kB of additional disk space will be used.
Do you want to continue? [Y/n] y
0% [Connecting to gb.archive.ubuntu.com (2001:67c:1560:8001::14)]
Get:1 http://gb.archive.ubuntu.com/ubuntu yakkety-updates/main amd64 php7.0-pgsql amd64 7.0.13-0ubuntu0.16.10.1 [55.8 kB]
Get:2 http://gb.archive.ubuntu.com/ubuntu yakkety/main amd64 php-pgsql all 1:7.0+44 [1,920 B]                                                                                     
Fetched 57.7 kB in 8min 4s (118 B/s)                                                                                                                                              
Selecting previously unselected package php7.0-pgsql.                                                                                                                             
(Reading database ... 258311 files and directories currently installed.)                                                                                                          
Preparing to unpack .../0-php7.0-pgsql_7.0.13-0ubuntu0.16.10.1_amd64.deb ...                                                                                                      
Unpacking php7.0-pgsql (7.0.13-0ubuntu0.16.10.1) ...
Selecting previously unselected package php-pgsql.
Preparing to unpack .../1-php-pgsql_1%3a7.0+44_all.deb ...
Unpacking php-pgsql (1:7.0+44) ...
Processing triggers for libapache2-mod-php7.0 (7.0.13-0ubuntu0.16.10.1) ...
Setting up php7.0-pgsql (7.0.13-0ubuntu0.16.10.1) ...

Creating config file /etc/php/7.0/mods-available/pgsql.ini with new version

Creating config file /etc/php/7.0/mods-available/pdo_pgsql.ini with new version
Setting up php-pgsql (1:7.0+44) ...
Processing triggers for libapache2-mod-php7.0 (7.0.13-0ubuntu0.16.10.1) ...

我在 ubuntu/kubuntu 16.10 上。

编辑:

$ ping -c4 gb.archive.ubuntu.com
PING gb.archive.ubuntu.com(steelix.canonical.com (2001:67c:1560:8001::11)) 56 data bytes

--- gb.archive.ubuntu.com ping statistics ---
4 packets transmitted, 0 received, 100% packet loss, time 3056ms

对比

$ ping6 -c4 gb.archive.ubuntu.com
PING gb.archive.ubuntu.com(steelix.canonical.com (2001:67c:1560:8001::11)) 56 data bytes

--- gb.archive.ubuntu.com ping statistics ---
4 packets transmitted, 0 received, 100% packet loss, time 3073ms

编辑2:

$ which ping
/bin/ping

$ ping -V
ping utility, iputils-s20150815

答案1

注意:您似乎通过以下方式连接到 Ubuntu 镜像IPv6这可能会导致响应缓慢

为了使用IPv4只有您可以使用以下方法 建议在这里

-o Acquire::ForceIPv4=true运行时添加apt-get

如果您想使设置持久,只需创建 /etc/apt/apt.conf.d/99force-ipv4Acquire::ForceIPv4 "true";输入:

echo 'Acquire::ForceIPv4 "true";' | sudo tee /etc/apt/apt.conf.d/99force-ipv4

以下几个链接可以帮助您获得更快的镜像:

使用 GUIhttps://blog.kmonsoor.com/ubuntu-update-apt-get-server-to-use-fastest-mirror/

使用命令行http://tuxdiary.com/2015/06/13/find-fastest-ubuntu-mirror-cmdline/

使用 apt-selecthttps://github.com/jblakeman/apt-select

相关内容