在 CentOS 上使用 Cobbler 同步镜像(repository / distro),通常分为 系统安装镜像同步 和 软件仓库同步 两类。下面按常见场景说明。
同步核心命令:
cobbler sync
cobbler reposync
mkdir -p /mnt/centos7
mount -o loop CentOS-7-x86_64-DVD.iso /mnt/centos7
cobbler import \
--path=/mnt/centos7 \
--name=centos7 \
--arch=x86_64
导入完成后:
cobbler distro list
cobbler sync
cobbler repo add \
--name=centos7-base \
--mirror=http://mirrors.aliyun.com/centos/7/os/x86_64/ \
--arch=x86_64 \
--breed=yum
可选额外仓库:
cobbler repo add \
--name=centos7-updates \
--mirror=http://mirrors.aliyun.com/centos/7/updates/x86_64/
cobbler reposync
只同步指定仓库:
cobbler reposync --only=centos7-base
cobbler profile edit \
--name=centos7-x86_64 \
--repos="centos7-base centos7-updates"
cobbler sync
crontab -e
示例(每天凌晨同步):
0 2 * * * /usr/bin/cobbler reposync
setsebool -P cobbler_can_network_connect 1
systemctl stop firewalld
systemctl status cobblerd
systemctl status httpd
tail -f /var/log/cobbler/cobbler.log
cobbler import --path=/mnt/centos7 --name=centos7 --arch=x86_64
cobbler repo add --name=centos7-base --mirror=http://mirrors.aliyun.com/centos/7/os/x86_64/
cobbler repo add --name=centos7-updates --mirror=http://mirrors.aliyun.com/centos/7/updates/x86_64/
cobbler reposync
cobbler profile edit --name=centos7-x86_64 --repos="centos7-base centos7-updates"
cobbler sync
如果你说明 CentOS 版本(6/7/8/Stream) 或 内网/离线环境,我可以给你更精确的同步方案。