如何获得“ apt-get update”以在无法访问互联网且手动分配IP地址的计算机上工作?


19

我已经apt-mirror在一台可以访问互联网的计算机上成功设置并下载了最新的ubuntu软件包。目标是在apt-get update无法访问Internet的目标计算机上进行操作时,将该计算机用作存储库。两台机器都设置了手动IP地址,并且两台机器都以Ubuntu 16.04作为操作系统运行。的etc/apt/sources.list在目标机器只有1行:

deb http://<local_repo_IP>/ubuntu/ xenial main restricted multiverse universe

但是在sudo apt-get update目标计算机上执行操作时,出现以下错误:

Ign:1 http://<local_repo_IP>/ubuntu/dists/xenial main InRelease
Ign:2 http://<local_repo_IP>/ubuntu/dists/xenial main Release
Ign:3 http://<local_repo_IP>/ubuntu/dists/xenial main/restricted amd64 Packages
Ign:4 http://<local_repo_IP>/ubuntu/dists/xenial main/restricted i386 Packages
Ign:5 http://<local_repo_IP>/ubuntu/dists/xenial main/restricted all Packages
Ign:6 http://<local_repo_IP>/ubuntu/dists/xenial main/restricted Translation-en_HK
Ign:7 http://<local_repo_IP>/ubuntu/dists/xenial main/restricted Translation-en
Ign:8 http://<local_repo_IP>/ubuntu/dists/xenial main/multiverse amd64 Packages
Ign:9 http://<local_repo_IP>/ubuntu/dists/xenial main/multiverse i386 Packages
Ign:10 http://<local_repo_IP>/ubuntu/dists/xenial main/multiverse all Packages
Ign:11 http://<local_repo_IP>/ubuntu/dists/xenial main/multiverse Translation-en_HK
Ign:12 http://<local_repo_IP>/ubuntu/dists/xenial main/multiverse Translation-en
Ign:13 http://<local_repo_IP>/ubuntu/dists/xenial main/universe amd64 Packages
Ign:14 http://<local_repo_IP>/ubuntu/dists/xenial main/universe i386 Packages
Ign:15 http://<local_repo_IP>/ubuntu/dists/xenial main/universe all Packages
Ign:16 http://<local_repo_IP>/ubuntu/dists/xenial main/universe Translation-en_HK
Ign:17 http://<local_repo_IP>/ubuntu/dists/xenial main/universe Translation-en
Ign:3 http://<local_repo_IP>/ubuntu/dists/xenial main/restricted amd64 Packages
Ign:4 http://<local_repo_IP>/ubuntu/dists/xenial main/restricted i386 Packages
Ign:5 http://<local_repo_IP>/ubuntu/dists/xenial main/restricted all Packages
Ign:6 http://<local_repo_IP>/ubuntu/dists/xenial main/restricted Translation-en_HK
Ign:7 http://<local_repo_IP>/ubuntu/dists/xenial main/restricted Translation-en
Ign:8 http://<local_repo_IP>/ubuntu/dists/xenial main/multiverse amd64 Packages
Ign:9 http://<local_repo_IP>/ubuntu/dists/xenial main/multiverse i386 Packages
Ign:10 http://<local_repo_IP>/ubuntu/dists/xenial main/multiverse all Packages
Ign:11 http://<local_repo_IP>/ubuntu/dists/xenial main/multiverse Translation-en_HK
Ign:12 http://<local_repo_IP>/ubuntu/dists/xenial main/multiverse Translation-en
Ign:13 http://<local_repo_IP>/ubuntu/dists/xenial main/universe amd64 Packages
Ign:14 http://<local_repo_IP>/ubuntu/dists/xenial main/universe i386 Packages
Ign:15 http://<local_repo_IP>/ubuntu/dists/xenial main/universe all Packages
Ign:16 http://<local_repo_IP>/ubuntu/dists/xenial main/universe Translation-en_HK
Ign:17 http://<local_repo_IP>/ubuntu/dists/xenial main/universe Translation-en
Ign:3 http://<local_repo_IP>/ubuntu/dists/xenial main/restricted amd64 Packages
Ign:4 http://<local_repo_IP>/ubuntu/dists/xenial main/restricted i386 Packages
Ign:5 http://<local_repo_IP>/ubuntu/dists/xenial main/restricted all Packages
Ign:6 http://<local_repo_IP>/ubuntu/dists/xenial main/restricted Translation-en_HK
Ign:7 http://<local_repo_IP>/ubuntu/dists/xenial main/restricted Translation-en
Ign:8 http://<local_repo_IP>/ubuntu/dists/xenial main/multiverse amd64 Packages
Ign:9 http://<local_repo_IP>/ubuntu/dists/xenial main/multiverse i386 Packages
Ign:10 http://<local_repo_IP>/ubuntu/dists/xenial main/multiverse all Packages
Ign:11 http://<local_repo_IP>/ubuntu/dists/xenial main/multiverse Translation-en_HK
Ign:12 http://<local_repo_IP>/ubuntu/dists/xenial main/multiverse Translation-en
Ign:13 http://<local_repo_IP>/ubuntu/dists/xenial main/universe amd64 Packages
Ign:14 http://<local_repo_IP>/ubuntu/dists/xenial main/universe i386 Packages
Ign:15 http://<local_repo_IP>/ubuntu/dists/xenial main/universe all Packages
Ign:16 http://<local_repo_IP>/ubuntu/dists/xenial main/universe Translation-en_HK
Ign:17 http://<local_repo_IP>/ubuntu/dists/xenial main/universe Translation-en
Ign:3 http://<local_repo_IP>/ubuntu/dists/xenial main/restricted amd64 Packages
Ign:4 http://<local_repo_IP>/ubuntu/dists/xenial main/restricted i386 Packages
Ign:5 http://<local_repo_IP>/ubuntu/dists/xenial main/restricted all Packages
Ign:6 http://<local_repo_IP>/ubuntu/dists/xenial main/restricted Translation-en_HK
Ign:7 http://<local_repo_IP>/ubuntu/dists/xenial main/restricted Translation-en
Ign:8 http://<local_repo_IP>/ubuntu/dists/xenial main/multiverse amd64 Packages
Ign:9 http://<local_repo_IP>/ubuntu/dists/xenial main/multiverse i386 Packages
Ign:10 http://<local_repo_IP>/ubuntu/dists/xenial main/multiverse all Packages
Ign:11 http://<local_repo_IP>/ubuntu/dists/xenial main/multiverse Translation-en_HK
Ign:12 http://<local_repo_IP>/ubuntu/dists/xenial main/multiverse Translation-en
Ign:13 http://<local_repo_IP>/ubuntu/dists/xenial main/universe amd64 Packages
Ign:14 http://<local_repo_IP>/ubuntu/dists/xenial main/universe i386 Packages
Ign:15 http://<local_repo_IP>/ubuntu/dists/xenial main/universe all Packages
Ign:16 http://<local_repo_IP>/ubuntu/dists/xenial main/universe Translation-en_HK
Ign:17 http://<local_repo_IP>/ubuntu/dists/xenial main/universe Translation-en
Ign:3 http://<local_repo_IP>/ubuntu/dists/xenial main/restricted amd64 Packages
Ign:4 http://<local_repo_IP>/ubuntu/dists/xenial main/restricted i386 Packages
Ign:5 http://<local_repo_IP>/ubuntu/dists/xenial main/restricted all Packages
Ign:6 http://<local_repo_IP>/ubuntu/dists/xenial main/restricted Translation-en_HK
Ign:7 http://<local_repo_IP>/ubuntu/dists/xenial main/restricted Translation-en
Ign:8 http://<local_repo_IP>/ubuntu/dists/xenial main/multiverse amd64 Packages
Ign:9 http://<local_repo_IP>/ubuntu/dists/xenial main/multiverse i386 Packages
Ign:10 http://<local_repo_IP>/ubuntu/dists/xenial main/multiverse all Packages
Ign:11 http://<local_repo_IP>/ubuntu/dists/xenial main/multiverse Translation-en_HK
Ign:12 http://<local_repo_IP>/ubuntu/dists/xenial main/multiverse Translation-en
Ign:13 http://<local_repo_IP>/ubuntu/dists/xenial main/universe amd64 Packages
Ign:14 http://<local_repo_IP>/ubuntu/dists/xenial main/universe i386 Packages
Ign:15 http://<local_repo_IP>/ubuntu/dists/xenial main/universe all Packages
Ign:16 http://<local_repo_IP>/ubuntu/dists/xenial main/universe Translation-en_HK
Ign:17 http://<local_repo_IP>/ubuntu/dists/xenial main/universe Translation-en
Err:3 http://<local_repo_IP>/ubuntu/dists/xenial main/restricted amd64 Packages
  404  Not Found
Ign:4 http://<local_repo_IP>/ubuntu/dists/xenial main/restricted i386 Packages
Ign:5 http://<local_repo_IP>/ubuntu/dists/xenial main/restricted all Packages
Ign:6 http://<local_repo_IP>/ubuntu/dists/xenial main/restricted Translation-en_HK
Ign:7 http://<local_repo_IP>/ubuntu/dists/xenial main/restricted Translation-en
Ign:8 http://<local_repo_IP>/ubuntu/dists/xenial main/multiverse amd64 Packages
Ign:9 http://<local_repo_IP>/ubuntu/dists/xenial main/multiverse i386 Packages
Ign:10 http://<local_repo_IP>/ubuntu/dists/xenial main/multiverse all Packages
Ign:11 http://<local_repo_IP>/ubuntu/dists/xenial main/multiverse Translation-en_HK
Ign:12 http://<local_repo_IP>/ubuntu/dists/xenial main/multiverse Translation-en
Ign:13 http://<local_repo_IP>/ubuntu/dists/xenial main/universe amd64 Packages
Reading package lists... Done
W: The repository 'http://<local_repo_IP>/ubuntu/dists/xenial main Release' does not have a Release file.
N: Data from such a repository can't be authenticated and is therefore potentially dangerous to use.
N: See apt-secure(8) manpage for repository creation and user configuration details.
E: Failed to fetch http://<local_repo_IP>/ubuntu/dists/xenial/dists/main/restricted/binary-amd64/Packages  404  Not Found
E: Some index files failed to download. They have been ignored, or old ones used instead.

在目标计算机上:

  1. /etc/resolve.conf文件包含以下内容:

    # Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
    #     DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN
    nameserver 127.0.1.1
    
  2. /etc/network/interfaces包含以下内容:

    # interfaces(5) file used by ifup(8) and ifdown(8)
    auto lo
    iface lo inet loopback
    

另外,由于该输出中apt-get update唯一显示为error的行是Err:3 http://<local_repo_IP>/ubuntu/dists/xenial main/restricted amd64 Packages,所以我通过在目标计算机上执行以下操作来检查文件是否存在

wget http://<local_repo_IP>/ubuntu/dists/xenial/restricted/binary-amd64/Packages

而且我看到文件在那里,因为我得到以下输出:

--2017-12-21 17:23:24--  http://<local_repo_IP>/ubuntu/dists/xenial/restricted/binary-amd64/Packages
Connecting to <local_repo_IP>:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 127112 (124K)
Saving to: ‘Packages’

Packages                100%[============================>] 124.13K  --.-KB/s    in 0s      

2017-12-21 17:23:24 (469 MB/s) - ‘Packages’ saved [127112/127112]

我还检查了是否可以从目标计算机到回购计算机成功ping通。那也可行。

PING <local_repo_IP> (<local_repo_IP>) 56(84) bytes of data.
64 bytes from <local_repo_IP>: icmp_seq=1 ttl=64 time=0.169 ms
64 bytes from <local_repo_IP>: icmp_seq=2 ttl=64 time=0.671 ms
64 bytes from <local_repo_IP>: icmp_seq=3 ttl=64 time=0.186 ms
64 bytes from <local_repo_IP>: icmp_seq=4 ttl=64 time=0.190 ms
64 bytes from <local_repo_IP>: icmp_seq=5 ttl=64 time=0.315 ms
^C
--- <local_repo_IP> ping statistics ---
5 packets transmitted, 5 received, 0% packet loss, time 4047ms
rtt min/avg/max/mdev = 0.169/0.306/0.671/0.190 ms

那么,怎么了apt-get update?我该如何修复并使其正常工作?

PS我只是注意到错误提示http://<local_repo_IP>/ubuntu/dists/xenial/dists/main/restricted/binary-amd64/Packages。为什么要尝试restricted在main内部查找包?它不应该在看http://<local_repo_IP>/ubuntu/dists/xenial/restricted/binary-amd64/Packages吗?确实,当我这样做时wget http://<local_repo_IP>/ubuntu/dists/xenial/dists/main/restricted/binary-amd64/Packages,它会出现以下错误:

--2017-12-21 17:26:06--  http://<local_repo_IP>/ubuntu/dists/xenial/dists/main/restricted/binary-amd64/Packages
Connecting to <local_repo_IP>:80... connected.
HTTP request sent, awaiting response... 404 Not Found
2017-12-21 17:26:06 ERROR 404: Not Found.

这里发生了什么?为什么要尝试检查不存在的目录?我该如何apt-get update指出正确的路径?

Answers:


21

我发现解决方案是将etc/apt/sources.list文件编辑为仅包含系统体系结构的文件:

deb [arch=amd64] http://192.168.12.61/ubuntu/ xenial main restricted multiverse universe

现在,当我进行更新时,它没有给出任何错误:

$ sudo apt update
Hit:1 http://192.168.12.61/ubuntu xenial InRelease
Reading package lists... Done
Building dependency tree       
Reading state information... Done
All packages are up to date.

只是想将它发布为可能遇到相同问题的任何人的可能解决方案。


7
发布您自己的问题的答案绝对是正确的方法。代表将来会发现此问题的人们,谢谢!
亚历克斯

1
您也可以将其标记为解决方案。
地雷

4
考虑到您所遇到的错误是amd64文件,并且限制使用使其amd64难以消失,因此我认为这并不是真正解决问题的方法。这是您sources.list对其他相关配置所做的唯一更改吗?在进行此更改之前,您是否重新同步了镜像?
大师

我同意@topher。您应该将此标记为解决方案。
摇滚歌手

@muru是的,这是我所做的唯一更改,并且此后未出现任何错误。是的,我同意您的意见,即不应解决该问题。那么,关于它为什么起作用的任何想法?另外,我注意到它尝试在(错误中)搜索的路径是错误的-应该在其中搜索http://192.168.12.61/ubuntu/dists/xenial/restricted/binary-amd64/Packages,但在中搜索http://192.168.12.61/ubuntu/dists/xenial/dists/main/restricted/binary-amd64/Packages。为什么会这样呢?以及指定架构如何解决该问题?
Kristada673 '18

0

我对[amd-64]的看法...例如,如果在您的/etc/apt/sources.list中,您已启用google chrome更新deb [arch = amd64] http://dl.google。 com / linux / chrome / deb /稳定主

您会看到这是唯一包含[amd-64]的条目,它来自Google来源。

在您最初提到“ deb http:// 192 ...”时,也许您的更新在进入sources.list时提到了chrome更新,因为它没有特别提及,因此它的更新停滞了。

或者,查看sudo apt-cache policy,sources.list和sources.list.d

最终,在进一步回答之前,我可能会冒险并在自己的实验室中进行复制。

By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.