更改yum 源
- 例如执行yum update,经常报错“Cound not resolve host: xxxxx”,一般都是yum源是使用的国外镜像,国内访问很不好。这时可以将源手动替换为国内的清华大学源,或者阿里云源之类的。
详细使用方法可以参考https://mirrors.tuna.tsinghua.edu.cn/help/centos/,镜像站使用帮助,选择自己的版本即可。
CentOS 7
下面贴出CentOS 7版本下,清华源的配置
1 # CentOS-Base.repo
2 #
3 # The mirror system uses the connecting IP address of the client and the
4 # update status of each mirror to pick mirrors that are updated to and
5 # geographically close to the client. You should use this for CentOS updates
6 # unless you are manually picking other mirrors.
7 #
8 # If the mirrorlist= does not work for you, as a fall back you can try the
9 # remarked out baseurl= line instead.
10 #
11 #
12
13 [base]
14 name=CentOS-$releasever - Base
15 baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/os/$basearch/
16 #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os
17 gpgcheck=1
18 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
19
20 #released updates
21 [updates]
22 name=CentOS-$releasever - Updates
23 baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/updates/$basearch/
24 #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates
25 gpgcheck=1
26 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
27
28 #additional packages that may be useful
29 [extras]
30 name=CentOS-$releasever - Extras
31 baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/extras/$basearch/
32 #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras
33 gpgcheck=1
34 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
35
36 #additional packages that extend functionality of existing packages
37 [centosplus]
38 name=CentOS-$releasever - Plus
39 baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/centosplus/$basearch/
40 #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus
41 gpgcheck=1
42 enabled=0
43 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
PS 如果觉得命令行使用不方便,可以直接用SFTP连上之后进行文件编辑。
- 另外内核升级时可能用到/etc/yum.repos.d/elrepo.repo文件,也同样可以将其修改为清华大学的源。
同样贴出清华大学elrepo.repo源配置
### Name: 清华大学开源镜像
### URL: https://mirrors.tuna.tsinghua.edu.cn/elrepo/
[elrepo]
name=ELRepo.org Community Enterprise Linux Repository - el7
baseurl=https://mirrors.tuna.tsinghua.edu.cn/elrepo/elrepo/el7/$basearch/
#mirrorlist=http://mirrors.elrepo.org/mirrors-elrepo.el7
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-elrepo.org
protect=0
[elrepo-testing]
name=ELRepo.org Community Enterprise Linux Testing Repository - el7
baseurl=https://mirrors.tuna.tsinghua.edu.cn/elrepo/testing/el7/$basearch/
#mirrorlist=http://mirrors.elrepo.org/mirrors-elrepo-testing.el7
enabled=0
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-elrepo.org
protect=0
[elrepo-kernel]
name=ELRepo.org Community Enterprise Linux Kernel Repository - el7
baseurl=https://mirrors.tuna.tsinghua.edu.cn/elrepo/kernel/el7/$basearch/
#mirrorlist=http://mirrors.elrepo.org/mirrors-elrepo-kernel.el7
enabled=0
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-elrepo.org
protect=0
[elrepo-extras]
name=ELRepo.org Community Enterprise Linux Extras Repository - el7
baseurl=https://mirrors.tuna.tsinghua.edu.cn/elrepo/extras/el7/$basearch/
#mirrorlist=http://mirrors.elrepo.org/mirrors-elrepo-extras.el7
enabled=0
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-elrepo.org
protect=0
CentOS 8
Base
# CentOS-Base.repo
#
# The mirror system uses the connecting IP address of the client and the
# update status of each mirror to pick mirrors that are updated to and
# geographically close to the client. You should use this for CentOS updates
# unless you are manually picking other mirrors.
#
# If the mirrorlist= does not work for you, as a fall back you can try the
# remarked out baseurl= line instead.
#
#
[BaseOS]
name=CentOS-$releasever - Base
baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/BaseOS/$basearch/os/
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=BaseOS&infra=$infra
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
[AppStream]
name=CentOS-$releasever - AppStream
baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/AppStream/$basearch/os/
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=AppStream&infra=$infra
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
[PowerTools]
name=CentOS-$releasever - PowerTools
baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/PowerTools/$basearch/os/
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=PowerTools&infra=$infra
enabled=0
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras
baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/extras/$basearch/os/
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus
baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/centosplus/$basearch/os/
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
Stream
# CentOS-Stream-Base.repo
#
# The mirror system uses the connecting IP address of the client and the
# update status of each mirror to pick mirrors that are updated to and
# geographically close to the client. You should use this for CentOS updates
# unless you are manually picking other mirrors.
#
# If the mirrorlist= does not work for you, as a fall back you can try the
# remarked out baseurl= line instead.
#
#
[Stream-BaseOS]
name=CentOS-Stream - Base
baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/$stream/BaseOS/$basearch/os/
#mirrorlist=http://mirrorlist.centos.org/?release=$stream&arch=$basearch&repo=BaseOS&infra=$infra
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
[Stream-AppStream]
name=CentOS-Stream - AppStream
baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/$stream/AppStream/$basearch/os/
#mirrorlist=http://mirrorlist.centos.org/?release=$stream&arch=$basearch&repo=AppStream&infra=$infra
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
[Stream-PowerTools]
name=CentOS-Stream - PowerTools
baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/$stream/PowerTools/$basearch/os/
#mirrorlist=http://mirrorlist.centos.org/?release=$stream&arch=$basearch&repo=PowerTools&infra=$infra
enabled=0
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
#additional packages that may be useful
[Stream-extras]
name=CentOS-Stream - Extras
baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/$stream/extras/$basearch/os/
#mirrorlist=http://mirrorlist.centos.org/?release=$stream&arch=$basearch&repo=extras
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
#additional packages that extend functionality of existing packages
[Stream-centosplus]
name=CentOS-Stream - Plus
baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/$stream/centosplus/$basearch/os/
#mirrorlist=http://mirrorlist.centos.org/?release=$stream&arch=$basearch&repo=centosplus
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
elrepo
### Name: ELRepo.org Community Enterprise Linux Repository for el8
### URL: https://elrepo.org/
### URL: https://mirrors.tuna.tsinghua.edu.cn/elrepo/
[elrepo]
name=ELRepo.org Community Enterprise Linux Repository - el8
baseurl=http://elrepo.org/linux/elrepo/el8/$basearch/
https://mirrors.tuna.tsinghua.edu.cn/elrepo/elrepo/el8/$basearch/
http://mirrors.coreix.net/elrepo/elrepo/el8/$basearch/
http://mirror.rackspace.com/elrepo/elrepo/el8/$basearch/
http://linux-mirrors.fnal.gov/linux/elrepo/elrepo/el8/$basearch/
mirrorlist=http://mirrors.elrepo.org/mirrors-elrepo.el8
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-elrepo.org
[elrepo-testing]
name=ELRepo.org Community Enterprise Linux Testing Repository - el8
baseurl=http://elrepo.org/linux/testing/el8/$basearch/
https://mirrors.tuna.tsinghua.edu.cn/elrepo/testing/el8/$basearch/
http://mirrors.coreix.net/elrepo/testing/el8/$basearch/
http://mirror.rackspace.com/elrepo/testing/el8/$basearch/
http://linux-mirrors.fnal.gov/linux/elrepo/testing/el8/$basearch/
mirrorlist=http://mirrors.elrepo.org/mirrors-elrepo-testing.el8
enabled=0
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-elrepo.org
[elrepo-kernel]
name=ELRepo.org Community Enterprise Linux Kernel Repository - el8
baseurl=http://elrepo.org/linux/kernel/el8/$basearch/
https://mirrors.tuna.tsinghua.edu.cn/elrepo/kernel/el8/$basearch/
http://mirrors.coreix.net/elrepo/kernel/el8/$basearch/
http://mirror.rackspace.com/elrepo/kernel/el8/$basearch/
http://linux-mirrors.fnal.gov/linux/elrepo/kernel/el8/$basearch/
mirrorlist=http://mirrors.elrepo.org/mirrors-elrepo-kernel.el8
enabled=0
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-elrepo.org
[elrepo-extras]
name=ELRepo.org Community Enterprise Linux Extras Repository - el8
baseurl=http://elrepo.org/linux/extras/el8/$basearch/
https://mirrors.tuna.tsinghua.edu.cn/elrepo/extras/el8/$basearch/
http://mirrors.coreix.net/elrepo/extras/el8/$basearch/
http://mirror.rackspace.com/elrepo/extras/el8/$basearch/
http://linux-mirrors.fnal.gov/linux/elrepo/extras/el8/$basearch/
mirrorlist=http://mirrors.elrepo.org/mirrors-elrepo-extras.el8
enabled=0
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-elrepo.org
内核更改。注意调整
Converting from CentOS Linux to CentOS Stream
root@centos-linux# dnf install centos-release-stream
root@centos-linux# dnf distro-sync
root@centos-stream# cat /etc/centos-release
CentOS Stream release 8