问题描述
在使用 apt-get update
的时候,发现一堆报错,无法进行更新
root@atlassian:~# apt-get update
Err:1 https://mirrors.tuna.tsinghua.edu.cn/ubuntu focal InRelease
Reading from proxy failed - read (11: Resource temporarily unavailable) [IP: 192.168.1.99 7890]
Err:2 https://mirrors.tuna.tsinghua.edu.cn/ubuntu focal-updates InRelease
Reading from proxy failed - read (11: Resource temporarily unavailable) [IP: 192.168.1.99 7890]
Err:3 https://mirrors.tuna.tsinghua.edu.cn/ubuntu focal-backports InRelease
Reading from proxy failed - read (115: Operation now in progress) [IP: 192.168.1.99 7890]
Err:4 https://mirrors.tuna.tsinghua.edu.cn/ubuntu focal-security InRelease
Invalid response from proxy: HTTP/1.1 407 Proxy Authentication Required Connection: close Proxy-Authenticate: Basic Content-Length: 0 [IP: 192.168.1.99 7890]
Reading package lists… Done
W: Failed to fetch https://mirrors.tuna.tsinghua.edu.cn/ubuntu/dists/focal/InRelease Reading from proxy failed - read (11: Resource temporarily unavailable) [IP: 192.168.1.99 7890]
W: Failed to fetch https://mirrors.tuna.tsinghua.edu.cn/ubuntu/dists/focal-updates/InRelease Reading from proxy failed - read (11: Resource temporarily unavailable) [IP: 192.168.1.99 7890]
W: Failed to fetch https://mirrors.tuna.tsinghua.edu.cn/ubuntu/dists/focal-backports/InRelease Reading from proxy failed - read (115: Operation now in progress) [IP: 192.168.1.99 7890]
W: Failed to fetch https://mirrors.tuna.tsinghua.edu.cn/ubuntu/dists/focal-security/InRelease Invalid response from proxy: HTTP/1.1 407 Proxy Authentication Required Connection: close Proxy-Authenticate: Basic Content-Length: 0 [IP: 192.168.1.99 7890]
W: Some index files failed to download. They have been ignored, or old ones used instead.
想起来是在安装 Ubuntu Server 时,其中有一步是 Configure proxy
,然后我就填了,后面一些原因这个 IP 更换了,然后再进行修改的时候发现之前常规配置的几个文件中都没有相关信息:
/etc/profile.d/
目录下/etc/apt/apt.conf.d/
目录下/etc/profile
文件中/etc/environment
文件中~/.wgetrc
文件中~/.bashrc
文件中
解决方案
其实 /etc/apt/apt.conf.d/
目录下是可以发现的,但一堆文件也没细看,老老实实的搜吧: find /|xargs grep -ri "http://192.168.1.99:7890" -l
root@atlassian:~# find /|xargs grep -ri "http://192.168.1.99:7890" -l
/etc/apt/apt.conf.d/90curtin-aptproxy
/etc/systemd/system/snapd.service.d/snap_proxy.conf
/var/log/installer/subiquity-curtin-install.conf
/var/log/installer/subiquity-client-debug.log.2438
/var/log/installer/curtin-install-cfg.yaml
/var/log/installer/autoinstall-user-data
/var/log/installer/subiquity-curtin-apt.conf
/var/log/installer/installer-journal.txt
grep: /sys/kernel/tracing/per_cpu/cpu127/snapshot_raw: No such device
... ...
看一下 /etc/apt/apt.conf.d/90curtin-aptproxy
文件
root@atlassian:~# cat /etc/apt/apt.conf.d/90curtin-aptproxy
Acquire::http::Proxy "http://192.168.1.99:7890";
Acquire::https::Proxy "http://192.168.1.99:7890";
看一下 /etc/systemd/system/snapd.service.d/snap_proxy.conf
文件
root@atlassian:~# cat /etc/systemd/system/snapd.service.d/snap_proxy.conf
[Service]
Environment="HTTP_PROXY=http://192.168.1.99:7890"
Environment="HTTPS_PROXY=http://192.168.1.99:7890"
搜索进度太长后面就放弃了,把搜索出来的前两个文件删了试了一下可以,删除完成后记得重启服务。
systemctl daemon-reload
systemctl restart snapd
如果需要设置系统级代理,直接修改 /etc/profile
文件,将 export http_proxy=http://192.168.1.76:7890
放到最后,然后执行 source /etc/profile
即可。
我这里是本地虚拟机环境就偷懒直接改成系统级的了,在生产环境下或如果有别的需求,可以搜索一些上面几个目录名或文件名,对比一下在这几个地方配置有什么不同,对症下药才更能更好的解决问题。
评论区