首页 帮助中心 常见问题 Cobbler自动化安装部署Ubuntu和CentOS详细教程
Cobbler自动化安装部署Ubuntu和CentOS详细教程
时间 : 2024-08-29 14:26:05 编辑 : 华纳云 阅读量 : 73

  Cobbler 是一个Linux安装服务器,可以通过PXE进行网络引导并自动化安装Linux操作系统。它支持多种Linux发行版,包括Ubuntu和CentOS。
  一、安装Cobbler和配置环境
  1. 安装Cobbler和相关组件
  在CentOS 7上:
  yum install epel-release -y
  yum install cobbler cobbler-web dhcp tftp-server pykickstart httpd -y
  在Ubuntu上:
  apt-get update
  apt-get install cobbler cobbler-web dnsmasq tftpd-hpa tftp-hpa apache2 python3-pip -y
  2. 启动和配置Cobbler
  启动服务:
  systemctl start cobblerd
  systemctl enable cobblerd
  systemctl start httpd  # 在CentOS上
  systemctl enable httpd # 在CentOS上
  在Ubuntu上:
  systemctl start apache2
  systemctl enable apache2
  检查Cobbler设置:
  cobbler check
  根据提示进行修复。
  二、配置DHCP和TFTP
  1. 编辑DHCP配置文件
  在CentOS上编辑 /etc/cobbler/dhcp.template:
  subnet 192.168.1.0 netmask 255.255.255.0 {
  option routers             192.168.1.1;
  option domain-name-servers 192.168.1.1;
  range dynamic-bootp        192.168.1.100 192.168.1.254;
  default-lease-time         21600;
  max-lease-time             43200;
  next-server                $next_server;
  filename                   "$boot_file";
  }
  在Ubuntu上编辑 /etc/dnsmasq.d/cobbler.conf:
  port=0
  dhcp-range=192.168.1.100,192.168.1.254
  dhcp-boot=pxelinux.0
  enable-tftp
  tftp-root=/var/lib/tftpboot
  2. 启动和重启相关服务
  在CentOS上:
  systemctl restart cobblerd
  systemctl restart dhcpd
  systemctl restart xinetd
  在Ubuntu上:
  systemctl restart cobblerd
  systemctl restart dnsmasq
  systemctl restart tftpd-hpa
  三、导入操作系统镜像
  1. 下载操作系统镜像
  从官方镜像站下载Ubuntu和CentOS的ISO文件。
  2. 挂载ISO文件并导入镜像
  例如,在CentOS上:
  mount -o loop /path/to/centos.iso /mnt
  cobbler import --path=/mnt --name=centos7 --arch=x86_64
  umount /mnt
  mount -o loop /path/to/ubuntu.iso /mnt
  cobbler import --path=/mnt --name=ubuntu1804 --arch=x86_64
  umount /mnt
  四、配置Kickstart文件
  1. 创建和编辑Kickstart文件
  在/var/lib/cobbler/kickstarts/目录下创建对应的Kickstart文件。例如centos7.ks和ubuntu1804.seed。
  示例CentOS Kickstart文件(centos7.ks):
  install
  url --url=$tree
  lang en_US.UTF-8
  keyboard us
  network --bootproto=dhcp
  rootpw --iscrypted $6$yourpasswordhash
  firewall --disabled
  authconfig --enableshadow --passalgo=sha512
  selinux --permissive
  timezone America/New_York
  bootloader --location=mbr --driveorder=sda --append="rhgb quiet"
  zerombr
  clearpart --all --initlabel
  part /boot --fstype ext4 --size=500
  part swap --size=4096
  part / --fstype ext4 --grow --size=1
  reboot
  %packages
  @core
  %end
  示例Ubuntu Preseed文件(ubuntu1804.seed):
  d-i debian-installer/locale string en_US.UTF-8
  d-i console-setup/ask_detect boolean false
  d-i keyboard-configuration/layoutcode string us
  d-i netcfg/choose_interface select auto
  d-i netcfg/get_hostname string unassigned-hostname
  d-i netcfg/get_domain string unassigned-domain
  d-i time/zone string US/Eastern
  d-i clock-setup/utc boolean true
  d-i clock-setup/ntp boolean true
  d-i partman-auto/method string regular
  d-i partman-auto/disk string /dev/sda
  d-i partman-auto/choose_recipe select atomic
  d-i partman/confirm_write_new_label boolean true
  d-i partman/confirm boolean true
  d-i passwd/root-password-crypted password $6$yourpasswordhash
  d-i passwd/user-fullname string Ubuntu User
  d-i passwd/username string ubuntu
  d-i passwd/user-password-crypted password $6$yourpasswordhash
  tasksel tasksel/first multiselect standard
  d-i pkgsel/include string openssh-server
  d-i grub-installer/only_debian boolean true
  d-i finish-install/reboot_in_progress note
  五、同步Cobbler配置并重启服务
  cobbler sync
  systemctl restart cobblerd
  六、使用Cobbler进行自动化安装
  确保客户端机器可以通过PXE网络引导,并且已正确配置BIOS/UEFI设置。在启动时选择网络引导,Cobbler服务器将为其提供自动化安装。

华纳云 推荐文章
CentOS 7.x下配置DNS服务器基本操作 SQL数据库中删除重复数据方法有那些 Linux中APT攻击特点和手段及如何防护 Linux中apt包管理器创建临时文件失败如何解决 windows server 2008服务器安全设置初级配置详细步骤 CentOS 8和RHEL8配置EPEL仓库具体有什么方法 Netlify部署一个网站的完整演示 如何服务器上搭配大模型docker+ollama+langchain工具运行环境 Linux /etc/group的文件解析步骤 docker快速部署Stirling-PDF的一般流程
客服咨询
7*24小时技术支持
技术支持
渠道支持