本文共 8677 字,大约阅读时间需要 28 分钟。
Cobbler是PXE的二次开发产品所以功能更强大;
准备一台已经安装好操作系统的虚拟机:CentOS Linux release 7.5.1804 (Core) IP地址172.16.75.1安装一些必备组件:cobbler实在epel源当中的,可能直接yum安不上,所以我们先解决epel源的问题:[root@1 ~]# yum -y install epel-release然后安装组件:[root@1 ~]# yum -y install cobbler dhcp bind httpd rsync syslinux tftp-server安好,就进行下面的工作:[root@1 ~]# setenforce 0[root@1 ~]# iptables -F[root@1 ~]# systemctl start httpd[root@1 ~]# systemctl start cobblerd[root@1 ~]# cobbler check //检查,对出现的问题一一解决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 : SELinux is enabled. Please review the following wiki page for details on ensuring cobbler works correctly in your SELinux environment:4 : change 'disable' to 'no' in /etc/xinetd.d/tftp5 : 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.6 : enable and start rsyncd.service with systemctl7 : debmirror package is not installed, it will be required to manage debian deployments and repositories8 : 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 one9 : 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.解决第一个问题:我们可以看到在问题结尾有这么一行:Restart cobblerd and then run 'cobbler sync' to apply changes.
解决完这些完问题后,按照最后一行的提示操作即可:[root@1 ~]# systemctl restart cobblerd[root@1 ~]# cobbler sync完成后再次检查:ddns-update-style interim;
allow booting;
allow bootp;ignore client-updates;
set vendorclass = option vendor-class-identifier;option pxe-system-type code 93 = unsigned integer 16;
subnet 172.16.0.0 netmask 255.255.0.0 {
option routers 172.16.75.1;option domain-name-servers 172.16.75.1;option subnet-mask 255.255.0.0;range dynamic-bootp 172.16.100.100 172.16.100.254;default-lease-time 21600;max-lease-time 43200;next-server 172.16.75.1;class "pxeclients" { match if substring (option vendor-class-identifier, 0, 9) = "PXEClient";if option pxe-system-type = 00:02 { filename "ia64/elilo.efi";} else if option pxe-system-type = 00:06 { filename "grub/grub-x86.efi";} else if option pxe-system-type = 00:07 { filename "grub/grub-x86_64.efi";} else if option pxe-system-type = 00:09 { filename "grub/grub-x86_64.efi";} else { filename "pxelinux.0";}}}
group {
}与PXE不同,Cobbler可以自动帮助我们生成系统安装的yum 源,而不需要我们自己去制作,我们只要指定光盘路径就好了,并指定kickstart文件路径(这个文件的制作之前的博客中有说呦):
[root@1 ~]# mkdir /mnt/cdrom[root@1 ~]# mount -r /dev/sr0 /mnt/cdrom/[root@1 ~]# cobbler import --name="CentOS-7.5-x86_64" --path=/mnt/cdrom --kickstart=/var/lib/cobbler/kickstarts/centos7-common-ks.cfg --arch=x86_64task started: 2019-01-06_121449_importtask started (id=Media import, time=Sun Jan 6 12:14:49 2019)Found a candidate signature: breed=redhat, version=rhel6Found a candidate signature: breed=redhat, version=rhel7Found a matching signature: breed=redhat, version=rhel7Adding distros from path /var/www/cobbler/ks_mirror/CentOS-7.5-x86_64:creating new distro: CentOS-7.5-x86_64trying symlink: /var/www/cobbler/ks_mirror/CentOS-7.5-x86_64 -> /var/www/cobbler/links/CentOS-7.5-x86_64creating new profile: CentOS-7.5-x86_64associating reposchecking for rsync repo(s)checking for rhn repo(s)checking for yum repo(s)starting descent into /var/www/cobbler/ks_mirror/CentOS-7.5-x86_64 for CentOS-7.5-x86_64processing repo at : /var/www/cobbler/ks_mirror/CentOS-7.5-x86_64need to process repo/comps: /var/www/cobbler/ks_mirror/CentOS-7.5-x86_64looking for /var/www/cobbler/ks_mirror/CentOS-7.5-x86_64/repodata/comps.xmlKeeping repodata as-is :/var/www/cobbler/ks_mirror/CentOS-7.5-x86_64/repodata TASK COMPLETE 这个过程很慢,等等就好;好这个Centos7.5的就准备好了,我们在准备一个Centos6.7的:在我们的虚拟机中把Centos6.7的光盘镜像挂载上然后再进行操作:[root@1 ~]# mount -r /dev/sr0 /mnt/cdrom/[root@1 ~]# cobbler import --name="CentOS-6.7-x86_64" --path=/mnt/cdrom --kickstart=/var/lib/cobbler/kickstarts/centos6-common-ks.cfg --arch=x86_64task started: 2019-01-06_124948_importtask started (id=Media import, time=Sun Jan 6 12:49:48 2019)Found a candidate signature: breed=redhat, version=rhel6Found a matching signature: breed=redhat, version=rhel6Adding distros from path /var/www/cobbler/ks_mirror/CentOS-6.7-x86_64:LABEL local
MENU LABEL (local)MENU DEFAULTLOCALBOOT -1LABEL CentOS-6.7-i386
kernel /images/CentOS-6.7-i386/vmlinuzMENU LABEL CentOS-6.7-i386append initrd=/images/CentOS-6.7-i386/initrd.img ksdevice=bootif lang= kssendmac text ks=ipappend 2LABEL CentOS-6.7-x86_64
kernel /images/CentOS-6.7-x86_64/vmlinuzMENU LABEL CentOS-6.7-x86_64append initrd=/images/CentOS-6.7-x86_64/initrd.img ksdevice=bootif lang= kssendmac text ks=ipappend 2LABEL CentOS-7.5-x86_64
kernel /images/CentOS-7.5-x86_64/vmlinuzMENU LABEL CentOS-7.5-x86_64append initrd=/images/CentOS-7.5-x86_64/initrd.img ksdevice=bootif lang= kssendmac text ks=ipappend 2MENU end
这些自动添加的内容,这时候我们就可以打开一台没有安装操作系统的白鼠机进行测试了:
转载于:https://blog.51cto.com/huliheeyu/2339365