[root@localhost ~]# yum info dhcp Loaded plugins: fastestmirror, refresh-packagekit, security Loading mirror speeds from cached hostfile * base: mirrors.cn99.com * extras: mirrors.cn99.com * updates: mirrors.cn99.com Available Packages Name : dhcp Arch : x86_64 Epoch : 12 Version : 4.1.1 Release : 53.P1.el6.centos.1 Size : 823 k Repo : updates Summary : Dynamic host configuration protocol software URL : http://isc.org/products/DHCP/ License : ISC Description : DHCP (Dynamic Host Configuration Protocol) is a protocol which allows : individual devices on an IP network to get their own network : configuration information (IP address, subnetmask, broadcast address, : etc.) from a DHCP server. The overall purpose of DHCP is to make it : easier to administer a large network. The dhcp package includes the : ISC DHCP service and relay agent. : : To use DHCP on your network, install a DHCP service (or relay agent), : and on clients run a DHCP client daemon. The dhcp package provides : the ISC DHCP service and relay agent.
subnet 192.168.56.0 netmask 255.255.255.0 { range 192.168.56.10 192.168.56.20; }
这就行了. 后面全部注释掉:
1
:.,$s/^[^#]/#/
行了, 现在就开启服务吧.
1 2 3 4
[root@localhost ~]# netstat -anup Active Internet connections (servers and established) Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name udp 0 0 0.0.0.0:67 0.0.0.0:* 1159/dhcpd
监听在UDP的67号端口上.
那么现在开启另外一台主机, 使用dhclient来强行通过这个来获得这个DHCP服务器分配的IP.
在DHCP服务器上可以查看到日志:
1 2 3 4 5 6 7 8
Oct 8 13:53:21 node1 dhcpd: DHCPDISCOVER from 00:0c:29:a7:00:c1 via eth0 Oct 8 13:53:21 node1 dhcpd: DHCPDISCOVER from 00:0c:29:a7:00:cb via eth0 Oct 8 13:53:22 node1 dhcpd: DHCPOFFER on 192.168.230.100 to 00:0c:29:a7:00:c1 via eth0 Oct 8 13:53:22 node1 dhcpd: DHCPOFFER on 192.168.230.135 to 00:0c:29:a7:00:cb via eth0 Oct 8 13:53:22 node1 dhcpd: DHCPREQUEST for 192.168.230.100 (192.168.230.133) from 00:0c:29:a7:00:c1 via eth0 Oct 8 13:53:22 node1 dhcpd: DHCPACK on 192.168.230.100 to 00:0c:29:a7:00:c1 via eth0 Oct 8 13:53:22 node1 dhcpd: DHCPREQUEST for 192.168.230.135 (192.168.230.133) from 00:0c:29:a7:00:cb via eth0 Oct 8 13:53:22 node1 dhcpd: DHCPACK on 192.168.230.135 to 00:0c:29:a7:00:cb via eth0
tftp我们之前也说过的, 即 简单文件传输协议( Trivial File Transfer Protocol ). 我们来看一下介绍:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
[root@node1 ~]# yum info tftp-server Loaded plugins: fastestmirror, refresh-packagekit, security Loading mirror speeds from cached hostfile Available Packages Name : tftp-server Arch : x86_64 Version : 0.49 Release : 8.el6 Size : 39 k Repo : base Summary : The server for the Trivial File Transfer Protocol (TFTP) URL : http://www.kernel.org/pub/software/network/tftp/ License : BSD Description : The Trivial File Transfer Protocol (TFTP) is normally used only for : booting diskless workstations. The tftp-server package provides the : server for TFTP, which allows users to transfer files to and from a : remote machine. TFTP provides very little security, and should not be : enabled unless it is expressly needed. The TFTP server is run from : /etc/xinetd.d/tftp, and is disabled by default.
[root@node1 ~]# yum info syslinux Loaded plugins: fastestmirror, refresh-packagekit, security Loading mirror speeds from cached hostfile Installed Packages Name : syslinux Arch : x86_64 Version : 4.02 Release : 4.el6 Size : 2.0 M Repo : installed From repo : base Summary : Simple kernel loader which boots from a FAT filesystem URL : http://syslinux.zytor.com/wiki/index.php/The_Syslinux_Project License : GPLv2+ Description : SYSLINUX is a suite of bootloaders, currently supporting DOS FAT : filesystems, Linux ext2/ext3 filesystems (EXTLINUX), PXE network boots : (PXELINUX), or ISO 9660 CD-ROMs (ISOLINUX). It also includes a tool, : MEMDISK, which loads legacy operating systems from these media.
[root@master ~]# cobbler check The following are potential configuration items that you may want to fix:
1 : 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. 2 : SELinux is enabled. Please review the following wiki page for details on ensuring cobbler works correctly in your SELinux environment: https://github.com/cobbler/cobbler/wiki/Selinux 3 : change 'disable' to 'no'in /etc/xinetd.d/tftp 4 : 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 systemctl 6 : comment out 'dists' on /etc/debmirror.conf for proper debian support 7 : comment out 'arches' on /etc/debmirror.conf for proper debian support 8 : 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 9 : fencing tools were not found, and are required to use the (optional) power management features. install cman or fence-agents to use them
Restart cobblerd and then run 'cobbler sync' to apply changes.
[root@master ~]# cobbler import --name=CentOS7_x86_64 --path=/media/ task started: 2017-12-11_203518_import task started (id=Media import, time=Mon Dec 11 20:35:18 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/CentOS7_x86_64: creating new distro: CentOS7-x86_64 trying symlink: /var/www/cobbler/ks_mirror/CentOS7_x86_64 -> /var/www/cobbler/links/CentOS7-x86_64 creating new profile: CentOS7-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/CentOS7_x86_64 for CentOS7-x86_64 processing repo at : /var/www/cobbler/ks_mirror/CentOS7_x86_64 need to process repo/comps: /var/www/cobbler/ks_mirror/CentOS7_x86_64 looking for /var/www/cobbler/ks_mirror/CentOS7_x86_64/repodata/*comps*.xml Keeping repodata as-is :/var/www/cobbler/ks_mirror/CentOS7_x86_64/repodata *** TASK COMPLETE *** [root@master ~]# cd /var/www/ [root@master www]# ls cgi-bin cobbler html [root@master www]# cd /etc/httpd/conf.d/ [root@master conf.d]# ls autoindex.conf cobbler.conf README userdir.conf welcome.conf [root@master conf.d]# head cobbler.conf # This configuration file allows cobbler data # to be accessed over HTTP.
AliasMatch ^/cblr(?!/svc/)(.*)?$ "/var/www/cobbler$1" AliasMatch ^/cobbler_track(.*)?$ "/var/www/cobbler$1" #AliasMatch ^/cobbler(.*)?$ "/var/www/cobbler$1" Alias /cobbler /var/www/cobbler Alias /cobbler_webui_content /var/www/cobbler_webui_content
[root@master ~]# cobbler sync task started: 2017-12-11_203756_sync task started (id=Sync, time=Mon Dec 11 20:37:56 2017) running pre-sync triggers cleaning trees removing: /var/www/cobbler/images/CentOS7-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/CentOS7-x86_64 removing: /var/lib/tftpboot/s390x/profile_list copying bootloaders copying distros to tftpboot copying files for distro: CentOS7-x86_64 trying hardlink /var/www/cobbler/ks_mirror/CentOS7_x86_64/images/pxeboot/vmlinuz -> /var/lib/tftpboot/images/CentOS7-x86_64/vmlinuz trying hardlink /var/www/cobbler/ks_mirror/CentOS7_x86_64/images/pxeboot/initrd.img -> /var/lib/tftpboot/images/CentOS7-x86_64/initrd.img copying images generating PXE configuration files generating PXE menu structure copying files for distro: CentOS7-x86_64 trying hardlink /var/www/cobbler/ks_mirror/CentOS7_x86_64/images/pxeboot/vmlinuz -> /var/www/cobbler/images/CentOS7-x86_64/vmlinuz trying hardlink /var/www/cobbler/ks_mirror/CentOS7_x86_64/images/pxeboot/initrd.img -> /var/www/cobbler/images/CentOS7-x86_64/initrd.img Writing template files for CentOS7-x86_64 rendering TFTPD files generating /etc/xinetd.d/tftp processing boot_files for distro: CentOS7-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 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 ***
接着我们重新打开另外一台主机. 就可以看到下面的画面:
但是这显然不够, 我们想要达成无人值守的自动化安装, 就需要kickstart文件的帮助.
脱坑指南, 如果说你在这个时候尝试进入安装的时候出现了故障:
dracut-initqueue: curl: (23) Failed writing body (11904 != 16384) loop: module loaded dracut-initqueue[579]: mount: wrong fs type, bad option, bad superblock on /dev/loop0 dracut-initqueue[579]: missing codepage or helper program, or other error dracut-initqueue[579]: In some cases useful info is found in syslog - try dracut-initqueue[579]: dmesg | tail or so. dracut-initqueue[579]:Mumount: /run/initramfs/squashfs: not mounted dracut-initqueue[579]: /sbin/dmsquash-lice-root: line 273: printf: write error: No space left on device