利用 Cobbler 进行 Ubuntu 集群管理
一 架构与准备
openssl passwd -1),规划 子网、网关、DNS、地址池 与节点 MAC→IP 固定映射(便于按主机名上线)。二 部署 Cobbler 服务
dnf -y install cobbler dhcp-server(按需补充 httpd、tftp 等)server: <Cobbler_IP>、next_server_v4: <Cobbler_IP>manage_dhcp: true、manage_dhcp_v4: true、manage_tftpd: truepxe_just_once: truedefault_password_crypted: "<openssl passwd -1 的结果>"cobbler mkloaderscobbler checksystemctl enable --now cobblerd httpd tftp dhcpdcobbler sync(每次变更配置后执行)三 导入 Ubuntu 镜像与创建 Profile
mount -o loop /path/ubuntu-22.04.iso /mnt/isocobbler import --name=ubuntu-22.04 --path=/mnt/iso --arch=amd64/var/lib/cobbler/kickstarts/ubuntu-22.04.seedd-i debian-installer/locale string en_US、d-i console-setup/ask_detect boolean falsed-i mirror/http/hostname 与 d-i mirror/http/directory(指向 Cobbler 的 HTTP 根,如 http://<Cobbler_IP>/cobbler/ks_mirror/ubuntu-22.04/)d-i passwd/root-login boolean true、d-i passwd/root-password-crypted 或使用 d-i passwd/user-fullname、d-i passwd/username、d-i passwd/user-password-cryptedd-i partman/*、pkgsel/include 等cobbler profile add --name=ubuntu-22.04-server --distro=ubuntu-22.04-x86_64 --autoinstall=/var/lib/cobbler/kickstarts/ubuntu-22.04.seedcobbler sync四 批量上线与主机管理
/etc/cobbler/dhcp.template 的 subnet 内添加 host 段
host node01 {
hardware ethernet 00:50:56:3B:64:2F;
fixed-address 192.168.8.110;
}
host node02 {
hardware ethernet 00:50:56:23:4A:8E;
fixed-address 192.168.8.120;
}
cobbler synccobbler system add --name=node01 --hostname=node01 --profile=ubuntu-22.04-server --mac=00:50:56:3B:64:2F --ip-address=192.168.8.110 --netmask=255.255.255.0 --gateway=192.168.8.2 --dns-nameservers=8.8.8.8cobbler syncpxe_just_once: true 防止重装。五 常用运维与故障排查
cobbler check、cobbler list、cobbler report、cobbler distro list、cobbler profile list、cobbler system list、cobbler sync、cobbler reposync、cobbler --versioncat /var/lib/tftpboot/pxelinux.cfg/defaultcobblerd、httpd、tftp、dhcpd 处于 active (running) 状态next-server 指向 Cobbler 的 TFTP 地址,且 filename "pxelinux.0" 正确journalctl -u cobblerd -f、/var/log/cobbler/ 下的日志文件有助于定位导入、同步、引导失败等问题。