Score:0

Download from multiple backup apt repository in ubuntu

mm flag

I have AWS auto scaling group which scales out in peak hours. I'm facing unhealthy instances due to do AWS's apt servers being unresponsive sometimes.

 Err:68 http://ap-northeast-1.ec2.archive.ubuntu.com/ubuntu focal-updates/main amd64 python-apt-common all 2.0.0ubuntu0.20.04.7
  503  Service Unavailable 
Err:69 http://ap-northeast-1.ec2.archive.ubuntu.com/ubuntu focal-updates/main amd64 python3-apt amd64 2.0.0ubuntu0.20.04.7
  503  Service Unavailable
Err:70 http://ap-northeast-1.ec2.archive.ubuntu.com/ubuntu focal-updates/main amd64 ubuntu-release-upgrader-core all 1:20.04.38
  503  Service Unavailable 
Err:71 http://ap-northeast-1.ec2.archive.ubuntu.com/ubuntu focal-updates/main amd64 update-manager-core all 1:20.04.10.10
  503  Service Unavailable 
Err:72 http://ap-northeast-1.ec2.archive.ubuntu.com/ubuntu focal-updates/main amd64 python3-distupgrade all 1:20.04.38
  503  Service Unavailable
Err:73 http://ap-northeast-1.ec2.archive.ubuntu.com/ubuntu focal-updates/main amd64 python3-update-manager all 1:20.04.10.10
  503  Service Unavailable 

This does not happen every time but once in a while.

I'm trying to use multiple apt repositories in Ubuntu 20.04 so that when one fails, the packages will be downloaded from another. Is there any efficient way to do so?

I tried making clone of aws's apt repository (ap-northeast-1.ec2.archive.ubuntu.com/ubuntu/ in my case) using apt-mirror. Then I uploaded it to S3 with cloudfront. Then I added the endpoints in sources.list file.

  • When I use my clone's endpoint only it works fine.
  • When I use public repository and clone repository at the same time it works fine when both of them are available.
  • When I make clone unavailable by disabling cloudfront access, I get unhealthy instances again.

I want apt to use backup repository whenever main repository is down. My sources.list file while using both repo looks like:

#clone
deb my-endpoint/ubuntu/ focal main restricted
deb my-endpoint/ubuntu/ focal-updates main restricted
deb my-endpoint/ubuntu/ focal universe
deb my-endpoint/ubuntu/ focal-updates universe
deb my-endpoint/ubuntu/ focal multiverse
deb my-endpoint/ubuntu/ focal-updates multiverse
deb my-endpoint/ubuntu/ focal-backports main restricted universe multiverse

#public
deb http://ap-northeast-1.ec2.archive.ubuntu.com/ubuntu/ focal main restricted
deb http://ap-northeast-1.ec2.archive.ubuntu.com/ubuntu/ focal-updates main restricted
deb http://ap-northeast-1.ec2.archive.ubuntu.com/ubuntu/ focal universe
deb http://ap-northeast-1.ec2.archive.ubuntu.com/ubuntu/ focal-updates universe
deb http://ap-northeast-1.ec2.archive.ubuntu.com/ubuntu/ focal multiverse
deb http://ap-northeast-1.ec2.archive.ubuntu.com/ubuntu/ focal-updates multiverse
deb http://ap-northeast-1.ec2.archive.ubuntu.com/ubuntu/ focal-backports main restricted universe multiverse

#security
deb http://archive.ubuntu.com/ubuntu focal-security main restricted
deb http://archive.ubuntu.com/ubuntu focal-security universe
deb http://archive.ubuntu.com/ubuntu focal-security multiverse 
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.