centos配置yum源

Fantasy 发布于 23 天前 35 次阅读


1 配置本地源

挂载本地镜像,查看挂在情况

mkdir /mnt/cdrom   //创建挂在目录
mount /dev/cdrom /mnt/cdrom  //挂载镜像文件
df -h  //查看挂载情况


修改yum源repo文件

cd /etc/yum.repos.d/    //切换到repo文件目录
mkdir backup            //创建备份目录
mv * backup             //将所有repo文件移动至备份目录下
cp backup/CentOS-Linux-Media.repo /etc/yum.repos.d/  //复制本地yum源文件到yum.repos.d目录下
vi CentOS-Linux-Media.repo  //修改本地yum源文件
[media-baseos]
name=CentOS Linux releasever - Media - BaseOS
baseurl=file:///mnt/cdrom/BaseOS
        file:///media/CentOS/BaseOS
        file:///media/cdrom/BaseOS
        file:///media/cdrecorder/BaseOS
gpgcheck=1
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial

[media-appstream]
name=CentOS Linuxreleasever - Media - AppStream
baseurl=file:///mnt/cdrom/AppStream
        file:///media/CentOS/AppStream
        file:///media/cdrom/AppStream
        file:///media/cdrecorder/AppStream
gpgcheck=1
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial


更新yum源

yum clean all
yum makecache


安装vim测试

yum install vim* -y

2 配置国内源

安装wget

yum install wget* -y


将backup下的CentOS-Linux-BaseOS.repo复制到/etc/yum.repos.d目录下

cp /etc/yum.repos.backup/CentOS-Linux-BaseOS.repo /etc/yum.repos.d
ll


配置阿里镜像源

wget http://mirrors.aliyun.com/repo/Centos-8.repo

更新yum源

yum clean all
yum makecache

yum源
华为源

# 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.
#
#

[base]
name=CentOS-releasever - Base - repo.huaweicloud.com
baseurl=https://repo.huaweicloud.com/centos/releasever/os/basearch/
#mirrorlist=https://mirrorlist.centos.org/?release=releasever&arch=basearch&repo=os
gpgcheck=1
gpgkey=https://repo.huaweicloud.com/centos/RPM-GPG-KEY-CentOS-7

#released updates 
[updates]
name=CentOS-releasever - Updates - repo.huaweicloud.com
baseurl=https://repo.huaweicloud.com/centos/releasever/updates/basearch/
#mirrorlist=https://mirrorlist.centos.org/?release=releasever&arch=basearch&repo=updates
gpgcheck=1
gpgkey=https://repo.huaweicloud.com/centos/RPM-GPG-KEY-CentOS-7

#additional packages that may be useful
[extras]
name=CentOS-releasever - Extras - repo.huaweicloud.com
baseurl=https://repo.huaweicloud.com/centos/releasever/extras/basearch/
#mirrorlist=https://mirrorlist.centos.org/?release=releasever&arch=basearch&repo=extras
gpgcheck=1
gpgkey=https://repo.huaweicloud.com/centos/RPM-GPG-KEY-CentOS-7

#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-releasever - Plus - repo.huaweicloud.com
baseurl=https://repo.huaweicloud.com/centos/releasever/centosplus/basearch/
#mirrorlist=https://mirrorlist.centos.org/?release=releasever&arch=basearch&repo=centosplus
gpgcheck=1
enabled=0
gpgkey=https://repo.huaweicloud.com/centos/RPM-GPG-KEY-CentOS-7
此作者没有提供个人介绍
最后更新于 2024-12-30