cobbler 无人值守安装 esxi
准备
开始安装
yum -y install cobbler cobbler-web dnsmasq syslinux pykickstart bind rsync fence-agents debmirror dhcp xinetd
配置
1、启动服务
?
systemctl start cobblerd.service
systemctl start httpd.service
systemctl start tftp.service
2、配置cobbler
/etc/cobbler/settings:
manage_dhcp: 1
manage_dns: 1
manage_rsync: 1
pxe_just_once: 1
next_server: 172.16.100.128
server: 172.16.100.128
对应的行数已经标注出来了
3、配置cobbler的DHCP模版
vi /etc/cobbler/dhcp.template
subnet 172.16.100.0 netmask 255.255.255.0 {
option routers 172.16.100.254;
option domain-name-servers 114.114.114.114;
option subnet-mask 255.255.255.0;
range dynamic-bootp 172.16.100.130 172.16.100.140;
default-lease-time 21600;
max-lease-time 43200;
next-server $next_server;
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";
}
}
}
4、配置xinetd管理tftp
sed -ri '/disable/c\disable = no' /etc/xinetd.d/tftp
systemctl restart xinetd
5、 6和7、debian support
sed -i 's/@dists="sid";/#@dists="sid";/' /etc/debmirror.conf
sed -i 's/@arches="i386";/#@arches="i386";/' /etc/debmirror.conf
7、重启cobbler
systemctl restart cobblerd
8、排错
使用cobbler check检查配置文件有什么短缺,缺什么配置什么
selinux 关闭之后需要重启服务器生效。
访问一下
https://172.16.100.128/cobbler_web
重启服务器之后启动服务
特别说明 这些服务不要设置成开机自启状态
systemctl restart cobblerd.service
systemctl restart httpd.service
systemctl restart tftp.service
systemctl restart xinetd
cobbler check
[root@cobbler ~]# cobbler check
The following are potential configuration items that you may want to fix:
1 : 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.
2 : enable and start rsyncd.service with systemctl
3 : 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 one
Restart cobblerd and then run 'cobbler sync' to apply changes.
运行 cobbler get-loaders 报错
[root@cobbler ~]# cobbler get-loaders
task started: 2021-08-05_201639_get_loaders
task started (id=Download Bootloader Content, time=Thu Aug 5 20:16:39 2021)
downloading https://cobbler.github.io/loaders/README to /var/lib/cobbler/loaders/README
Exception occured: <class 'urlgrabber.grabber.URLGrabError'>
Exception value: [Errno 14] HTTPS Error 404 - Not Found
Exception Info:
File "/usr/lib/python2.7/site-packages/cobbler/remote.py", line 82, in run
rc = self._run(self)
File "/usr/lib/python2.7/site-packages/cobbler/remote.py", line 176, in runner
return self.remote.api.dlcontent(self.options.get("force",False), self.logger)
File "/usr/lib/python2.7/site-packages/cobbler/api.py", line 735, in dlcontent
return grabber.run(force)
File "/usr/lib/python2.7/site-packages/cobbler/action_dlcontent.py", line 73, in run
urlgrabber.grabber.urlgrab(src, filename=dst, proxies=proxies)
File "/usr/lib/python2.7/site-packages/urlgrabber/grabber.py", line 773, in urlgrab
return default_grabber.urlgrab(url, filename, **kwargs)
File "/usr/lib/python2.7/site-packages/urlgrabber/grabber.py", line 1220, in urlgrab
return _run_callback(opts.failfunc, opts)
File "/usr/lib/python2.7/site-packages/urlgrabber/grabber.py", line 1071, in _run_callback
return cb(obj)
File "/usr/lib/python2.7/site-packages/urlgrabber/grabber.py", line 1065, in _do_raise
raise obj.exception
!!! TASK FAILED !!!
解决方法
链接:https://pan.baidu.com/s/1SaMH7TvcpJXqPkV1AMCAGg 提取码:stvu
解压缩到/var/lib/cobbler/loaders目录
root@cobbler loaders]# ll
总用量 84
-rw-r--r-- 1 root root 0 8月 5 20:23 COPYING.elilo
-rw-r--r-- 1 root root 0 8月 5 20:23 COPYING.syslinux
-rw-r--r-- 1 root root 0 8月 5 20:23 COPYING.yaboot
-rw-r--r-- 1 root root 0 8月 5 20:23 elilo-ia64.efi
-rw-r--r-- 1 root root 0 8月 5 20:23 grub-x86_64.efi
-rw-r--r-- 1 root root 0 8月 5 20:23 grub-x86.efi
-rw-r--r-- 1 root root 55140 8月 5 20:23 menu.c32
-rw-r--r-- 1 root root 26759 8月 5 20:23 pxelinux.0
-rw-r--r-- 1 root root 0 8月 5 20:23 README
-rw-r--r-- 1 root root 0 8月 5 20:23 yaboot
再次运行 cobbler get-loaders 任务完成
[root@cobbler loaders]# cobbler check
The following are potential configuration items that you may want to fix:
1 : enable and start rsyncd.service with systemctl
2 : 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 one
Restart cobblerd and then run 'cobbler sync' to apply changes.
[root@cobbler loaders]# openssl passwd -1 -salt 'hahaha' '542@123'
$1$hahaha$THoZ8R44wcH3noSBkK0yu0
[root@cobbler loaders]# vi /etc/cobbler/settings
101 #default_password_crypted: "$1$mF86/UHC$WvcIcX2t6crBz2onWxyac."
102 default_password_crypted: "$1$hahaha$THoZ8R44wcH3noSBkK0yu0"
[root@cobbler loaders]# systemctl enable rsyncd && systemctl start rsyncd
[root@cobbler loaders]# systemctl restart cobblerd
[root@cobbler loaders]# cobbler check
No configuration problems found. All systems go.
到这里安装和基本配置完成。
配置PXE和镜像
[root@cobbler ~]# mount -o loop -t iso9660 /mnt/VMware_ESXi_6.5.0.update03_15177306_LNV_20191216.iso /media/
[root@vm9005 cobbler]# systemctl restart cobblerd.service
[root@vm9005 cobbler]# cobbler import --path=/media/ --name=esxi6.5 --arch=x86_64
task started: 2021-08-05_125455_import
task started (id=Media import, time=Thu Aug 5 12:54:55 2021)
Found a candidate signature: breed=vmware, version=esxi65
running: /usr/bin/file /var/www/cobbler/ks_mirror/esxi6.5-x86_64/vmware-esx-base-osl.txt
received on stdout: /var/www/cobbler/ks_mirror/esxi6.5-x86_64/vmware-esx-base-osl.txt: UTF-8 Unicode text, with very long lines, with CRLF, CR line terminators
received on stderr:
Found a matching signature: breed=vmware, version=esxi65
Adding distros from path /var/www/cobbler/ks_mirror/esxi6.5-x86_64:
running: /usr/bin/file /var/www/cobbler/ks_mirror/esxi6.5-x86_64/tools.t00
received on stdout: /var/www/cobbler/ks_mirror/esxi6.5-x86_64/tools.t00: gzip compressed data, was "tools-light.tar", from Unix, last modified: Thu May 30 08:30:33 2019
received on stderr:
creating new distro: esxi6.5-x86_64
trying symlink: /var/www/cobbler/ks_mirror/esxi6.5-x86_64 -> /var/www/cobbler/links/esxi6.5-x86_64
creating new profile: esxi6.5-x86_64
associating repos
*** TASK COMPLETE *
# Sample scripted installation file
# for ESXi 6+
#
vmaccepteula
reboot --noeject
rootpw --iscrypted $default_password_crypted
install --firstdisk --overwritevmfs
clearpart --firstdisk --overwritevmfs
#$SNIPPET('network_config')
network --bootproto=dhcp #新增加
%pre --interpreter=busybox
$SNIPPET('kickstart_start')
$SNIPPET('pre_install_network_config')
%post --interpreter=busybox
r=busybox #新增加
$SNIPPET('kickstart_done')
[root@cobbler loaders]# cobbler sync
task started: 2021-08-05_210436_sync
task started (id=Sync, time=Thu Aug 5 21:04:36 2021)
running pre-sync triggers
cleaning trees
removing: /var/www/cobbler/images/esxi6.5-x86_64
removing: /var/lib/tftpboot/pxelinux.cfg/default
removing: /var/lib/tftpboot/grub/images
removing: /var/lib/tftpboot/grub/efidefault
removing: /var/lib/tftpboot/images/esxi6.5-x86_64
removing: /var/lib/tftpboot/s390x/profile_list
copying bootloaders
trying hardlink /var/lib/cobbler/loaders/pxelinux.0 -> /var/lib/tftpboot/pxelinux.0
trying hardlink /var/lib/cobbler/loaders/menu.c32 -> /var/lib/tftpboot/menu.c32
trying hardlink /var/lib/cobbler/loaders/yaboot -> /var/lib/tftpboot/yaboot
trying hardlink /usr/share/syslinux/memdisk -> /var/lib/tftpboot/memdisk
trying hardlink /var/lib/cobbler/loaders/grub-x86_64.efi -> /var/lib/tftpboot/grub/grub-x86_64.efi
trying hardlink /var/lib/cobbler/loaders/grub-x86.efi -> /var/lib/tftpboot/grub/grub-x86.efi
copying distros to tftpboot
copying files for distro: esxi6.5-x86_64
trying hardlink /var/www/cobbler/ks_mirror/esxi6.5-x86_64/mboot.c32 -> /var/lib/tftpboot/images/esxi6.5-x86_64/mboot.c32
trying hardlink /var/www/cobbler/ks_mirror/esxi6.5-x86_64/imgpayld.tgz -> /var/lib/tftpboot/images/esxi6.5-x86_64/imgpayld.tgz
copying images
generating PXE configuration files
generating PXE menu structure
copying files for distro: esxi6.5-x86_64
trying hardlink /var/www/cobbler/ks_mirror/esxi6.5-x86_64/mboot.c32 -> /var/www/cobbler/images/esxi6.5-x86_64/mboot.c32
trying hardlink /var/www/cobbler/ks_mirror/esxi6.5-x86_64/imgpayld.tgz -> /var/www/cobbler/images/esxi6.5-x86_64/imgpayld.tgz
Writing template files for esxi6.5-x86_64
generating: /var/lib/tftpboot/images/esxi6.5-x86_64/cobbler-boot.cfg
rendering DHCP files
generating /etc/dhcp/dhcpd.conf
rendering DNS files
generating /etc/named.conf
generating /etc/secondary.conf
rendering TFTPD files
generating /etc/xinetd.d/tftp
processing boot_files for distro: esxi6.5-x86_64
cleaning link caches
rendering Rsync files
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: service named restart
received on stdout:
received on stderr: Redirecting to /bin/systemctl restart named.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.manage_genders
running python trigger cobbler.modules.scm_track
running shell triggers from /var/lib/cobbler/triggers/change/*
*** TASK COMPLETE ***
第二次排错
一切准备就绪之后,创建一台虚拟机,怎么样都进入不了PXE引导界面。对比正常和非正常的两台服务器,发现启动的服务一样,端口一样。
问题出在虚拟机上,原来是虚拟机的操作系统选择VMWARE 系列之后,不支持PXE引导。
[root@cobbler tftpboot]# systemctl list-units | grep running
auditd.service loaded active running Security Auditing Service
chronyd.service loaded active running NTP client/server
cobblerd.service loaded active running Cobbler Helper Daemon
crond.service loaded active running Command Scheduler
dbus.service loaded active running D-Bus System Message Bus
dhcpd.service loaded active running DHCPv4 Server Daemon
getty@tty1.service loaded active running Getty on tty1
httpd.service loaded active running The Apache HTTP Server
irqbalance.service loaded active running irqbalance daemon
lvm2-lvmetad.service loaded active running LVM2 metadata daemon
named.service loaded active running Berkeley Internet Name Domain (DNS)
NetworkManager.service loaded active running Network Manager
polkit.service loaded active running Authorization Manager
postfix.service loaded active running Postfix Mail Transport Agent
rsyncd.service loaded active running fast remote file copy program daemon
rsyslog.service loaded active running System Logging Service
systemd-journald.service loaded active running Journal Service
systemd-logind.service loaded active running Login Service
systemd-udevd.service loaded active running udev Kernel Device Manager
tftp.service loaded active running Tftp Server
tuned.service loaded active running Dynamic System Tuning Daemon
vgauthd.service loaded active running VGAuth Service for open-vm-tools
vmtoolsd.service loaded active running Service for virtual machines hosted on VMware
dbus.socket loaded active running D-Bus System Message Bus Socket
lvm2-lvmetad.socket loaded active running LVM2 metadata daemon socket
systemd-journald.socket loaded active running Journal Socket
systemd-udevd-control.socket loaded active running udev Control Socket
systemd-udevd-kernel.socket loaded active running udev Kernel Socket
tftp.socket loaded active running Tftp Server Activation Socket
|