Experiment: Build a PXE Server to automatically install an unattended system
Install HTTP on the PXE Server and the newly installed server to achieve load balancing.
Create a master-slave DNS Server
Step 1: Configure DHCP to assign IP addresses to hosts that require system installation.
Set the Server IP address to 192.168.100.11.
[[Email protected] ~] # Ifconfig eth0 | grep "Inet ADDR"
Inet ADDR: 192.168.100.11 bcast: 192.168.100.255 mask: 255.255.255.0
[[Email protected] ~] #
Install DHCP
[[Email protected] ~] # Yum-y install DHCP
[[Email protected] ~] # Rpm-Q DHCP
Dhcp-3.0.5-31.el5_8.1
[[Email protected] ~] #
Modify the DHCP configuration file as follows:
[[Email protected] ~] # Cat/etc/DHCPD. conf
Ddns-Update-style interim;
Next-server 192.168.100.11;
Filename "pxelinux.0 ";
Subnet 192.168.100.0 netmask 255.255.255.0 {
Option subnet-mask limit 255.0;
Option domain-name "candy.com ";
Option domain-name-servers 192.168.100.11;
Range dynamic-BOOTP 192.168.100.128 192.168.100.254;
}
[[Email protected] ~] #
Start DHCP
[[Email protected] ~] # Service DHCPD restart
Disable DHCPD: [OK]
Start DHCPD: [OK]
[[Email protected] ~] # Chkconfig DHCPD on
[[Email protected] ~] #
Step 2: configure the TFTP service
TFTP is installed by default.
[[Email protected] ~] # Rpm-Q TFTP
Tftp-0.49-2
[[Email protected] ~] # Rpm-q tftp-Server
Tftp-server-0.49-2
[[Email protected] ~] #
Start the xinetd service
[[Email protected] ~] # Vi/etc/xinetd. d/TFTP
Disable = No
[[Email protected] ~] #/Etc/init. d/xinetd restart
Stop xinetd: [OK]
Start xinetd: [OK]
[[Email protected] ~] # Chkconfig xinetd on
[[Email protected] ~] #
Copy the Kernel File and initialization file to the TFTP directory.
[[Email protected] pxeboot] # cp initrd. IMG vmlinuz/tftpboot/
[[Email protected] pxeboot] # pwd
/Media/images/pxeboot
[[Email protected] pxeboot] # cp/usr/share/syslinux/pxelinux.0/tftpboot/
[[Email protected] pxeboot] #
[[Email protected] pxeboot] # cd/tftpboot/
[[Email protected] tftpboot] # ls
Initrd. IMG Linux-install pxelinux.0 vmlinuz
[[Email protected] tftpboot] # mkdir/tftpboot/pxelinux. cfg
[[Email protected] tftpboot] #
[[Email protected] tftpboot] # cp/Media/isolinux. cfg/tftpboot/pxelinux. cfg/Default
[[Email protected] tftpboot] #
Step 3: Configure NFS sharing so that the installation source can be found during system installation.
[[Email protected]/] # mkdir-P/data/ISO/rhel5.9
[[Email protected]/] # cp-RF/MISC/CD/*/data/ISO/rhel5.9/
[[Email protected]/] # Cat/etc/exports
/Data/ISO/rhel5.9 * (RO)
[[Email protected]/] # service Portmap restart
Stop Portmap: [OK]
Start Portmap: [OK]
[[Email protected]/] # chkconfig Portmap on
[[Email protected]/] # service NFS restart
Disable NFS mountd: [failed]
Disable the NFS daemon: [failed]
Disable NFS quotas: [failed]
Start the NFS service: [OK]
Disable NFS quota: [OK]
Start the NFS daemon: [OK]
Start NFS mountd: [OK]
Stopping RPC idmapd: [OK]
Starting RPC idmapd: [OK]
[[Email protected]/] # chkconfig NFS on
[[Email protected]/] #
Step 4: Configure DNS (optional)
[[Email protected]/] # rpm-Q bind-chroot caching-nameserver
Bind-9.3.6-20.P1.el5_8.5
Bind-chroot-9.3.6-20.P1.el5_8.5
Package caching-nameserver Is Not Installed
[[Email protected]/] #
[[Email protected]/] #
[[Email protected]/] # Yum-y install caching-nameserver
[[Email protected]/] # rpm-Q bind-chroot caching-nameserver
Bind-9.3.6-20.P1.el5_8.5
Bind-chroot-9.3.6-20.P1.el5_8.5
Caching-nameserver-9.3.6-20.P1.el5_8.5
[[Email protected]/] #
[[Email protected]/] # cd/var/named/chroot/etc/
[[Email protected] etc] # cp-P named. caching-nameserver.conf named. conf
[[Email protected] etc] #
[[Email protected] etc] # diff named. caching-nameserver.conf named. conf
15c15
<Listen-on port 53 {127.0.0.1 ;};
---
> Listen-on port 53 {192.168.100.11 ;};
27, 28c27, 28
<Allow-query {localhost ;};
<Allow-query-Cache {localhost ;};
---
> Allow-query {Any ;};
> Allow-query-Cache {Any ;};
37, 38c37, 38
<Match-clients {localhost ;};
<Match-destinations {localhost ;};
---
> Match-clients {Any ;};
> Match-destinations {Any ;};
[[Email protected] etc] #
[[Email protected] named] # Cat candy.com. Zone
$ TTL 86400
@ In SOA candy.com. root.candy.com .(
2014092201; Serial (D. Adams)
3 h; refresh
15 m; retry
1 W; expiry
1D); Minimum
In NS dns1.candy.com.
Dns1 in a 192.168.100.11
$ Generate 20-30 station $ in a 192.168.100. $
[[Email protected] named] #
[[Email protected] named] # Cat candy.com. ARPA
$ TTL 86400
@ In SOA candy.com. root.candy.com .(
2014092201; Serial (D. Adams)
3 h; refresh
15 m; retry
1 W; expiry
1D); Minimum
In NS dns1.candy.com.
11 In PTR dns1.candy.com.
$ Generate 20-30 $ in PTR station $ .candy.com.
[[Email protected] named] #
[[Email protected] named] #/etc/init. d/named restart
Stop named: [OK]
Start named: [OK]
[[Email protected] named] # chkconfig named on
[[Email protected] named] #
[[Email protected] named] # host station21.candy.com 192.168.100.11
Using Domain Server:
Name: 192.168.100.11
Address: 192.168.100.11 #53
Aliases:
Station21.candy.com has address 192.168.100.21
[[Email protected] named] #
[[Email protected] named] #
[[Email protected] named] # host 192.168.100.30 192.168.100.11
Using Domain Server:
Name: 192.168.100.11
Address: 192.168.100.11 #53
Aliases:
30.100.168.192.in-ADDR. Arpa Domain Name Pointer station30.candy.com.
[[Email protected] named] #
Step 5: Configure kickstart for unattended installation
When configuring the yum library, the title in the configuration file must start with RHEL; otherwise, the software package cannot be read.
[[Email protected]/] # Yum-y install system-config-kickstart
[[Email protected] ~] # System-config-kickstart
Configure production ks. cfg file
Use http to access files
[[Email protected] ~] # Ls/var/www/html/KS. cfg
/Var/www/html/KS. cfg
[[Email protected] ~] #
To add a statement, skip the step of entering the cdkey during Automatic Installation
[[Email protected] ~] # Vi/var/www/html/KS. cfg
Key -- skip
[[Email protected] ~] #/Etc/init. d/httpd restart
Stop httpd: [OK]
Start httpd: [OK]
[[Email protected] ~] #
Modify the following file to read the KS. cfg file during installation.
[[Email protected] ~] # Vi/tftpboot/pxelinux. cfg/Default
Append Ks = http: // 192.168.100.11/KS. cfg initrd = initrd. img
[[Email protected] ~] #
Step 6: install and configure HTTP on the newly installed Machine
Create an HTML file on the PXE Server and copy it to the newly installed server.
[[Email protected] ~] # Cat/var/www/html/index.html
<HTML> <title> 2014-09-23 </title>
<Head>
<Body> </body>
</Html>
[[Email protected] ~] #
[[Email protected] ~] # SCP/var/www/html/index.html 192.168.100.21:/var/www/html/index.html
[[Email protected] ~] #
Both servers have the same name.
[[Email protected] ~] # Grep servername/etc/httpd/CONF/httpd. conf
Servername www.candy.com: 80
[[Email protected] ~] #
[[Email protected]/] # grep servername/etc/httpd/CONF/httpd. conf
Servername www.candy.com: 80
[[Email protected]/] #
Step 7: Set the slave DNS Server
Modify the primary configuration file of the primary DNS, add authorization information, and only allow updates from the DNS server
[[Email protected] ~] # Vi/var/named/chroot/etc/named. conf
Allow-transfer {192.168.100.21 ;};
[[Email protected] ~] #
Modify the zone file, add domain name resolution from the DNS server, and HTTP server domain name resolution
[[Email protected] ~] # Cat/var/named/chroot/var/named/candy.com. Zone
$ TTL 86400
@ In SOA candy.com. root.candy.com .(
2014092302; Serial (D. Adams)
3 h; refresh
15 m; retry
1 W; expiry
1D); Minimum
In NS dns1.candy.com.
In NS dns2.candy.com.
Dns1 in a 192.168.100.11
Dns2 in a 192.168.100.21
WWW in a 192.168.100.11
In a 192.168.100.21
[[Email protected] ~] #
[[Email protected] ~] # Cat/var/named/chroot/var/named/candy.com. ARPA
$ TTL 86400
@ In SOA candy.com. root.candy.com .(
2014092301; Serial (D. Adams)
3 h; refresh
15 m; retry
1 W; expiry
1D); Minimum
In NS dns1.candy.com.
In NS dns2.candy.com.
11 In PTR dns1.candy.com.
12 In PTR dns2.candy.com.
[[Email protected] ~] #
Configure the slave DNS server and add the following configuration
[[Email protected]/] # tail-10/var/named/chroot/etc/named. rfc1912.zones
Zone "candy.com" in {
Type slave;
File "Slaves/candy.com. Zero ";
Masters {192.168.100.11 ;};
};
Zone "100.168.192.in-ADDR. Arpa" in {
Type slave;
File "Slaves/candy.com. Arpa ";
Masters {192.168.100.11 ;};
};
[[Email protected]/] #
After the service is restarted, the zone file is automatically generated.
[[Email protected] 30/] #/etc/init. d/named restart
Stop named: [OK]
Start named: [OK]
[[Email protected]/] # ls/var/named/chroot/var/named/slaves/
Candy.com. Arpa candy.com. Zero
[[Email protected]/] #
Build a PXE Server to automatically install an unattended system