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