Centos7.9同步外网yum源至内网

curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
curl -o /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
yum makecache
yum repolist

安装软件

yum install -y yum-utils createrepo		# yum-utils包含reposync同步工具,createrepo用于对rpm文件进行索引建立
reposync -n --repoid=extras --repoid=updates --repoid=base --repoid=epel -p /library/Centos7.9/		# -n 指下载最新软件包,-p 指定目录,--repoid 指定本地的源,如果不指定就同步所有源

# 创建源索引
createrepo -po /library/Centos7.9/base/ /library/Centos7.9/base/
createrepo -po /library/Centos7.9/extras/ /library/Centos7.9/extras/
createrepo -po /library/Centos7.9/updates/ /library/Centos7.9/updates/
createrepo -po /library/Centos7.9/epel/ /library/Centos7.9/epel/
# 更新源索引
createrepo --update /library/Centos7.9/base/
createrepo --update /library/Centos7.9/extras/
createrepo --update /library/Centos7.9/updates/
createrepo --update /library/Centos7.9/epel/

创建yum源客repo配置文件

cat << EOF > /mirror/repo/CentOS-Base.repo

[base]
name=CentOS- Base
baseurl=file:///library/Centos7.9/base/
enable=1
gpgcheck=0
 
[updates]
name=CentOS- Updates
baseurl=file:///library/Centos7.9/updates/
enable=1
gpgcheck=0

[extras]
name=CentOS- Extras
baseurl=file:///library/Centos7.9/extras/
enable=1
gpgcheck=0

[epel]
name=CentOS- Epel
baseurl=file:///library/Centos7.9/epel/
enable=1
gpgcheck=0
EOF
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值