Ubuntu 20.04 无法连接到我的本地 REPO

Ubuntu 20.04 无法连接到我的本地 REPO

Iv 设置本地回购协议我已经从 Ubuntu 下载了所有软件包。

root@vm-repo-server:~# ifconfig | grep inet
        inet 10.0.0.4  netmask 255.255.255.0  broadcast 10.0.0.255

root@vm-repo-server:/var/www/html/ubuntu/mirror/azure.archive.ubuntu.com/ubuntu/dists/focal# ll
total 40472
drwxr-xr-x 6 root root      146 Jan 24 12:31 ./
drwxr-xr-x 8 root root      123 Jan 24 12:31 ../
-rw-r--r-- 1 root root 40902952 Apr 23  2020 Contents-amd64.gz
-rw-r--r-- 1 root root   264892 Apr 23  2020 InRelease
-rw-r--r-- 1 root root   263289 Apr 23  2020 Release
-rw-r--r-- 1 root root     1554 Apr 23  2020 Release.gpg
drwxr-xr-x 5 root root       51 Jan 24 12:31 main/
drwxr-xr-x 5 root root       51 Jan 24 12:31 multiverse/
drwxr-xr-x 4 root root       38 Jan 24 12:31 restricted/
drwxr-xr-x 5 root root       51 Jan 24 12:31 universe/
root@vm-repo-server:


602.5 GiB will be downloaded into archive.
Downloading 187125 archive files using 20 threads...
Begin time: Mon Jan 24 10:24:22 2022
[20]... [19]... [18]... [17]... [16]... [15]... [14]... [13]... [12]... [11]... [10]... [9]... [8]... [7]... [6]... [5]... [4].                                                                                                           .. [3]... [2]... [1]... [0]...
End time: Mon Jan 24 12:31:12 2022

我已设置了两个客户端,一个是 18.04,一个是 20.04。这些客户端现在将从 REPO 服务器下载更新

18.04 源列表 /etc/apt/sources.list 包含以下条目:

root@vm-ubuntu18:~# cat /etc/apt/sources.list | grep allow
deb [allow-insecure=yes] http://10.0.0.4/ubuntu/mirror/azure.archive.ubuntu.com/ubuntu/ bionic main restricted universe multiverse
deb [allow-insecure=yes]  http://10.0.0.4/ubuntu/mirror/azure.archive.ubuntu.com/ubuntu/ bionic-updates main restricted universe multiverse
deb [allow-insecure=yes] http://10.0.0.4/ubuntu/mirror/azure.archive.ubuntu.com/ubuntu/ bionic-backports main restricted universe multiverse
deb [allow-insecure=yes]  http://10.0.0.4/ubuntu/mirror/security.ubuntu.com/ubuntu bionic-security main restricted universe multiverse
root@vm-ubuntu18:~#

从 18.04 服务器运行 apt 更新时,它运行正常并连接到我的 REPO。

root@vm-ubuntu18:~# date && apt update
Mon Jan 24 16:13:40 UTC 2022
Hit:1 http://10.0.0.4/ubuntu/mirror/azure.archive.ubuntu.com/ubuntu bionic InRelease
Hit:2 http://10.0.0.4/ubuntu/mirror/azure.archive.ubuntu.com/ubuntu bionic-updates InRelease
Hit:3 http://10.0.0.4/ubuntu/mirror/azure.archive.ubuntu.com/ubuntu bionic-backports InRelease
Hit:4 http://10.0.0.4/ubuntu/mirror/security.ubuntu.com/ubuntu bionic-security InRelease
Reading package lists... Done
Building dependency tree
Reading state information... Done
5 packages can be upgraded. Run 'apt list --upgradable' to see them.
root@vm-ubuntu18:~#

当我尝试从同一个 REPO 更新 20.04 LTS 时出现以下错误:

Err:4 http://10.0.0.4/ubuntu/mirror/azure.archive.ubuntu.com/ubuntu focal/main amd64 c-n-f Metadata
  404  Not Found [IP: 10.0.0.4 80]
Ign:11 http://10.0.0.4/ubuntu/mirror/azure.archive.ubuntu.com/ubuntu focal/universe amd64 c-n-f Metadata
Ign:12 http://10.0.0.4/ubuntu/mirror/azure.archive.ubuntu.com/ubuntu focal/multiverse amd64 c-n-f Metadata
Ign:13 http://10.0.0.4/ubuntu/mirror/azure.archive.ubuntu.com/ubuntu focal/restricted amd64 c-n-f Metadata
Fetched 265 kB in 0s (867 kB/s)
Reading package lists... Done
E: Failed to fetch http://10.0.0.4/ubuntu/mirror/azure.archive.ubuntu.com/ubuntu/dists/focal/main/cnf/Commands-amd64  404  Not Found [IP: 10.0.0.4 80]
E: Some index files failed to download. They have been ignored, or old ones used instead.
root@vm-ubuntu20:~#

20.04 源列表文件中应该包含什么才能连接到 IP 为 10.0.0.4 的本地 REPO 并下载软件包而不会出现错误?

谢谢

答案1

我最近将所有系统从 18.04 升级到 20.04(包括本地镜像)时遇到了这个问题。

问题在于“命令未找到”文件,这些文件显然在 18.04 中不存在,或者至少工作方式不同。我必须将这些行添加到镜像下载后运行的脚本中以解压缩文件。

unxz -fk /[mirror location]/us.archive.ubuntu.com/ubuntu/dists/focal-security/main/cnf/Commands-amd64.xz
unxz -fk /[mirror location]/us.archive.ubuntu.com/ubuntu/dists/focal-security/multiverse/cnf/Commands-amd64.xz
unxz -fk /[mirror location]/us.archive.ubuntu.com/ubuntu/dists/focal-security/restricted/cnf/Commands-amd64.xz
unxz -fk /[mirror location]/us.archive.ubuntu.com/ubuntu/dists/focal-security/universe/cnf/Commands-amd64.xz
#
unxz -fk /[mirror location]/us.archive.ubuntu.com/ubuntu/dists/focal-updates/main/cnf/Commands-amd64.xz
unxz -fk /[mirror location]/us.archive.ubuntu.com/ubuntu/dists/focal-updates/multiverse/cnf/Commands-amd64.xz
unxz -fk /[mirror location]/us.archive.ubuntu.com/ubuntu/dists/focal-updates/restricted/cnf/Commands-amd64.xz
unxz -fk /[mirror location]/us.archive.ubuntu.com/ubuntu/dists/focal-updates/universe/cnf/Commands-amd64.xz

我可能手动解压了基本发行版的文件,我记不清了。可能我解压了,但没有在脚本中放入相关命令,因为这些文件不会改变。所以这是一次性的事情。

我使用的apt-mirror版本很遗憾没有维护,需要进行一些其他调整才能使其与 20.04 兼容 - 但似乎您没有使用它。所以我所做的可能对您不起作用,但最重要的是,您需要提取这些 cnf 文件,以便检查sudo apt update对客户端正常运行。

相关内容