Auto install centOS6.5 under XE + kickstart
About PXE
Pxe works in the Client/Server network mode. When the Client does not have an operating system locally, it can download the image file and kickstart file from the Server over the network, the system is automatically installed based on the kickstart file. When you deploy environments for multiple servers, you can install the operating system in batches, greatly reducing the workload.
PXE dependent services:
1) dhcp: dynamically allocates network properties such as IP addresses, subnet masks, gateways, and DNS addresses to clients;
2) tftp: Provides the client with the boot program, kernel, ramdisk, and other files required for installation;
3) http: Provides the kickstart file and the installation source.
How PXE works: when the client is started, if there is no boot program locally, it will use the NIC as the boot device. In this case, the pxe function on the NIC will be activated, the pxe_client program is transferred to the memory for execution. When a DHCP address is requested for broadcast, the DHCP server in the LAN will respond and assign the IP address, subnet mask, gateway, and other network attribute configurations to it. The client downloads the pxelinux.0 file (pxe Startup File, similar to bootloader) from the specified tftp server based on the instructions of the DHCP server. After the download is complete, the client loads and executes the file, then, request the kernel, ramdisk, and anaconda program used during pxe boot to the server to start the installation process.
Dhcp and tftp client programs are generally integrated on the NIC.
Deployment process
Deploy a dhcp server
[root@node1~]#yuminstalldhcp[root@node1~]#cp/usr/share/doc/dhcp-4.1.1/dhcpd.conf.sample/etc/dhcp/dhcpd.conf[root@node1~]#vim/etc/dhcp/dhcpd.confoptiondomain-name"baby.org";# Domain name search listoptiondomain-name-servers114.114.114.114;# Domain Name Server addressdefault-lease-time600;# Default lease term (in seconds)max-lease-time7200;# Maximum lease term (in seconds)log-facilitylocal7;# Use rsyslog to store logssubnet192.168.3.0netmask255.255.255.0{range192.168.3.10192.168.3.254;# Address pooloptionrouters192.168.3.1;# Gatewayoptionbroadcast-address192.168.3.31;# Broadcast addressdefault-lease-time600;max-lease-time7200;next-server192.168.3.2;# Next server address accessed (tftp)filename"pxelinux.0";# Files to be downloaded on next-server}Check the configuration information and start the service:
[root@node1~]#servicedhcpdconfigtestSyntax:OK[root@node1~]#servicedhcpdstartStartingdhcpd:[OK]The service is running properly.
Deploy a tftp server
The tftp service is managed by the xinetd service. After the installation is complete, enable the Service in xinetd and restart the xinetd service.
[root@node1~]#yuminstalltftp-server[root@node1~]#chkconfigtftpon[root@node1~]#vim/etc/xinetd.d/tftpservicetftp{disable=no# The service has become availablesocket_type=dgramprotocol=udpwait=yesuser=rootserver=/usr/sbin/in.tftpdserver_args=-s/var/lib/tftpbootper_source=11cps=1002flags=IPv4}Server_args specifies the Service Startup parameter, and-s specifies its working directory as/var/lib/tftpboot. Place the files required by the client in this directory.
Start the service:
[root@node1~]#servicexinetdrestartStoppingxinetd:[FAILED]Startingxinetd:[OK]The service is running properly.
Deploy httpd service
[root@node1~]#yuminstallhttpd/Mnt/flash is the disk Mount directory. Create a directory under/var/www/html and bind it to/mnt/flash.
[root@node1~]#mkdir-pv/var/www/html/centos/6/x86_64mkdir:createddirectory`/var/www/html/centos'mkdir:createddirectory`/var/www/html/centos/6'mkdir:createddirectory`/var/www/html/centos/6/x86_64'[root@node1~]#mount--bind/mnt/flash//var/www/html/centos/6/x86_64/After binding, you can directly access/mnt/flash/(install the Source Path) through/var/www/html/centos/6/x86_64 ). Then start the service.
[root@node1~]#servicehttpdstartAdd the required files to the tftp service directory:
Attach a CD image to the/var/lib/tftpboot directory. The Mount directory of the CD image is/mnt/flash.
[root@node1~]#cp/mnt/flash/images/pxeboot/{vmlinuz,initrd.img}/var/lib/tftpboot/[root@node1~]#cp/mnt/flash/isolinux/{boot.msg,vesamenu.c32,splash.jpg}/var/lib/tftpboot/[root@node1~]#mkdir/var/lib/tftpboot/pxelinux.cfg[root@node1~]#cp/mnt/flash/isolinux/isolinux.cfg/var/lib/tftpboot/pxelinux.cfg/defaultProvide the PXE Working Environment (that is, provide the pxelinux.0 file ):
[root@node1~]#yuminstallsyslinux[root@node1~]#cp/usr/share/syslinux/pxelinux.0/var/lib/tftpboot/As the background image, vesamenu. c32 reads the image menu displayed in the isolinux. cfg file. The isolinux. cfg file must be in the pxelinux. cfg directory and named default. The graphic menu is as follows:
By default, the image menu is the first item, and its corresponding configuration file is pxelinux. modify the default file in the cfg directory and add the startup parameter ks for the first item so that it can obtain the kickstart file when loading the kernel.
[root@node1~]#vim/var/lib/tftpboot/pxelinux.cfg/default....................labellinuxmenulabel^Installorupgradeanexistingsystemmenudefaultkernelvmlinuzappendinitrd=initrd.imgks=http://192.168.3.2/ks_file/ks.cfgtextProvide kickstart files
[root@node1~]#cp/root/anaconda-ks.cfg/var/www/html/ks_file/ks.cfg[root@node1~]#chmod+r/var/www/html/ks_file/ks.cfgYou can use system-config-kickstart to create a kickstart file. The procedure is very simple. Install system-config-kickstart, type the system-config-kickstart command to start a graphical interface, configure the parameters for installation, and then generate the kickstart file (similar to the operating system installation process ).
There is a anaconda-ks.cfg file under the/root directory, which is the kickstart file, which records the installation parameters of the local operating system and other information. You can modify and use it. The following are the modifications:
[root@node1~]#vim/var/www/html/ks_file/ks.cfgtext# Installation on a text interfacereboot# Automatically restart after installationselinux--disabled# Disable selinux.....# The following is the disk partition content.clearpart--all--drives=sdapart/boot--fstype=ext4--size=500partpv.008002--grow--size=1volgroupvg_node1--pesize=4096pv.008002logvol/home--fstype=ext4--name=lv_home--vgname=vg_node1--grow--size=100logvol/--fstype=ext4--name=lv_root--vgname=vg_node1--grow--size=1024--maxsize=51200logvolswap--name=lv_swap--vgname=vg_node1--grow--size=1984--maxsize=1984url--url="http://192.168.3.2/centos/6/x86_64"repo--name="CentOS"--baseurl=http://192.168.3.2/centos/6/x86_64--cost=100The above repo parameter specifies the installation Source Path and points it to the CD image path on the httpd server.
Test availability
Deploy a virtual machine without an operating system in the CIDR Block and start it. You can also set the first boot device of a virtual machine as the NIC.
Guide Interface
Find the installation Source
Software Package Installation Process
Complete the test...