您的位置:

CentOS8更新yum源

一、CentOS更新yum源

1、备份原有yum源文件

mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.bak  

2、下载新的yum源文件

wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-8.repo  

3、更新缓存

yum clean all  
yum makecache  

二、CentOS8配置yum源

1、查看CentOS8的yum源配置文件

cd /etc/yum.repos.d/  
ls  

2、编辑CentOS8的yum源配置文件

vi /etc/yum.repos.d/Centos-AppStream.repo  

3、修改baseurl为阿里云地址

[appstream]  
name=CentOS-$releasever - AppStream  
baseurl=http://mirrors.aliyun.com/centos/$releasever/AppStream/$basearch/os/  
enabled=1  
gpgcheck=0  

4、修改对应的yum源文件即可

三、CentOS7更新yum源

1、备份原有yum源文件

mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.bak  

2、下载新的yum源文件

wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo  

3、更新缓存

yum clean all  
yum makecache  

四、CentOS8更换yum源

1、备份原有yum源文件

mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.bak  

2、下载新的yum源文件

wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.163.com/.help/CentOS7-Base-163.repo  

3、更新缓存

yum clean all  
yum makecache  

五、CentOS8本地yum源

1、安装createrepo工具

yum install createrepo -y  

2、创建本地yum源目录

mkdir /company/yum  

3、拷贝本地的yum源文件到公司yum目录下

4、将rpm包加入yum库,创建repodata文件,生成yum索引(以添加`bash-4.2.46-31.el7.x86_64.rpm` rpm包为例)

rpm --addsign /company/yum/bash-4.2.46-31.el7.x86_64.rpm
createrepo /company/yum/
yum clean all
yum makecache

六、CentOS8手动配置yum源

1、创建CentOS8的yum源配置文件

touch /etc/yum.repos.d/Centos-AppStream.repo  

2、编辑CentOS8的yum源配置文件

vi /etc/yum.repos.d/Centos-AppStream.repo  

3、输入以下内容

[appstream]  
name=CentOS-$releasever - AppStream  
baseurl=http://mirrors.aliyun.com/centos/$releasever/AppStream/$basearch/os/  
enabled=1  
gpgcheck=0  

七、CentOS8安装yum

1、检查系统内是否有CentOS系统自带的yum

rpm -qa|grep yum  

2、安装yum

rpm -iUvh http://mirror.centos.org/centos/8/BaseOS/x86_64/os/Packages/yum-4.0.9.3-6.el8.noarch.rpm  

3、再检查是否安装成功

rpm -qa|grep yum  

八、CentOS8阿里云yum源

1、备份原有yum源文件

cd /etc/yum.repos.d/  
mv CentOS-Base.repo CentOS-Base.repo.bak  

2、创建新的yum源文件

vi CentOS-Base.repo  

3、编辑新的yum源文件,复制以下内容:

[base]  
name=CentOS-$releasever - Base  
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os  
baseurl=http://mirrors.aliyun.com/centos/$releasever/BaseOS/$basearch/os/  
gpgcheck=1  
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-Official  

[updates]  
name=CentOS-$releasever - Updates  
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates  
baseurl=http://mirrors.aliyun.com/centos/$releasever/BaseOS/$basearch/os/  
gpgcheck=1  
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-Official  

[extras]  
name=CentOS-$releasever - Extras  
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras  
baseurl=http://mirrors.aliyun.com/centos/$releasever/extras/$basearch/os/  
gpgcheck=1  
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-Official  

[centosplus]  
name=CentOS-$releasever - Plus  
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus  
baseurl=http://mirrors.aliyun.com/centos/$releasever/centosplus/$basearch/os/  
gpgcheck=1  
enabled=0  
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-Official  

4、更新缓存

yum clean all  
yum makecache  

九、CentOS8搭建本地yum源

详细操作步骤参考第五小节“CentOS8本地yum源”。