当前位置:   article > 正文

制作CentOS7 yum私有源的方法_centos7 私有yum源

centos7 私有yum源

离线化yum源的方法

首先准备一个excludes.list文件,作为排除的列表,如果不想排除,可以不用这个文件,并且将离线化脚本中的参数--exclude-from=exclude.list删除。

exclude.list文件内容:

SRPMS
aarch64
ppc64
ppc64le
debug
repodata
EFI
LiveOS
images
isolinux
CentOS_BuildTag
EULA
GPL
RPM-GPG-KEY-CentOS-7
RPM-GPG-KEY-CentOS-Testing-7
drpms
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16

离线化脚本rsync.sh,会在当前目录下创建一个centos的目录,并将源内容同步到这个目录,通过createrepo命令创建yum仓库。离线文件总计27G左右,执行前确认空间足够。如果不使用exclude.list,占用空间只会更多。脚本内容:

#!/bin/bash

#epel
rsync -avz --exclude-from=exclude.list rsync://mirrors.tuna.tsinghua.edu.cn/epel/7/ epel/7/
createrepo epel/7/
 
#centos7-base
rsync -avz --exclude-from=exclude.list rsync://mirrors.tuna.tsinghua.edu.cn/centos/7/os/x86_64/ centos/7/os/x86_64/
createrepo centos/7/os/x86_64/
 
#centos7-updates
rsync -avz --exclude-from=exclude.list rsync://mirrors.tuna.tsinghua.edu.cn/centos/7/updates/x86_64/ centos/7/updates/x86_64/
createrepo centos/7/updates/x86_64/
 
#centos7-extras
rsync -avz --exclude-from=exclude.list rsync://mirrors.tuna.tsinghua.edu.cn/centos/7/extras/x86_64/ centos/7/extras/x86_64/
createrepo centos/7/extras/x86_64/
 
#centos7-centosplus
rsync -avz --exclude-from=exclude.list rsync://mirrors.tuna.tsinghua.edu.cn/centos/7/centosplus/x86_64/ centos/7/centosplus/x86_64/
createrepo centos/7/centosplus/x86_64/
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21

在执行脚本之前,需要确定系统上已经安装命令rsynccreaterepo

yum install rsync createrepo -y
  • 1

搭建本地文件源

现在,可以使用local.repo使用当前目录为yum源,文件内容如下:

[base]
name=Local Repository
baseurl=file:///centos/7/os/x86_64/
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

[updates]
name=Local Repository
baseurl=file:///centos/7/updates/x86_64/
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

[extras]
name=Local Repository
baseurl=file:///centos/7/extras/x86_64/
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

[centosplus]
name=Local Repository
baseurl=file:///centos/7/centosplus/x86_64/
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27

上边是开启gpgcheck了,如果不想启用,把它设置成0

搭建http源

如果想要搭建http服务访问源,使用apache或者nginx搭建一个http服务,将文件放到web目录里面即可。然后把repo文件中的每一个repo的baseurl改为对应的url就行了。

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/羊村懒王/article/detail/458799
推荐阅读
相关标签
  

闽ICP备14008679号