赞
踩
首先准备一个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
离线化脚本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/
在执行脚本之前,需要确定系统上已经安装命令rsync
和createrepo
。
yum install rsync createrepo -y
现在,可以使用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
上边是开启gpgcheck
了,如果不想启用,把它设置成0
。
如果想要搭建http服务访问源
,使用apache
或者nginx
搭建一个http服务,将文件放到web目录里面即可。然后把repo文件中的每一个repo的baseurl
改为对应的url就行了。
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。