购买好虚机,迫不及待地开始使用,apt-get把所有需要的包全部装上。此时遇到了一个问题:
root@ecs-68145193:/tmp# apt install unzip
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following package was automatically installed and is no longer required:
libjudydebian1
Use 'apt autoremove' to remove it.
Suggested packages:
zip
The following NEW packages will be installed:
unzip
0 upgraded, 1 newly installed, 0 to remove and 1 not upgraded.
Need to get 169 kB of archives.
After this operation, 593 kB of additional disk space will be used.
0% [Connecting to cn.archive.ubuntu.com (91.189.91.39)]
0% [Connecting to cn.archive.ubuntu.com (91.189.91.39)]
Err:1 http://cn.archive.ubuntu.com/ubuntu focal/main amd64 unzip amd64 6.0-25ubuntu1
Could not connect to cn.archive.ubuntu.com:80 (91.189.91.38). - connect (104: Connection reset by peer) Could not connect to cn.archive.ubuntu.com:80 (91.189.91.39). - connect (104: Connection reset by peer) Could not connect to cn.archive.ubuntu.com:80 (2001:67c:1562::18), connection timed out Could not connect to cn.archive.ubuntu.com:80 (2001:67c:1562::15), connection timed out
E: Failed to fetch http://cn.archive.ubuntu.com/ubuntu/pool/main/u/unzip/unzip_6.0-25ubuntu1_amd64.deb Could not connect to cn.archive.ubuntu.com:80 (91.189.91.38). - connect (104: Connection reset by peer) Could not connect to cn.archive.ubuntu.com:80 (91.189.91.39). - connect (104: Connection reset by peer) Could not connect to cn.archive.ubuntu.com:80 (2001:67c:1562::18), connection timed out Could not connect to cn.archive.ubuntu.com:80 (2001:67c:1562::15), connection timed out
E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?
这是什么问题导致的呢?
首先检查网络:
root@ecs-68145193:/tmp# ping baidu.com
PING baidu.com (220.181.38.251) 56(84) bytes of data.
64 bytes from 220.181.38.251 (220.181.38.251): icmp_seq=1 ttl=45 time=28.7 ms
64 bytes from 220.181.38.251 (220.181.38.251): icmp_seq=2 ttl=45 time=28.1 ms
^C
--- baidu.com ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1001ms
rtt min/avg/max/mdev = 28.102/28.386/28.670/0.284 ms
ping 百度的域名是没问题的,说明公网没问题。
那现在是什么问题呢。因为在CentOS中也碰到了类似的问题,所以,很快断定是Ubunto源的问题。国内连接cn.archive.ubuntu.com (91.189.91.39) 这个源有限制,所以查询国内的可用源。
解决办法:
切换到国内源
1.sudo cp /etc/apt/sources.list /etc/apt/sources_default.list
2.sudo gedit /etc/apt/sources.list
删除文件中所有内容,替换为以下内容
清华开源软件镜像站,找到自己对应的版本,粘贴就好。保存。
# 默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-updates main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-updates main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-backports main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-backports main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-security main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-security main restricted universe multiverse
# 预发布软件源,不建议启用
# deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-proposed main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-proposed main restricted universe multiverse
3.sudo apt update
4.sudo apt upgrade --->>>这个不执行也可以,我后面执行后,apt出现异常了
此时再尝试安装,就能装上了:
也可以使用阿里的源。要注意自己的系统版本。