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.conf
optiondomain-name
"baby.org"
;
# Domain name search list
optiondomain-name-servers114.114.114.114;
# Domain Name Server address
default-lease-
time
600;
# Default lease term (in seconds)
max-lease-
time
7200;
# Maximum lease term (in seconds)
log-facilitylocal7;
# Use rsyslog to store logs
subnet192.168.3.0netmask255.255.255.0{
range192.168.3.10192.168.3.254;
# Address pool
optionrouters192.168.3.1;
# Gateway
optionbroadcast-address192.168.3.31;
# Broadcast address
default-lease-
time
600;
max-lease-
time
7200;
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~]
#servicedhcpdconfigtest
Syntax:OK
[root@node1~]
#servicedhcpdstart
Startingdhcpd:[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/tftp
servicetftp
{
disable=no
# The service has become available
socket_type=dgram
protocol=udp
wait=
yes
user=root
server=
/usr/sbin/in
.tftpd
server_args=-s
/var/lib/tftpboot
per_source=11
cps=1002
flags=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~]
#servicexinetdrestart
Stoppingxinetd:[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_64
mkdir
: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~]
#servicehttpdstart
Add 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/default
Provide 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
..........
..........
labellinux
menulabel^Installorupgradeanexistingsystem
menudefault
kernelvmlinuz
appendinitrd=initrd.imgks=http:
//192
.168.3.2
/ks_file/ks
.cfgtext
Provide 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.cfg
You 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.cfg
text
# Installation on a text interface
reboot
# Automatically restart after installation
selinux--disabled
# Disable selinux
.....
# The following is the disk partition content.
clearpart--all--drives=sda
part
/boot
--fstype=ext4--size=500
partpv.008002--grow--size=1
volgroupvg_node1--pesize=4096pv.008002
logvol
/home
--fstype=ext4--name=lv_home--vgname=vg_node1--grow--size=100
logvol/--fstype=ext4--name=lv_root--vgname=vg_node1--grow--size=1024--maxsize=51200
logvolswap--name=lv_swap--vgname=vg_node1--grow--size=1984--maxsize=1984
url--url=
"http://192.168.3.2/centos/6/x86_64"
repo--name=
"CentOS"
--baseurl=http:
//192
.168.3.2
/centos/6/x86_64
--cost=100
The 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...