自建yum仓库,分别为网络源和本地源

一、本地源

tep1 添加光驱并挂载

[root@CentOS7 ~]#mkdir applocation/Centos7 -p
[root@CentOS7 ~]#mount /dev/sr1 /applocation/Centos7
[root@CentOS7 ~]#lsblk
NAME   MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda      8:0    0   30G  0 disk 
├─sda1   8:1    0  300M  0 part /boot
├─sda2   8:2    0    2G  0 part [SWAP]
└─sda3   8:3    0 27.7G  0 part /
sr0     11:0    1  4.4G  0 rom  
sr1     11:1    1  723M  0 rom  /applocation/Centos7
#此时,光盘已经挂载到该目录下
[root@CentOS7 ~]#ls /applocation/Centos7
EFI  images  isolinux  LICENSE  TRANS.TBL

tep2 打开仓库配置文件

[root@CentOS7 ~]#ls /etc/yum.repos.d/
CentOS-Base.repo  CentOS-Debuginfo.repo  CentOS-Media.repo    CentOS-Vault.repo
CentOS-CR.repo    CentOS-fasttrack.repo  CentOS-Sources.repo  CentOS-x86_64-kernel.repo
[root@CentOS7 ~]#mv *.repo bak;touch base.repo;vim base.repo

[Base]
name=Centos7
baseurl=file://applocation/Centos7      
gpgcheck=0

tep3 检查本地仓库状态

[root@CentOS7 ~]##yum repolist 
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: www
repo id            repo name         status                   
base/7/x86_64        Base            10,072 
#此时已完成本地源配置

二、网络源

  • 修改配置文件
[base]
name=base
baseurl=https://mirrors.cloud.tencent.com/centos/7/os/x86_64/
	https://mirrors.tuna.tsinghua.edu.cn/centos/7/os/x86_64/
	https://repo.huaweicloud.com/centos/7/os/x86_64/
gpgcheck=0

[epel]
name=epel
baseurl=https://mirrors.cloud.tencent.com/epel/7/x86_64/
        https://mirrors.huaweicloud.com/epel/7/x86_64/
        https://mirrors.tuna.tsinghua.edu.cn/epel/7/x86_64/

gpgcheck=1
gpgkey=https://mirrors.cloud.tencent.com/epel/RPM-GPG-KEY-EPEL-7
       https://mirrors.huaweicloud.com/epel/RPM-GPG-KEY-EPEL-7
       https://mirrors.tuna.tsinghua.edu.cn/epel/RPM-GPG-KEY-EPEL-7
enabled=1
[extras]
name=extras
baseurl=https://mirrors.cloud.tencent.com/centos/7/extras/x86_64/
        https://mirrors.huaweicloud.com/centos/7/extras/x86_64/
	https://mirrors.tuna.tsinghua.edu.cn/centos/7/extras/x86_64/
gpgcheck=1
gpgkey=https://repo.huaweicloud.com/centos/RPM-GPG-KEY-CentOS-7
enabled=1
  • 检查结果
[root@CentOS7 ~]#yum repolist 
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: repo.huaweicloud.com
 * epel: mirrors.cloud.tencent.com
 * extras: mirrors.cloud.tencent.com
repo id                                                               repo name                                                             status
base                                                                  base                                                                  10,072
epel                                                                  epel                                                                  13,665
extras                                                                extras                                                                   500
repolist: 24,237

posted @ 2022-01-26 00:29  火火7412  阅读(20)  评论(0编辑  收藏  举报