下面从系统层面、Cobbler 配置层面、服务与性能层面、维护与自动化几个角度,系统性地说明如何优化 Debian 下的 Cobbler(PXE 自动安装系统)。
apt purge snapd
apt autoremove
避免无关服务占用资源(尤其是 PXE 服务器)
Cobbler 对时间敏感(签名、HTTPS)
apt install chrony
systemctl enable --now chrony
apt install python3-pip
pip3 install cobbler
Cobbler 默认使用 SQLite:
manage_dhcp: true
manage_dns: false # 若已有 DNS 可关闭
pxe_just_once: true
server: <cobbler_ip>
next_server: <cobbler_ip>
✅ pxe_just_once: true 防止重复 PXE 安装
编辑:
/etc/default/tftpd-hpa
示例:
TFTP_OPTIONS="--secure --blocksize 1468"
提高大文件传输效率
<Directory /var/www/cobbler>
EnableSendfile On
CacheEnable disk /
</Directory>
cobbler import 优化cobbler import --path=/mnt/debian12 --name=debian12 --arch=amd64
建议:
apt install apt-mirror
配置:
deb http://mirrors.debian.org/debian bookworm main
再在 kickstart/preseed 中:
d-i mirror/http/hostname string 192.168.1.10
✅ 大幅减少外网依赖
示例:
d-i pkgsel/update-policy select none
d-i finish-install/reboot_in_progress note
d-i partman-auto/disk string /dev/sda
d-i partman-auto/method string lvm
systemctl disable bluetooth
systemctl disable cups
manage_dhcp: true
default-lease-time 600;
max-lease-time 7200;
cobbler system add --name=node1 --mac=xx:xx:xx --ip-address=192.168.1.20
ulimit -n 65535
/var/www/cobbler/var/lib/cobblerauthn_pam: true
cobbler sync
cobbler reposync
/var/log/cobbler/
建议 logrotate:
/var/log/cobbler/*.log {
weekly
rotate 4
compress
}
| 问题 | 优化方案 |
|---|---|
| PXE 启动慢 | 调整 TFTP blocksize |
| 安装卡住 | 检查 preseed / DHCP |
| 重复安装 | 开启 pxe_just_once |
| 网络不稳定 | 本地 apt 镜像 |
Cobbler Server
├─ DHCP (cobbler)
├─ TFTP
├─ HTTP (local repo)
└─ apt-mirror
如果你愿意,我可以: