1.背景介绍
作为运维,在公司经常遇到一些机械性重复工作要做,例如:为新机器装系统,一台两台机器装系统,可以用光盘、U盘等介质安装,1小时也完成了,但是如果有成百台的服务器还要用光盘、U盘去安装,就显得有些力不从心了。PXE技术就能很好的解决这个问题,本文将会对PXE的工作原理有所介绍,而cobbler则是基于PXE技术的工作原理的二次封装,通过命令的方式简化了PXE配置过程。
2.PXE原理介绍
2.1原理与概念
事实上把PXE称作是一种引导方式而不是安装方式似乎更加准确,PXE(Pre-boot Execution Environment)是由Intel设计的协议,它可以使计算机通过网络启动,但是有一个前提条件是计算机的网卡必须具有引导功能,这个网卡中要有一个PXE客户端。当计算机POST自检成功以后,BIOS把网卡中ROM的PXE客户端调入内存执行,PXE客户端通过网络中的DHCP服务器获取一个IP地址,拿到IP地址以后PXE继续引导计算机与网络中的TFTP客户端建立连接,从而从TFTP服务器中获取开机引导文件之后请求并下载安装需要的文件。在这个过程中需要一台服务器来提供启动文件、安装文件、以及安装过程中的自动应答文件等。
2.2原理介绍
Client向PXE Server上的DHCP发送IP地址请求消息,DHCP检测Client是否合法(主要是检测Client的网卡MAC地址),如果合法则返回Client的IP地址,同时将启动文件pxelinux.0的位置信息一并传送给Client
Client向PXE Server上的TFTP发送获取pxelinux.0请求消息,TFTP接收到消息之后再向Client发送pxelinux.0大小信息,试探Client是否满意,当TFTP收到Client发回的同意大小信息之后,正式向Client发送pxelinux.0
Client执行接收到的pxelinux.0文件
Client向TFTP Server发送针对本机的配置信息文件(在TFTP服务的pxelinux.cfg目录下,这是系统菜单文件,格式和isolinux.cfg格式一样,功能也是类似),TFTP将配置文件发回Client,继而Client根据配置文件执行后续操作。
Client向TFTP发送Linux内核请求信息,TFTP接收到消息之后将内核文件发送给Client
Client向TFTP发送根文件请求信息,TFTP接收到消息之后返回Linux根文件系统
Client启动Linux内核
Client下载安装源文件,读取自动化安装脚本
3.Cobbler
鉴于pxe自动装系统网上一搜一大把,我就不详细操作举例了,今天主要讲一讲Cobbler。
3.1Cobbler介绍
Cobbler是一个Linux服务器快速网络安装的服务,由python开发,小巧轻便(15k行python代码),可以通过PXE的方式来快速安装、重装物理服务器和虚拟机,同时还可以管理DHCP,DNS,TFTP、RSYNC以及yum仓库、构造系统ISO镜像。
Cobbler可以使用命令行方式管理,也提供了基于Web的界面管理工具(cobbler-web),还提供了API接口,可以方便二次开发使用。
3.2Cobbler工作流程
client裸机配置了从网络启动后,开机后会广播包请求DHCP服务器 (cobbler server)发送其分配好的一个IP
DHCP服务器(cobbler server)收到请求后发送responese,包括其ip地址
client裸机拿到ip后再向cobbler server发送请求OS引导文件的请求
cobbler server告诉裸机OS引导文件的名字和TFTP server的ip和 port
client裸机通过上面告知的TFTP server地址通信,下载引导文件
client裸机执行执行该引导文件,确定加载信息,选择要安装的os, 期间会再向cobbler server请求kickstart文件和os image
cobbler server发送请求的kickstart和os iamge
client裸机加载kickstart文件
client裸机接收os image,安装该os image
3.3Cobbler集成的服务
PXE服务支持
DHCP服务管理
DNS服务管理(可选bind,dnsmasq)
电源管理
Kickstart服务支持
YUM仓库管理
TFTP(PXE启动时需要)
Apache(提供kickstart的安装源,并提供定制化的kickstart配置)
3.4配置目录
配置文件目录:
/etc/cobbler
/etc/cobbler/settings : cobbler 主配置文件
/etc/cobbler/iso/: iso模板配置文件
/etc/cobbler/pxe: pxe模板文件
/etc/cobbler/power: 电源配置文件
/etc/cobbler/user.conf: web服务授权配置文件
/etc/cobbler/users.digest: web访问的用户名密码配置文件
/etc/cobbler/dhcp.template : dhcp服务器的的配置末班
/etc/cobbler/dnsmasq.template : dns服务器的配置模板
/etc/cobbler/tftpd.template : tftp服务的配置模板
/etc/cobbler/modules.conf : 模块的配置文件
数据目录:
/var/lib/cobbler/config/: 用于存放distros,system,profiles 等信 息配置文件
/var/lib/cobbler/triggers/: 用于存放用户定义的cobbler命令
/var/lib/cobbler/kickstart/: 默认存放kickstart文件
/var/lib/cobbler/loaders/: 存放各种引导程序 镜像目录
/var/www/cobbler/ks_mirror/: 导入的发行版系统的所有数据
/var/www/cobbler/images/ : 导入发行版的kernel和initrd镜像用于 远程网络启动
/var/www/cobbler/repo_mirror/: yum 仓库存储目录
日志目录:
/var/log/cobbler/installing: 客户端安装日志
/var/log/cobbler/cobbler.log : cobbler日志
3.5命令介绍
cobbler commands介绍
cobbler check 核对当前设置是否有问题
cobbler list 列出所有的cobbler元素
cobbler report 列出元素的详细信息
cobbler sync 同步配置到数据目录,更改配置最好都要执行下
cobbler reposync 同步yum仓库
cobbler distro 查看导入的发行版系统信息
cobbler system 查看添加的系统信息
cobbler profile 查看配置信息
3.6/etc/cobbler/settings中重要的参数设置
default_password_crypted: “$1$gEc7ilpP$pg5iSOj/mlxTxEslhRvyp/”
manage_dhcp:1
manage_tftpd:1
pxe_just_once:1
next_server:< tftp服务器的 IP 地址>
server:
4.Cobbler安装
4.1系统信息
Centos7安装cobbler的版本为V2.8.5
Centos8安装cobbler的版本为V3.2.0(不推荐)
文章以Centos7部署V2.8.5版本为例进行示范
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 [root @localhost ~] CentOS Linux release 7.2 .1511 (Core) [root @localhost ~] 3.10 .0 -327 .el7.x86_64[root @localhost ~] Disabled [root @localhost ~] ● firewalld.service - firewalld - dynamic firewall daemon Loaded: loaded (/usr/lib/systemd/system/firewalld.service; disabled; vendor preset: enabled) Active: inactive (dead) Docs: man :firewalld(1 ) [root @localhost ~] 10.0 .0.101 [root @localhost ~] localhost.localdomain [root @localhost ~]
4.2配置yum源
1 [root @localhost ~]wget -O /tmp/system.sh http://hudisk.tpddns.cn:8097 /cobbler/repo/system.sh && sh /tmp/system.sh
4.3开始安装Cobbler
4.3.1安装cobbler以及相关的软件
4.3.2启动相关服务
1 2 3 4 [root @localhost ~] [root @localhost ~] [root @localhost ~] [root @localhost ~]
4.3.3通过cobbler check 查看问题
1 2 3 4 5 6 7 8 9 10 11 12 13 [root @localhost ~] The following are potential configuration items that you may want to fix: 1 : The 'server' field in /etc/cobbler/settings must be set to something other than localhost, or kickstarting features will not work. This should be a resolvable hostname or IP for the boot server as reachable by all machines that will use it.2 : For PXE to be functional, the 'next_server' field in /etc/cobbler/settings must be set to something other than 127.0 .0.1 , and should match the IP of the boot server on the PXE network.3 : change 'disable' to 'no' in /etc/xinetd.d/tftp4 : Some network boot-loaders are missing from /var/lib/cobbler/loaders, you may run 'cobbler get-loaders' to download them, or, if you only want to handle x86/x86_64 netbooting, you may ensure that you have installed a *recent* version of the syslinux package installed and can ignore this message entirely. Files in this directory, should you want to support all architectures, should include pxelinux.0 , menu.c32, elilo.efi, and yaboot. The 'cobbler get-loaders' command is the easiest way to resolve these requirements.5 : enable and start rsyncd.service with systemctl6 : debmirror package is not installed, it will be required to manage debian deployments and repositories7 : The default password used by the sample templates for newly installed machines (default_password_crypted in /etc/cobbler/settings) is still set to 'cobbler' and should be changed, try : "openssl passwd -1 -salt 'random-phrase-here' 'your-password-here'" to generate new one8 : fencing tools were not found, and are required to use the (optional) power management features. install cman or fence-agents to use themRestart cobblerd and then run 'cobbler sync' to apply changes.
按照提示一个一个的解决问题:
问题1:
问题2:
问题3:
vim /etc/xinetd.d/tftp
1 2 3 4 5 6 7 8 9 10 11 12 13 service tftp { socket_type = dgram protocol = udp wait = yes user = root server = /usr/sbin/in.tftpd server_args = -s /var/lib/tftpboot disable = no per_source = 11 cps = 100 2 flags = IPv4 }
问题4:(现在官网已经不提供下载,我这里提供一份下载 链接,下载后解压到/var/lib/cobbler/目录就好了,执行cobbler sync生效)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 [root @localhost ~] task started: 2017 -10 -15_113824_get_loaders task started (id=Download Bootloader Content, time=Sun Oct 15 11 :38 :24 2017 ) downloading https://cobbler.github.io/loaders/README to /var/lib/cobbler/loaders/README downloading https://cobbler.github.io/loaders/COPYING.elilo to /var/lib/cobbler/loaders/COPYING.elilo downloading https://cobbler.github.io/loaders/COPYING.yaboot to /var/lib/cobbler/loaders/COPYING.yaboot downloading https://cobbler.github.io/loaders/COPYING.syslinux to /var/lib/cobbler/loaders/COPYING.syslinux downloading https://cobbler.github.io/loaders/elilo-3 .8 -ia64 .efi to /var/lib/cobbler/loaders/elilo-ia64 .efi downloading https://cobbler.github.io/loaders/yaboot-1 .3.17 to /var/lib/cobbler/loaders/yaboot downloading https://cobbler.github.io/loaders/pxelinux.0 -3 .86 to /var/lib/cobbler/loaders/pxelinux.0 downloading https://cobbler.github.io/loaders/menu.c32-3 .86 to /var/lib/cobbler/loaders/menu.c32 downloading https://cobbler.github.io/loaders/grub-0 .97 -x86 .efi to /var/lib/cobbler/loaders/grub-x86 .efi downloading https://cobbler.github.io/loaders/grub-0 .97 -x86_64 .efi to /var/lib/cobbler/loaders/grub-x86_64 .efi *** TASK COMPLETE ***
问题5:
1 2 3 4 [root @localhost ~] Created symlink from /etc/systemd/system/multi-user .target.wants/rsyncd.service to /usr/lib/systemd/system/rsyncd.service. [root @localhost ~]
问题6:
跟debian 相关,可以忽略
问题7:
1 2 3 4 5 [root @localhost ~] $1 $123456 $wOSEtcyiP2N /IfIl15W6Z0[root @localhost ~] default_password_crypted: "$1 $123456 $wOSEtcyiP2N /IfIl15W6Z0
再次执行cobbler check
1 2 3 4 [root @localhost ~] The following are potential configuration items that you may want to fix: 1 : debmirror package is not installed, it will be required to manage debian deployments and repositories
以上两个问题暂时可以忽略
4.3.4配置cobbler-DHCP
修改cobbler配置
1 2 [root @localhost ~] manage_dhcp: 1
修改dhcp.templates配置文件(仅列出修改部分)
1 2 3 4 5 6 7 8 9 10 [root @localhost ~] subnet 10.0 .0.0 netmask 255.255 .255.0 { option routers 10.0 .0.2 ; option domain-name -servers 10.0 .0.2 ; option subnet-mask 255.255 .255.0 ; range dynamic-bootp 10.0 .0.100 10.0 .0.250 ; default-lease -time 3600 ; } next-server 192.168 .10.1 ; filename "pxelinux.0" ;
重启服务并同步配置,改完dhcp必须要sync同步配置
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 [root @localhost ~] [root @localhost ~] task started: 2017 -10 -15_122732_sync task started (id=Sync, time=Sun Oct 15 12 :27 :32 2017 ) running pre-sync triggers cleaning trees removing: /var/lib/tftpboot/pxelinux.cfg/default removing: /var/lib/tftpboot/grub/efidefault removing: /var/lib/tftpboot/grub/grub-x86 .efi removing: /var/lib/tftpboot/grub/images removing: /var/lib/tftpboot/grub/grub-x86_64 .efi removing: /var/lib/tftpboot/s390x/profile_list copying bootloaders trying hardlink /var/lib/cobbler/loaders/grub-x86 .efi -> /var/lib/tftpboot/grub/grub-x86 .efi trying hardlink /var/lib/cobbler/loaders/grub-x86_64 .efi -> /var/lib/tftpboot/grub/grub-x86_64 .efi copying distros to tftpboot copying images generating PXE configuration files generating PXE menu structure rendering DHCP files generating /etc/dhcp/dhcpd.conf rendering TFTPD files generating /etc/xinetd.d/tftp cleaning link caches running post-sync triggers running python triggers from /var/lib/cobbler/triggers/sync/post/* running python trigger cobbler.modules.sync_post_restart_services running: dhcpd -t -q received on stdout: received on stderr: running: service dhcpd restart received on stdout: received on stderr: Redirecting to /bin/systemctl restart dhcpd.service running shell triggers from /var/lib/cobbler/triggers/sync/post/* running python triggers from /var/lib/cobbler/triggers/change/* running python trigger cobbler.modules.scm_track running shell triggers from /var/lib/cobbler/triggers/change/* *** TASK COMPLETE ***
检查dhcp
1 2 3 4 [root @localhost ~] udp 0 0 0.0 .0.0 :39776 0.0 .0.0 :* 53381 /dhcpd udp 0 0 0.0 .0.0 :67 0.0 .0.0 :* 53381 /dhcpd udp6 0 0 :::46146 :::* 53381 /dhcpd
4.3.5导入CentOs-7的镜像
#Ubuntu镜像注意事项
不支持desktop、live版本(仅支持LTS server version版本)
推荐ubuntu-18.04-server-amd64
#使用光驱加载Centos6的系统镜像
1 2 # 为后续cobble导入镜像做准备 mount -t iso9660 -o loop,ro /dev/cdrom /mn
#导入镜像的过程
将光盘文件复制到/var/www/cobbler/ks_mirror目录下
并且自动生成apahce的一个子配置文件/etc/httpd/conf.d/cobbler.conf将镜像发布出去
#导入Centos6和Centos7导入无异常
#导入Centos8的镜像会报错解决办法在本文最下面下方cobbler导入镜像失败
#导入Ubuntu 18.04之后的版本也是导入失败(非LTS版本可能支持的不友好)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 [root @localhost ~] mount : /dev/sr0 is write-protected , mounting read-only [root @localhost ~] task started: 2017 -10 -15_145401_import task started (id=Media import, time=Sun Oct 15 14 :54 :01 2017 ) Found a candidate signature: breed=redhat, version=rhel6 Found a candidate signature: breed=redhat, version=rhel7 Found a matching signature: breed=redhat, version=rhel7 Adding distros from path /var/www/cobbler/ks_mirror/Centos-7 .2 -x86_64 : creating new distro: Centos-7 .2 -x86_64 trying symlink: /var/www/cobbler/ks_mirror/Centos-7 .2 -x86_64 -> /var/www/cobbler/links/Centos-7 .2 -x86_64 creating new profile: Centos-7 .2 -x86_64 associating repos checking for rsync repo(s) checking for rhn repo(s) checking for yum repo(s) starting descent into /var/www/cobbler/ks_mirror/Centos-7 .2 -x86_64 for Centos-7 .2 -x86_64 processing repo at : /var/www/cobbler/ks_mirror/Centos-7 .2 -x86_64 need to process repo/comps: /var/www/cobbler/ks_mirror/Centos-7 .2 -x86_64 looking for /var/www/cobbler/ks_mirror/Centos-7 .2 -x86_64 /repodata/*comps*.xml Keeping repodata as-is :/var/www/cobbler/ks_mirror/Centos-7 .2 -x86_64 /repodata *** TASK COMPLETE ***
# --path 镜像路径
# --name 为安装源定义一个名字
# --arch 指定安装源是32位、64位、ia64, 目前支持的选项有: x86│x86_64│ia64
# 安装源的唯一标示就是根据name参数来定义,本例导入成功后,安装源的唯一标示就是:CentOS-7.1-x86_64
导入完镜像以后,那么就使查看下cobbler
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 [root @localhost ks_mirror ] distros: Centos-7 .2 -x86_64 profiles: Centos-7 .2 -x86_64 systems: repos: images: mgmtclasses: packages: files:
4.3.6导入kickstarts配置文件
这里提供两个自己在用的ks文件
1 2 3 4 5 6 7 8 9 10 [root @localhost kickstarts ] default.ks esxi5-ks .cfg legacy.ks sample_autoyast.xml sample_esx4.ks sample_esxi5.ks sample_old.seed esxi4-ks .cfg install_profiles pxerescue.ks sample_end.ks sample_esxi4.ks sample.ks sample.seed [root @localhost kickstarts ] /var/lib/cobbler/kickstarts [root @localhost kickstarts ] rz waiting to receive. zmodem trl+C ȡ 100 % 1 KB 1 KB/s 00 :00 :01 0 Errors.
查看导入信息及默认ks文件
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 [root @localhost kickstarts ] distros: ========== Name : Centos-7 .2 -x86_64 Architecture : x86_64 TFTP Boot Files : {} Breed : redhat Comment : Fetchable Files : {} Initrd : /var/www/cobbler/ks_mirror/Centos-7 .2 -x86_64 /images/pxeboot/initrd.img Kernel : /var/www/cobbler/ks_mirror/Centos-7 .2 -x86_64 /images/pxeboot/vmlinuz Kernel Options : {} Kernel Options (Post Install) : {} Kickstart Metadata : {'tree' : 'http://@@http_server@@/cblr/links/Centos-7.2-x86_64' } Management Classes : [] OS Version : rhel7 Owners : ['admin' ] Red Hat Management Key : <<inherit>> Red Hat Management Server : <<inherit>> Template Files : {} profiles: ========== Name : Centos-7 .2 -x86_64 TFTP Boot Files : {} Comment : DHCP Tag : default Distribution : Centos-7 .2 -x86_64 Enable gPXE? : 0 Enable PXE Menu? : 1 Fetchable Files : {} Kernel Options : {} Kernel Options (Post Install) : {} Kickstart : /var/lib/cobbler/kickstarts/sample_end.ks Kickstart Metadata : {} Management Classes : [] Management Parameters : <<inherit>> Name Servers : [] Name Servers Search Path : [] Owners : ['admin' ] Parent Profile : Internal proxy : Red Hat Management Key : <<inherit>> Red Hat Management Server : <<inherit>> Repos : [] Server Override : <<inherit>> Template Files : {} Virt Auto Boot : 1 Virt Bridge : xenbr0 Virt CPUs : 1 Virt Disk Driver Type : raw Virt File Size(GB) : 5 Virt Path : Virt RAM (MB) : 512 Virt Type : kvm systems: ========== repos: ========== images: ========== mgmtclasses: ========== packages: ========== files: ==========
如果安装的是centos7以上的系统,需要把网卡名称改成eth0需要执行以下命令。
1 cobbler profile edit --name=CentOS-7.2-x86_64 --kopts='net.ifnames=0 biosdevname=0'
我ks文件(只是简单配置的,具体可以按自己业务来)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 part biosboot --fstype =biosboot --size =1 install url --url ='http://cobbler_ip/cobbler/ks_mirror/Centos-7.6-x86_64/' reboot text lang zh_CN.UTF-8 keyboard us zerombr bootloader --location =mbr timezone --utc Asia/Shanghai authconfig --enableshadow --passalgo =sha512 rootpw --iscrypted $default_password_crypted clearpart --all --initlabel part /boot --fstype xfs --size 800 --ondrive =sda part swap --size 16384 --ondrive =sda part / --fstype xfs --grow --size 1 --ondrive =sda firstboot --disable selinux --disabled firewall --disabled logging --level =info %packages @base @compat-libraries @debugging @development tree nmap sysstat ntpdate lrzsz net-tools wget net-snmp dos2unix telnet iptraf ncurses-devel openssl-devel zlib-devel OpenIPMI-tools screen %end %post mkdir -pv /data /sh cd /data /shwget http://cobbler_ip/centos7.shchmod 755 centos7.sh bash -x centos7.sh %end
检查ks命令
编辑修改指定ks文件为我们刚刚上传的ks
1 2 3 4 5 [root @localhost kickstarts ] Centos-7 .2 -x86_64 [root @localhost kickstarts ] [root @localhost kickstarts ]
4.3.7同步cobbler
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 [root @localhost kickstarts ] task started: 2017 -10 -15_154709_sync task started (id=Sync, time=Sun Oct 15 15 :47 :09 2017 ) running pre-sync triggers cleaning trees removing: /var/www/cobbler/images/Centos-7 .2 -x86_64 removing: /var/lib/tftpboot/pxelinux.cfg/default removing: /var/lib/tftpboot/grub/efidefault removing: /var/lib/tftpboot/grub/grub-x86 .efi removing: /var/lib/tftpboot/grub/images removing: /var/lib/tftpboot/grub/grub-x86_64 .efi removing: /var/lib/tftpboot/images/Centos-7 .2 -x86_64 removing: /var/lib/tftpboot/s390x/profile_list copying bootloaders trying hardlink /var/lib/cobbler/loaders/grub-x86 .efi -> /var/lib/tftpboot/grub/grub-x86 .efi trying hardlink /var/lib/cobbler/loaders/grub-x86_64 .efi -> /var/lib/tftpboot/grub/grub-x86_64 .efi copying distros to tftpboot copying files for distro: Centos-7 .2 -x86_64 trying hardlink /var/www/cobbler/ks_mirror/Centos-7 .2 -x86_64 /images/pxeboot/vmlinuz -> /var/lib/tftpboot/images/Centos-7 .2 -x86_64 /vmlinuz trying hardlink /var/www/cobbler/ks_mirror/Centos-7 .2 -x86_64 /images/pxeboot/initrd.img -> /var/lib/tftpboot/images/Centos-7 .2 -x86_64 /initrd.img copying images generating PXE configuration files generating PXE menu structure copying files for distro: Centos-7 .2 -x86_64 trying hardlink /var/www/cobbler/ks_mirror/Centos-7 .2 -x86_64 /images/pxeboot/vmlinuz -> /var/www/cobbler/images/Centos-7 .2 -x86_64 /vmlinuz trying hardlink /var/www/cobbler/ks_mirror/Centos-7 .2 -x86_64 /images/pxeboot/initrd.img -> /var/www/cobbler/images/Centos-7 .2 -x86_64 /initrd.img Writing template files for Centos-7 .2 -x86_64 rendering DHCP files generating /etc/dhcp/dhcpd.conf rendering TFTPD files generating /etc/xinetd.d/tftp processing boot_files for distro: Centos-7 .2 -x86_64 cleaning link caches running post-sync triggers running python triggers from /var/lib/cobbler/triggers/sync/post/* running python trigger cobbler.modules.sync_post_restart_services running: dhcpd -t -q received on stdout: received on stderr: running: service dhcpd restart received on stdout: received on stderr: Redirecting to /bin/systemctl restart dhcpd.service running shell triggers from /var/lib/cobbler/triggers/sync/post/* running python triggers from /var/lib/cobbler/triggers/change/* running python trigger cobbler.modules.scm_track running shell triggers from /var/lib/cobbler/triggers/change/* *** TASK COMPLETE ***
5.新建一个虚拟机测试
为避免发生未知问题,先把服务端所有服务重启
1 2 3 [root @localhost cobbler ] [root @localhost cobbler ] [root @localhost cobbler ]
新建虚拟机从pxe启动,如果出现下面图形,则说明已经成功了
上图中网址也可以定制为我们自己的
1 2 3 [root @localhost cobbler ] MENU TITLE Cobbler | I'm here # 修改这里为你想修改的内容 [root@localhost cobbler]# cobbler sync # 同步之后就可以看到效果了
6.通过MAC地址定制化安装
我们可以根据不同的MAC地址来给安装 不同的操作系统,配置不同的静态iP,设置不同的主机名等等,虚拟机查看MAC地址步骤如图
配置定制化安装(需要验证,后续验证后添加验证结果)
1 2 3 4 5 6 7 8 9 10 11 12 [root @localhost cobbler ] --name =linux-web01 \ --mac =00 :0 C:29 :3 B:03 :9 B \ --profile =Centos-7 .2 -x86_64 \ --ip -address =10.0 .0.200 \ --subnet =255.255 .255.0 \ --gateway =10.0 .0.2 \ --interface =eth0 \ --static =1 \ --hostname =linux-web01 \ --name -servers ="10.0.0.2" \ --kickstart =/var/lib/cobbler/kickstarts/Centos7.2 -x86_64 .cfg
system add # 添加定制系统
name # 定制系统名称
mac # mac地址
profile #指定profile
ip-address # 指定IP地址
subnet # 指定子网掩码
gateway # 指定网关
interface # 指定网卡,eth0上面配置已经修改,centos7默认网卡名称不是eth0
static # 1表示启用静态IP
hostname # 定义hostname
name-server # dns服务器
kickstart # 指定ks文件
配置成功后我们可以查看到刚才定制的系统
1 2 [root @localhost cobbler ] linux-web01
接下来我们创建一个虚拟机,mac地址为00:0C:29:3B:03:9B,启动后你就会发现自动进入安装系统了,等安装完以后,所有的配置都和我们当初设置的一样。
7.使用koan实现重新安装系统
在客户端安装koan(要配置好源)
1 2 [root @localhost ~] [root @localhost ~]
重新安装客户端系统
重启系统后会自动重装系统
导入镜像失败
1 2 3 4 5 6 [root@cobbler]# cobbler import --name=Centos8-arch-x8664 --path-/mnt task started: 2021-03-02_150652_import task started (id-Hedia import, time-Tue Mar 2 15:06:52 2021) Found a candidate signature: breed-redhat, version-rhel8 No signature matched in /var/ww/cobbler/ks mirror/Centos8-x86 64 !!! TASK FAILED !
#修改签名文件(修改rhel8键值对内的二行信息即可)
vim /var/lib/cobbler/distro_signatures.json
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 "rhel8": { "signatures": [ "BaseOS" ], "version_file": "(redhat|sl|slf|centos|centos-linux|centos-stream|oraclelinux|vzlinux)-release-(?!notes)([\\w]*-)*8[\\.-]+(.*)\\.rpm", "version_file_regex": null, "kernel_arch": "kernel-(.*).rpm", "kernel_arch_regex": null, "supported_arches": [ "aarch64", "i386", "x86_64", "ppc64le" ], "supported_repo_breeds": [ "rsync", "rhn", "yum" ], "kernel_file": "vmlinuz(.*)", "initrd_file": "initrd(.*)\\.img", "isolinux_ok": false, "default_kickstart": "/var/lib/cobbler/kickstarts/sample_end.ks", "kernel_options": "", "kernel_options_post": "", "boot_files": [] },
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 *#更新签名文件(不推荐)* cobbler signature report *#列出* cobbler signature update *#更新* 如果执行此命令的话 导入还是会报错,所以不需要执行:报错如下: # cobbler import --path=/mnt --name=Centos-8.3 --arch=x86_64 task started: 2021-11-20_222449_import task started (id=Media import, time=Sat Nov 20 22:24:49 2021) Found a candidate signature: breed=suse, version=sles15generic Found a candidate signature: breed=suse, version=opensuse15.0 Found a candidate signature: breed=suse, version=opensuse15.1 Found a candidate signature: breed=redhat, version=rhel8 No signature matched in /var/www/cobbler/ks_mirror/Centos-8.3-x86_64 !!! TASK FAILED !!! *#重启服务* systemctl restart cobblerd.service
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 # Ubuntu 18.10 "cosmic": { "signatures":["dists", ".disk"], "version_file":"Release|mini-info", "version_file_regex":"Codename: cosmic|Ubuntu 18.10", "kernel_arch":"linux-headers-(.*)\\.deb", "kernel_arch_regex":null, "supported_arches":["i386","amd64"], "supported_repo_breeds":["apt"], "kernel_file":"linux(.*)", "initrd_file":"initrd(.*)\\.gz", "isolinux_ok":false, "default_kickstart":"/var/lib/cobbler/kickstarts/sample.seed", "kernel_options":"", "kernel_options_post":"", "boot_files":[] # Ubuntu 19.04 "disco": { "signatures":["dists", ".disk"], "version_file":"Release|mini-info", "version_file_regex":"Codename: disco|Ubuntu 19.04", "kernel_arch":"linux-headers-(.*)\\.deb", "kernel_arch_regex":null, "supported_arches":["i386","amd64"], "supported_repo_breeds":["apt"], "kernel_file":"linux(.*)", "initrd_file":"initrd(.*)\\.gz", "isolinux_ok":false, "default_kickstart":"/var/lib/cobbler/kickstarts/sample.seed", "kernel_options":"", "kernel_options_post":"", "boot_files":[] # Ubuntu 19.10 "eoan": { "signatures":["dists", ".disk"], "version_file":"Release|mini-info", "version_file_regex":"Codename: eoan|Ubuntu 19.10", "kernel_arch":"linux-headers-(.*)\\.deb", "kernel_arch_regex":null, "supported_arches":["i386","amd64"], "supported_repo_breeds":["apt"], "kernel_file":"linux(.*)", "initrd_file":"initrd(.*)\\.gz", "isolinux_ok":false, "default_kickstart":"/var/lib/cobbler/kickstarts/sample.seed", "kernel_options":"", "kernel_options_post":"", "boot_files":[] # 重启服务 systemctl restart cobblerd.service
原文来自:https://www.cnblogs.com/linuxliu/p/7668048.html