PXE batch installation and deployment CentOS6.5

Source: Internet
Author: User
How does one install Linux? And how to automatically (unattended) install it? And how to automatically install them in batches? Next we will introduce them one by one. The following uses the CentOS6 series as an example to conduct an experiment with VMware as the Virtual Machine Manager. I. installing the System 1. how do I install a Linux operating system on my pc? &

How does one install Linux? And how to automatically (unattended) install it? And how to automatically install them in batches? Next we will introduce them one by one.

 

The following uses the CentOS6 series as an example to conduct an experiment with VMware as the Virtual Machine Manager.

 

1. install the system

1. how does one install a Linux operating system on a personal pc?

The installation process for Linux is as follows:

Take a local image as an example. add POST and perform self-check, load the kernel and temporary root file system in the image file, and then start the anaconda installation program, which is interactive, help you select some operations before installation. after completing this step, enter the real installation package software to complete the system installation.

  # How to load the memory and root file system? # The general process is: execute isolinux under the isolinux directory on the CD. bin binary program, which loads # vmlinuz and initrd. img files are used to load the kernel and temporary root file systems. # After the kernel and temporary root file system are loaded, isolinux is executed. cfg script. this script displays the installation menu. # The image in splash.jpg format is displayed as the background. 1-1 # boot. the cat file provides boot: prompt to set relevant parameters. Tab can fill in all relevant parameters, 1-2. This function # is equivalent to Figure 1-1. click Tab under the corresponding menu to add relevant parameters # The following is the related files under the isolinux directory on the CD # [root @ server ~] # Ll/media/cdrom/isolinux/total 37142-r -- r -- 1 root 2048 Nov 29 2013 boot. cat-r -- 2 root 84 Nov 29 2013 boot. msg-r -- 2 root 334 Nov 28 2013 grub. conf-r -- 2 root 33392971 Nov 28 2013 initrd. img-r -- 2 root 24576 Nov 29 2013 isolinux. bin-r -- 2 root 936 Nov 29 2013 isolinux. cfg-r -- 2 root 165080 Nov 29 2013 memtest-r -- 2 root 151230 Nov 29 2013 splash.jpg-r -- 1 root root 2215 Nov 29 2013 TRANS. TBL-r -- 2 root 162860 Nov 29 2013 vesamenu. c32-r-xr-xr-x 4 root 4128368 Nov 29 2013 vmlinuz

-1 installation menu

Figure 1-2 manually add parameters for installation

  # Common parameters in Figure 1-2 are: # ip netmask gateway specifies the ip address, mask, and network management # Example: ip 172.16.10.44 netmask 255.255.0.0 gateway 172.16.0.1 # repo specifies the location of the installation package # ks specifies the location of the kickstat file. # Example: repo = # ks = cdrom:/isolinux/ks. cfg # Why should we set these parameters? # The reason is: there is no software warehouse locally, and automatic installation is implemented. # For detailed configuration parameters, refer to the Installation_Guide file for the response of http://www.rehhat.com/docs

Due to space limitations, the specific installation process is not described here.

 

2. how to implement unattended installation (kickstart )?

You can use a local image for interactive installation when installing a Linux operating system once. Now, five operating systems need to be installed, which may not be so efficient as one machine. Here, we need to use a self-made CD image to implement unattended (non-interactive installation ).

1. unattended installation (kickstart)

How does one implement unattended installation ?? Is to provide an anaconda installer. the cfg file defines and sets the pre-installation operations, such as the keyboard type, time zone, administrator password, partition information, language, and name of the installed package.

  # Select the hardware platform # platform = x86, AMD64, or Intel EM64T # firewall settings -- disabled disable -- enabled enfirewall -- disabled # upgrade the system after installation: install upgrade: upgradeinstall # network-based installation. if network-based installation is used, the url is required. url -- url = "# specify the location of the network software repository repo -- name =" CentOS "-- baseurl = ftp://172.16.10.9/pub/cdrom -- Cost = 100 # set the root password rootpw -- iscrypted $1 $ FUS6GrNf $ dArNmVbJWOo4EAKCmgdEK/# system authentication information auth -- useshadow -- passalgo = sha512 # graphical installation of graphical # keyboard type keyboard us # language lang en_US # SELinux setting selinux -- disabled # system installation and receiving Rebootreboot # setting the time zone timezone Asia/Shanghai # Nic configuration network -- bootproto = dhcp -- device = eth0 -- onboot = on # loading the kernel yes parameter bootloader -- append = "crashkernel = auto rhgb quiet" -- l Ocation = mbr -- driveorder = "sda" # clear MBR record zerombr # clear cache information clearpart -- all -- initlabel # partition information part/boot -- fstype = ext4 -- size = 200 # set logic volume partition, this is important because, logical Volume part pv.008002 -- size = 61440 volgroup vg0 -- pesize = 8192 pv.008002logvol/-- fstype = ext4 -- name = root -- vgname = vg0 -- size = 20480 logvol swap -- name = swap -- vgname = vg0 -- size = 2048 logvol/usr -- fstype = ext4 -- name = usr -- vgname = vg0 -- size = 10240 logvol /Var -- fstype = ext4 -- name = var -- vgname = vg0 -- size = 20480 # script executed before installation % pre # set welcom infoecho "Welcom !! Install CentOS 6.5 "% end # script to be executed after installation % post # set hostsecho '172. 16.0.1 server.example.com server '>/etc/hosts % end # installation package combination package % packages @ baselftp % end

The configuration file has many formats and parameters, making it difficult to configure. Therefore, graphical management tools are available. Use yum install system-config-kickstart to install this management tool. Use the system-config-kickstart command to start the graphical management tool for configuration. However, graphical management tools do not support logical volumes in Partitions. Therefore, these configuration parameters should be familiar with the configuration file.


12 # Ksvalidator ks. cfg use this tool to check for syntax errors # generally, you do not need to perform a syntax check if you use a graphical tool for configuration.

 

2. create a boot image

Before installing the system, you only need the files in the isolinux directory in the image. Therefore, use the kickstart file to create a CD image.

Specific practices:

  1. copy the isolinux Directory of the installation CD and modify the permission # cp/media/cdrom/isolinux/tmp-R # chmod 755/tmp/isolinux-R 2. copy the cfg file to the isolinux Directory # cp/roo/ks. cfg/tmp/isolinux/3. modify isolinux under the isolinux directory. the following content of the cfg file is label linux menu label ^ Install or upgrade an existing system menu default kernel vmlinuz append initrd = initrd. img # find the above content, in append initrd = initrd. add img: # ip 172.16.10.99 netmask 255.255.0.0 gateway 172.16.0.1 ks = Cdrom:/isolinux/ks. cfg # note that the software package here must exist and can be found remotely, that is, in ks. the url and repo settings in the cfg file # must be correct. 4. for details about how to create an iso image # mkisofs parameter, refer: http://wiki.osdev.org/Mkisofs # Mkisofs-R-J-T-v -- no-emul-boot -- boot-load-size 4 -- boot-info-table-V "CentOS 6.5 x86_64 boot"-B isolinux /isolinux. bin-c isolinux/boot. cat-o/root/boot. iso/tmp/isolinux

So far, we can implement unattended installation. The method is to copy the created image file boot. iso to five machines and use it as the installation image to enable unattended installation.

 

3. how to implement automatic batch installation (PXE )?

Currently, 50 machines need to be installed. if they are installed using a self-made iso image, the efficiency is not very efficient. We need to use the PXE mechanism here.

PXE (preboot execute environment, pre-start execution environment) is used to obtain an ip address for the installed machine, and then download a pxelinux.0 file on the specified server using the TFTP protocol, the function is equivalent to isolinux in the CD. bin. In combination with the kickstart file to achieve automatic batch installation.

 

1. DHCP service

DHCP (Dynamic Host Configration Protocol Dynamic Host Configuration Protocol) is a C/S service architecture. The role is to allow the client to lease an IP address on the server. For UDP transmission, the port number listened by the server is 67 and the port number listened by the client is 68.

Why can the client obtain the address after the DHCP server is available? The process of getting an address is as follows:

 

  # Step 1: There is a BIOSRom chip in the NIC, and dhcp dicover broadcast request will be sent to the LAN at startup to request an IP address # Step 2: when receiving a broadcast REQUEST from the client, the DHCP server sends a broadcast packet of dhcp offer and assigns an IP address. # Step 3: After receiving the packet, the client sends a broadcast packet of dhcp request to the server. To determine whether the IP address can be used to avoid conflict # Step 4: After the server receives the packet, it will send a dhcp ack confirmation message. then the client can lease the IP address.

Install: use yum install dhcp-y to install

Start and close:/etc/init. d/dhcpd start | error in configuration file during stop startup

Automatic startup: chkconfig dhcpd on

DHCP

2. TFTP service

TFTP (Trivial File Transfer Protocol Simple File Transfer Protocol) is actually a simple File server that provides the File download service, usually when the number of files is small. It is also a C/S architecture, with the server working on UDP port 69.

 

Install: yum install tftp-server tftp-y

This service is controlled by the super process xinetd to implement the "on-call" status. Enable the service in the/etc/xinetd. d/tftp file

  # Disable = no enable this function # Here we can also find the default release path:/var/lib/tftpboot

Start and close:/etc/init. d/xinetd start | stop

Automatic startup: chkconfig tftp on

 

3. configure PXE

The topology of the experiment is as follows:

The general process is: the installed machine leases an IP address to the DHCP server, obtains the address of the TFTP server, and downloads the pxelinux.0 file to the TFTP server to load the kernel and temporary root file system, at this time, a default file will be downloaded, which specifies the kickstart release method, find the corresponding server to download and get the kickstart file for automatic installation. Specify the repo location in the kickstart file to download the software package during installation.

 

Due to environment limitations, DHCP, TFTP, and FTP servers are all installed on machines 172.16.10.9.

Step 1: Configure dhcpx information

  # Vim/etc/dhcp/dhcpd. conf option domain-name "example.com"; # domain name option domain-name-servers 172.16.0.1; # DNS server name default-lease-time 600; # lease time max-lease-time 7200; # maximum lease time log-facility local7; subnet 172.16.0.0 netmask 255.255.255.0.0 {range 172.16.10.14 172.16.10.99; # address pool option routers 172.16.0.1; # Gateway next-server 172.16.10.9; # tftp server address filename "pxelinux.0"; # download file name} # Other parameters host, hardware, clas S. # Start the service after Configuration #/etc/init. d/dhcp start

 

 

Step 2: provide file download

  # The disk mount point is/media/cdrom # cp/usr/share/syslinux/pxelinux.0/var/lib/tftpboot # cp/media/cdrom/images/pxeboot/{initrd. img, vmlinuz}/var/lib/tftpboot # cp/media/cdrom/isolinux/{vesamenu.c32,splash.jpg}/var/lib/tftpboot # mkdir/var/lib/tftpboot/pxelinux. cfg # cp/media/cdrom/isolinux. cfg/var/lib/tftpboot/pxelinux. cfg/default # pxelinux.0 is provided by the installation package syslinux. make sure that it is installed before replication. # start the service after configuration is complete. #/etc/init. d/xinetd start

 

Step 3: provide the installation source and the ks. cfg file

  # Yum source is implemented based on ftp # yum install vsftpd-y # mkdir/var/ftp/pub/cdrom-p # mount -- bind/media/cdrom/var/ftp/pub/cdrom #/etc/init. d/vsftpd start # chkconfig vsftpd on # Create a kickstart file # it can be generated by system-config-kickstart. For example, ks. cfg # copies the ks. cfg file to the/var/ftp directory.

How to configure PXE refer to: http://www.syslinux.org/wiki/index.php/PXELINUX

 

 

Note:

1. you also need to modify the/var/lib/tftpboot/pxelinux. cfg/default file:

  Label linux menu label ^ Install or upgrade an existing system menu defaul kernel vmlinuz append initrd = initrd. img ks = ftp: // 172.16.10.9/ks. cfg # location of the ks file added # ks. the yum source in the cfg file must be available and can be found correctly.

2. firewall needs to be disabled

  #/Etc/init. d/iptables stop

 

Now, you can install them in batches. However, if a large number of packages are installed, the network bandwidth will be under great pressure. at this time, we need to use the cobbler and puppet tools to achieve this.

 

Summary: This article mainly introduces the principles and construction process of the PXE service.

This article from the "cold" blog, please be sure to keep this source http://guoting.blog.51cto.com/8886857/1533029

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.