在CentOS 7系统中安装yum源,可以让我们更方便地管理和更新系统软件包,以下是详细的步骤:
准备工作
1、确保你的CentOS 7系统已经安装了基本的软件包,如wget、tar等,如果没有安装,可以使用以下命令进行安装:
sudo yum install y wget tar
2、下载CentOS 7的镜像文件,访问CentOS官方网站(https://www.centos.org/download/)下载最新版本的CentOS 7镜像文件,这里以CentOS 7.9为例,下载x86_64架构的镜像文件。
创建本地yum源
1、将下载好的CentOS 7镜像文件上传到服务器的一个目录,例如/opt
,使用wget
命令下载镜像文件:
sudo wget https://centos7.iuscommunity.org/iusrelease.rpm sudo wget https://centos7.iuscommunity.org/iusreleasex86_647.9.20093.el7.ius.aarch64.rpm sudo wget https://centos7.iuscommunity.org/centos/7/os/x86_64/Packages/centoslinuxrepos79.20093.el7.ius.aarch64.rpm sudo wget https://centos7.iuscommunity.org/centos/7/os/x86_64/Packages/centosgpgkeys79.20093.el7.ius.aarch64.rpm
2、安装iusrelease
和centosgpgkeys
包:
sudo rpm ivh iusrelease* centosgpgkeys*
3、将下载好的CentOS 7镜像文件上传到服务器的一个目录,例如/opt
,使用wget
命令下载镜像文件:
sudo wget https://centos7.iuscommunity.org/iusrelease.rpm sudo wget https://centos7.iuscommunity.org/iusreleasex86_647.9.20093.el7.ius.aarch64.rpm sudo wget https://centos7.iuscommunity.org/centos/7/os/x86_64/Packages/centoslinuxrepos79.20093.el7.ius.aarch64.rpm sudo wget https://centos7.iuscommunity.org/centos/7/os/x86_64/Packages/centosgpgkeys79.20093.el7.ius.aarch64.rpm
2、安装iusrelease
和centosgpgkeys
包:
sudo rpm ivh iusrelease* centosgpgkeys*
3、将下载好的CentOS 7镜像文件上传到服务器的一个目录,例如/opt
,使用wget
命令下载镜像文件:
sudo wget https://centos7.iuscommunity.org/iusrelease.rpm sudo wget https://centos7.iuscommunity.org/iusreleasex86_647.9.20093.el7.ius.aarch64.rpm sudo wget https://centos7.iuscommunity.org/centos/7/os/x86_64/Packages/centoslinuxrepos79.20093.el7.ius.aarch64.rpm sudo wget https://centos7.iuscommunity.org/centos/7/os/x86_64/Packages/centosgpgkeys79.20093.el7.ius.aarch64.rpm
2、安装iusrelease
和centosgpgkeys
包:
sudo rpm ivh iusrelease* centosgpgkeys*
配置本地yum源
1、创建一个名为localrepo
的目录,用于存放本地yum源的文件:
sudo mkdir /etc/yum.repos.d/localrepo
2、将下载好的CentOS 7镜像文件解压到localrepo
目录:
sudo tar zxvf centoslinuxrepos79* C /etc/yum.repos.d/localrepo strip=1
3、修改localrepo
目录下的CentOSBase.repo
文件,将baseurl
和mirrorlist
指向本地镜像文件的位置:
[base] name=CentOS Linux ($releasever) Base mirrors.ustc.edu.cn #baseurl=http://mirrors.ustc.edu.cn/centos/$releasever/os/$basearch/ #mirrorlist=http://mirrors.ustc.edu.cn/centos/$releasever/os/$basearch/mirrorlist?repo=os&arch=$basearch&lang=zh_CN&release=$releasever&contenttype=text/plain&id=baseurl&dist=centos&group_id=base&extra=%252Fos%252F$basearch%252F&filename=baseurl%5Fcontents%5F$releasever%5F$basearch%5Fbaseurl%5Fcontents%5Ffilelist%5Fbaseurl%5Fcontents%5Ffilelist%5Fbaseurl%5Fcontents%5Ffilelist%5Fbaseurl%5Fcontents%5Ffilelist%5Fbaseurl%5Fcontents%5Ffilelist%5Fbaseurl%5Fcontents%5Ffilelist%5Fbaseurl%5Fcontents%5Ffilelist%5Fbaseurl%5Fcontents%5Ffilelist%5Fbaseurl%5Fcontents%5Ffilelist%5Fbaseurl%5Fcontents%5Ffilelist%5Fbaseurl%5Fcontents%5Ffilelist%5Fbaseurl%5Fcontents%5Ffilelist%5Fbaseurl%5Fcontents%5Ffilelist%5Fbaseurl%5Fcontents%5Ffilelist%5Fbaseurl%5Fcontents%5Ffilelist%5Fbaseurl%5Fcontents%5Ffilelist%5Fbaseurl%5Fcontents%5Ffilelist%5Fbaseurl%5Fcontents%5Ffilelist%5Fbaseurl%5Fcontents%5Ffilelist%5Fbaseurl%5Fcontents%5Ffilelist%5Fbaseurl%5Fcontents%5Ffilelist%5Fbaseurl%5Fcontents%5Ffilelist%5Fbaseurl%5Fcontents%5Ffilelist%5Fbaseurl
原创文章,作者:K-seo,如若转载,请注明出处:https://www.kdun.cn/ask/457154.html