Давайте предположим, что мы используем Ubuntu 18.04 LTS (Бионический Бобр).
Я знаю GUI способы переключить в настоящее время используемое зеркало APT.
Пользователь должен открыть Software и Updates (software-properties-gtk
или software-properties-kde
) и перейдите к вкладке Ubuntu Software (Kubuntu Software) и затем выберите зеркало в Загрузке со списка:
Но как переключиться, APT зеркально отражают от командной строки?
Примечания/обновления:
/etc/apt/sources.list
предотвратить опечатки и автоматизировать корректный зеркальный выбор. software-properties-gtk
(также интересно, где зеркальные адреса сохраняются в системе).Список зеркальных серверов получен библиотекой Python ( get_server_list
процедура определяется в /usr/lib/python3/dist-packages/aptsources/distro.py
и названный от /usr/lib/python3/dist-packages/softwareproperties/gtk/SoftwarePropertiesGtk.py
).
Решение состоит в том, чтобы использовать названный инструмент apt-mirror-updater
. Это устанавливаемо от pip
/pip3
:
sudo pip3 install apt-mirror-updater
Функциональность:
Использование: apt-mirror-updater [ОПЦИИ]
apt-mirror-updater программа автоматизирует устойчивую Кв. - получают зеркальный выбор для Debian и Ubuntu путем включения исследования доступных зеркал, рейтинга доступных зеркал, автоматического переключения между зеркалами и устойчивого обновления списка пакета.
Поддерживаемые опции:
- r, - remote-host=SSH_ALIAS
Operate on a remote system instead of the local system. The SSH_ALIAS argument gives the SSH alias of the remote host. It is assumed that the remote account has root privileges or password-less sudo access.
- f, - find-current-mirror
Determine the main mirror that is currently configured in /etc/apt/sources.list and report its URL on standard output.
- b, - find-best-mirror
Discover available mirrors, rank them, select the best one and report its URL on standard output.
- l, - зеркала списка
List available (ranked) mirrors on the terminal in a human readable format.
- c, - change-mirror=MIRROR_URL
Update /etc/apt/sources.list to use the given MIRROR_URL.
- a, - auto-change-mirror
Discover available mirrors, rank the mirrors by connection speed and update status and update /etc/apt/sources.list to use the best available mirror.
- u, - обновление, - списки пакета обновления
Update the package lists using `apt-get update', retrying on failure and automatically switch to a different mirror when it looks like the current mirror is being updated.
- x, - exclude=PATTERN
Add a pattern to the mirror selection blacklist. PATTERN is expected to be a shell pattern (containing wild cards like `?' and `*') that is matched against the full URL of each mirror.
- m, - max=COUNT
Don't query more than COUNT mirrors for their connection status (defaults to 50). If you give the number 0 no limit will be applied. Because Ubuntu mirror discovery can report more than 300 mirrors it's useful to limit the number of mirrors that are queried, otherwise the ranking of mirrors will take a long time (because over 300 connections need to be established).
- v, - подробный
Increase logging verbosity (can be repeated).
- q, - тихий
Decrease logging verbosity (can be repeated).
- h, - справка
Show this message and exit.
Таким образом, это позволяет находить лучшее зеркало и применять его к /etc/apt/sources.list
:
sudo apt-mirror-updater --auto-change-mirror
Также это позволяет выбирать зеркало URL и применять его к /etc/apt/sources.list
:
$ apt-mirror-updater --list-mirrors
-----------------------------------------------------------------------------------------------------------------------
| Rank | Mirror URL | Available? | Updating? | Last updated | Bandwidth |
-----------------------------------------------------------------------------------------------------------------------
| 1 | http://mirror.timeweb.ru/ubuntu | Yes | No | Up to date | 6.49 KB/s |
| 2 | http://no.archive.ubuntu.com/ubuntu | Yes | No | Up to date | 6.38 KB/s |
| 3 | http://ftp.aso.ee/ubuntu | Yes | No | Up to date | 5.62 KB/s |
| 4 | http://mirror.plusserver.com/ubuntu/ubuntu | Yes | No | Up to date | 4.77 KB/s |
| 5 | http://nl.archive.ubuntu.com/ubuntu | Yes | No | Up to date | 4.68 KB/s |
...
и затем выберите зеркало вручную:
sudo apt-mirror-updater -c "http://mirror.timeweb.ru/ubuntu"
Некоторое решение (протестированный на моем LTS Ubuntu 18.04.1): https://github.com/jblakeman/apt-select.git
pip install apt-select
или:
pip3 install apt-select
Добавление сценария для СОЕДИНЕНИЯ КАНАЛОМ для выполнения его отовсюду (делают это постоянным):
export PATH=$PATH:~/.local/bin/apt-select
Заставьте главное зеркало от Соединенных Штатов генерировать новый sources.list::
apt-select --country US
Выберите из лучших 3 зеркал, включая тех последнее обновление неделю назад::
apt-select -c -t 3 -m one-week-behind
Выберите из 5 американских зеркал с самой низкой задержкой к Вашей машине:
$ apt-select --country US -t 5 --choose