Ubuntu虚机操作指南---1、源和环境配置

购买好虚机,迫不及待地开始使用,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出现异常了

 此时再尝试安装,就能装上了:

 也可以使用阿里的源。要注意自己的系统版本。

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
root@6527d9173397:/# apt update Ign:1 http://archive.ubuntu.com/ubuntu jammy InRelease Ign:2 http://security.ubuntu.com/ubuntu jammy-security InRelease Ign:2 http://security.ubuntu.com/ubuntu jammy-security InRelease Ign:3 http://archive.ubuntu.com/ubuntu jammy-updates InRelease Ign:4 http://archive.ubuntu.com/ubuntu jammy-backports InRelease Ign:2 http://security.ubuntu.com/ubuntu jammy-security InRelease Ign:1 http://archive.ubuntu.com/ubuntu jammy InRelease Err:2 http://security.ubuntu.com/ubuntu jammy-security InRelease Temporary failure resolving 'security.ubuntu.com' Ign:3 http://archive.ubuntu.com/ubuntu jammy-updates InRelease Ign:4 http://archive.ubuntu.com/ubuntu jammy-backports InRelease Ign:1 http://archive.ubuntu.com/ubuntu jammy InRelease Ign:3 http://archive.ubuntu.com/ubuntu jammy-updates InRelease Ign:4 http://archive.ubuntu.com/ubuntu jammy-backports InRelease Err:1 http://archive.ubuntu.com/ubuntu jammy InRelease Temporary failure resolving 'archive.ubuntu.com' Err:3 http://archive.ubuntu.com/ubuntu jammy-updates InRelease Temporary failure resolving 'archive.ubuntu.com' Err:4 http://archive.ubuntu.com/ubuntu jammy-backports InRelease Temporary failure resolving 'archive.ubuntu.com' Reading package lists... Done Building dependency tree... Done Reading state information... Done All packages are up to date. W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/jammy/InRelease Temporary failure resolving 'archive.ubuntu.com' W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/jammy-updates/InRelease Temporary failure resolving 'archive.ubuntu.com' W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/jammy-backports/InRelease Temporary failure resolving 'archive.ubuntu.com' W: Failed to fetch http://security.ubuntu.com/ubuntu/dists/jammy-security/InRelease Temporary failure resolving 'security.ubuntu.com' W: Some index files failed to download. They have been ignored, or old ones used instead.
06-12

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值