This article has been included in the column of this site
Server Optimization Series
0. What is a software source
A software repository is where software packages are stored. Users can use package managers on some operating systems to download software applications from software repositories. For example, CPAN contains many software repositories written in Perl.
- Wikipedia
1. Why should you change the software source?
Most of the default software sources of the system are from abroad, and domestic access may be slow, disconnected or even inaccessible.
Domestic leading companies and well-known universities have provided mirror sites, and the servers are deployed in China, which is superior in terms of download speed and stability.
2. How to choose software source
Refer to this site article:
https://blog.tsinbei.com/archives/238/
3, replace the software source
3.1, Centos
(1) Backup
1 | mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup |
(2) Replacement
Download the new CentOS-Base.repo to /etc/yum.repos.d/
1 | wget - O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo |
or
1 | curl - o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo |
Note: Change the 7 in http://mirrors.aliyun.com/repo/Centos-7.repo to your own Centos version number, for example, Centos 8 is http://mirrors.aliyun.com/repo/Centos- 8. repo.
(3) Cache
1 | yum makecache |
3.2, Ubuntu
(1) Backup
1 | sudo cp /etc/apt/sources.list /etc/apt/sources_init.list |
(2) Change permissions
1 | sudo chmod 777 /etc/apt/source.list |
Replace the source
Bash 1
sudo nano /etc/apt/sources.list
Use nano to open the text, delete the contents of the original file, copy one of the sources below, and save.
Aliyuan:Text 1
2
3
4
5
6
7
8
9
10deb http://mirrors.aliyun.com/ubuntu/ xenial main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ xenial-proposed main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ xenial main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ xenial-proposed main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse
Tsinghua source:
Text 1
2
3
4
5
6
7
8
9
10deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic main restricted universe multiverse deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic main restricted universe multiverse deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-security main restricted universe multiverse deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-security main restricted universe multiverse deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse
(3) Update
Bash 1
sudo apt-get update
Fix broken packages, try uninstalling the wrong package, and reinstall the correct version.
Bash 1
sudo apt-get - f install
update software
Bash 1
sudo apt-get upgrade
3.3, Debian
(1) Backup
Bash 1
sudo cp /etc/apt/sources.list /etc/apt/sources.list_bak
(2) Replacement
Will
/etc/apt/sources.list
Debian default source address in the file
http://deb.debian.org
replace with
http://mirrors.ustc.edu.cn
Just wait for the mirror address.
1 | sudo sed - i 's/deb.debian.org/mirrors.ustc.edu.cn/g' /etc/apt/sources.list |
You can also edit directly
/etc/apt/sources.list
file, add the following
1 | deb http://mirrors.ustc.edu.cn/debian stable main contrib non-free # deb-src http://mirrors.ustc.edu.cn/debian stable main contrib non-free deb http://mirrors.ustc.edu.cn/debian stable-updates main contrib non-free # deb-src http://mirrors.ustc.edu.cn/debian stable-updates main contrib non-free # deb http://mirrors.ustc.edu.cn/debian stable-proposed-updates main contrib non-free # deb-src http://mirrors.ustc.edu.cn/debian stable-proposed-updates main contrib non-free |
(3) Update
1 | sudo apt-get update |
3.4, Fedora
1 | su cd /etc/yum.repos.d/ mv fedora.repo fedora.repo.backup mv fedora-updates.repo fedora-updates.repo.backup wget - O /etc/yum.repos.d/fedora.repo http://mirrors.aliyun.com/repo/fedora.repo wget - O /etc/yum.repos.d/fedora-updates.repo http://mirrors.aliyun.com/repo/fedora-updates.repo dnf clean all dnf makecache |
3.5, OpenSUSE
(1) Disable the original software source
1 | sudo zypper mr - da |
(2) Add HKUST mirror source
1 | sudo zypper ar - fc https://mirrors.ustc.edu.cn/opensuse/distribution/leap/42.1/repo/oss USTC:42.1:OSS sudo zypper ar - fc https://mirrors.ustc.edu.cn/opensuse/distribution/leap/42.1/repo/non-oss USTC:42.1:NON-OSS sudo zypper ar - fc https://mirrors.ustc.edu.cn/opensuse/update/leap/42.1/oss USTC:42.1:UPDATE-OSS sudo zypper ar - fc https://mirrors.ustc.edu.cn/opensuse/update/leap/42.1/non-oss USTC:42.1:UPDATE-NON-OSS |
(3) Manually refresh the software source
1 | sudo zypper ref |
(4) Update the system
1 | sudo zypper up |
3.6, FreeBSD
(1) Modify the pkg source
1 | mkdir - p /usr/local/etc/pkg/repos |
exist
/usr/local/etc/pkg/repos/FreeBSD.conf
Write the following:
1 | # content of FreeBSD.conf FreeBSD: { url: "pkg+http://mirrors.ustc.edu.cn/freebsd-pkg/${ABI}/quarterly", } |
- Modify the ports source
exist
/etc/make.conf
Write the following:
1 | # content of make.conf FETCH_CMD=axel - n 10 - a DISABLE_SIZE=yes MASTER_SITE_OVERRIDE?=http://mirrors.ustc.edu.cn/freebsd-ports/distfiles/${DIST_SUBDIR}/ |
- Modify the portsnap source
exist
/etc/portsnap.conf
join in:
1 | # content of porsnap.conf SERVERNAME=porsnap.tw.freebsd.org |
Server optimization (2) Replace the software source
Comments