温馨提示×

debian cobbler怎配置

小樊
52
2026-10-12 14:31:34
栏目: 智能运维

下面给你一个**在 Debian 上配置 Cobbler(自动化安装系统)**的实用流程,基于 Debian 11/12 + Cobbler 3.x(目前主流版本)。


一、环境准备

1. 系统要求

  • Debian 11/12
  • 静态 IP(非常重要)
  • 关闭或配置好防火墙
  • 建议内存 ≥ 2G

2. 安装基础软件

apt update
apt install -y cobbler cobbler-web fence-agents \
  tftp tftp-hpa xinetd dhcpd isc-dhcp-server \
  apache2 syslinux bind9-utils

二、Cobbler 基础配置

1. 修改 Cobbler 配置

编辑:

vim /etc/cobbler/settings.yaml

关键配置(示例):

server: 192.168.1.10
next_server: 192.168.1.10
manage_dhcp: 1
manage_tftp: 1
manage_dns: 0
pxe_just_once: 1

server 和 next_server 必须是 Cobbler 服务器 IP


三、配置 TFTP / xinetd

vim /etc/xinetd.d/tftp

确保:

service tftp
{
    disable = no
    socket_type = dgram
    protocol = udp
    wait = yes
    user = root
    server = /usr/sbin/in.tftpd
    server_args = -s /var/lib/tftpboot
}

重启:

systemctl restart xinetd
systemctl enable xinetd

四、配置 DHCP

1. 编辑 DHCP 模板

vim /etc/cobbler/dhcp.template

示例:

subnet 192.168.1.0 netmask 255.255.255.0 {
     option routers             192.168.1.1;
     option domain-name-servers 8.8.8.8;
     option subnet-mask         255.255.255.0;
     range dynamic-bootp        192.168.1.100 192.168.1.200;
     default-lease-time         21600;
     max-lease-time             43200;
     next-server                192.168.1.10;
     filename                   "pxelinux.0";
}

2. 同步 Cobbler

cobbler sync

五、导入系统镜像(以 Debian 为例)

1. 挂载 ISO

mount -o loop debian-12-amd64-DVD-1.iso /mnt

2. 导入

cobbler import --path=/mnt --name=debian12 --arch=x86_64

查看:

cobbler distro list

六、配置 Kickstart(自动安装)

1. 创建 KS 文件

vim /var/lib/cobbler/kickstarts/debian12.ks

示例(最小安装):

lang en_US
keyboard us
timezone Asia/Shanghai
rootpw --plaintext password
clearpart --all --initlabel
part / --fstype ext4 --size 1 --grow
bootloader --location mbr
%packages
@base
%end

2. 关联 profile

cobbler profile edit --name=debian12-x86_64 \
--kickstart=/var/lib/cobbler/kickstarts/debian12.ks

七、Web 管理(可选)

访问:

https://<server-ip>/cobbler_web

默认账号:

  • 用户:cobbler
  • 密码:cobbler

修改密码:

htdigest /etc/cobbler/users.digest "Cobbler" cobbler

八、启动服务

systemctl enable --now cobblerd
systemctl enable --now apache2
systemctl enable --now isc-dhcp-server
cobbler sync

九、客户端测试

  1. 客户端 BIOS 设置 PXE 启动
  2. 自动进入 Cobbler 菜单
  3. 选择 Debian12 自动安装

十、常见问题

1. Cobbler sync 报错

cobbler check

按提示修复

2. PXE 起不来

  • 确认 pxe_just_once
  • 确认防火墙放行 UDP 67/68/69

3. Debian KS 不生效

Debian 推荐用 preseed 而不是 kickstart(CentOS 用 kickstart)


如果你愿意,我可以:

  • 给你 Debian preseed 示例
  • 帮你做 Cobbler + UEFI
  • 或针对 内网无外网环境做离线配置

你现在是 Debian 还是 Ubuntu 客户端?UEFI 还是 Legacy?

0 踩