1. Install Epel source
[Email protected] src]# RPM-UVH epel-release-6-8.noarch.rpm
2. Install DHCP
[email protected] ~]# Yum install dhcp-y
3. Configure DHCP
[Email protected] ~]# cp/usr/share/doc/dhcp-4.1.1/dhcpd.conf.sample/etc/dhcp/dhcpd.conf Cp:overwrite '/etc/dhcp/dhcpd.conf '? Y
[Email protected] ~]# sed-i-E '/^$/d '-e '/^#/d '/etc/dhcp/dhcpd.conf
Modifying the dhcpd.conf configuration file Ddns-update-style none;ignore client-updates;default-lease-time 86400;max-lease-time 604800;subnet 20.0.0.0 netmask 255.255.255.0 {range 20.0.0.30 20.0.0.100; Option Domain-name-servers 20.0.0.10; Option Domain-name "Kickstart"; Option Subnet-mask 255.255.255.0; Option routers 20.0.0.1; Next-server 20.0.0.10; FileName "pxelinux.0";}
|
4. Specify the NIC to start the DHCP service
[Email protected] ~]# vim/etc/sysconfig/dhcpd# Command Line Options Heredhcpdargs=eth1
5. Start DHCP
[[Email protected] ~]# service DHCPD restart[[email protected] ~]# Ps-ef | grep DHCPD | Grep-v GREPDHCPD 2832 1 0 23:41? 00:00:00/usr/sbin/dhcpd-user Dhcpd-group dhcpd eth1
6. Installing TFTP
[email protected] ~]# Yum install tftp-server-y [[email protected] ~]# vim /etc/xinetd.d/tftpservice tftp{ socket_type = dgram protocol = udp wait = yes user = root server = /usr/sbin/in.tftpd server_args = -s /var/lib/ tftpboot disable = no per_source = 11 cps = 100 2 flags = ipv4}[[email protected] ~]# /etc/init.d/ xinetd startstarting xinetd: [ OK ][[email protected] ~]# netstat -lnupactive internet connections (only servers) 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:* &nbsP; 2832/dhcpd udp 0 0 0.0.0.0:69 0.0.0.0: * 2893/xinetd |
7. Installing Nginx
[Email protected] src]# useradd nginx-m-s/sbin/nologin [email protected] nginx-1.8.1]# Yum install gcc gcc-c++ zlib pcre pcre-devel OpenSSL openssl-devel-y [Email protected] nginx-1.8.1]#/configure \ >--user=nginx \ >--group=nginx \ >--prefix=/usr/local/nginx \ >--sbin-path=/usr/sbin/nginx \ >--conf-path=/etc/nginx/nginx.conf \ >--with-http_stub_status_module \ >--with-http_ssl_module \ >--with-http_gzip_static_module \ >--with-http_sub_module \ >--with-pcre |
8. Create a directory for Kickstart to store CentOS images
[Email protected] ~]# mkdir/data/www/cent6.7-p [[email protected] ~]# mount/dev/sr0/data/www/cent6.7 Mount:block device/dev/sr0 is write-protected, Mounting Read-only [Email protected] ~]# Ls/data/www/cent6.7centos_buildtag GPL Packages rpm-gpg-key-centos-6 Rpm-gpg-key-centos-testing-6efi Images release-notes-en-us.html rpm-gpg-key-centos-debug-6 TRANS . Tbleula Isolinux Repodata rpm-gpg-key-centos-security-6
|
9. Nginx Configuration
User Nginx Nginx; Worker_processes 4; Error_log/var/log/nginx/error.log notice; Worker_rlimit_nofile 65535;
Events { Use Epoll; Worker_connections 65535; }
HTTP { Include Mime.types; Default_type Application/octet-stream;
Log_format Main ' $remote _addr-$remote _user [$time _local] "$request" ' ' $status $body _bytes_sent ' $http _referer ' ' "$http _user_agent" "$http _x_forwarded_for";
Sendfile on; Tcp_nopush on; Tcp_nodelay on; Send_timeout 60; Keepalive_timeout 60;
gzip on; Gzip_min_length 1k; Gzip_buffers 4 32k; Gzip_comp_level 3; Gzip_http_version 1.1; Gzip_types text/plain application/x-javascript text/css text/htm application/xml; Gzip_vary on;
Include vhosts/*.conf; }
[Email protected] ~]# mkdir/etc/nginx/vhosts
[Email protected] ~]# vim/etc/nginx/vhosts/mirror.conf server {Listen 80; server_name 20.0.0.10; Index index.html index.htm index.jsp; Server_tokens off; Access_log/var/log/nginx/mirror.access.log main; Location/{root/data/www; AutoIndex on; Autoindex_exact_size off; Autoindex_localtime on; }}
650) this.width=650; "src=" http://s2.51cto.com/wyfs02/M01/83/E6/wKioL1d_VICxJ9GjAACzKsWZync687.jpg "title=" 1.jpg " alt= "Wkiol1d_vicxj9gjaaczkswzync687.jpg"/>
|
10. Configuring PXE Boot
[email protected] ~]# Yum install syslinux-y [Email protected] ~]# cp/usr/share/syslinux/pxelinux.0/var/lib/tftpboot/ [Email protected] ~]# cp-a/data/www/cent6.7/isolinux/*/var/lib/tftpboot/[Email protected] ~]# ls/var/lib/tftpboot/boot.cat grub.conf isolinux.bin memtest splash.jpg vesamenu.c32boot.m SG initrd.img isolinux.cfg pxelinux.0 TRANS. TBL Vmlinuz
[Email protected] ~]# cd/var/lib/tftpboot/ [Email protected] tftpboot]# mkdir pxelinux.cfg
[Email protected] tftpboot]# cp/data/www/cent6.7/isolinux/isolinux.cfg Pxelinux.cfg/default
|
11. Create a Ks.cfg configuration file
[Email protected] ~]# Mkdir/data/www/config [Email protected] ~]# vim/data/www/config/ks.cfg # kickstart file automatically generated by anaconda. #version =rhel6installurl --url= "http://20.0.0.10/CentOS6.7/" Lang en_us. utf-8keyboard usnetwork --bootproto=dhcp --device=eth0 --onboot=on# root passwdrootpw redhatfirewall --disabledauth --useshadow --enablemd5selinux -- Disabledtimezone asia/shanghaibootloader --location=mbr --driveorder=sda --append= " Nomodeset crashkernel=auto rhgb quiet "firstboot --disablelogging --level= infozerombrskipx#part /boot --fstype=ext4 --asprimary --size=200#part swap -- Asprimary --size=512#part / --fstype=ext4 --grow --asprimary --size=200clearpart --all --initlabelpart /boot --fstype=ext4 --size=200part swap --fstype= Swap --size=2048part / --fstype=ext4 --grow --size=1reboot%packages@development%enD
|
12, modify the/var/lib/tftpboot/pxelinux.cfg/default
[Email protected] ~]# Vim/var/lib/tftpboot/pxelinux.cfg/default Default Linux #prompt 1 Timeout 600
Display Boot.msg
Menu Background Splash.jpg Menu title Welcome to CentOS 6.7! Menu Color Border 0 #ffffffff #00000000 Menu Color SEL 7 #ffffffff #ff000000 Menu Color Title 0 #ffffffff #00000000 Menu Color tabmsg 0 #ffffffff #00000000 Menu Color Unsel 0 #ffffffff #00000000 Menu Color Hotsel 0 #ff000000 #ffffffff Menu Color Hotkey 7 #ffffffff #ff000000 Menu Color ScrollBar 0 #ffffffff #00000000
Label Linux Menu label ^install or upgrade an existing system Menu default Kernel Vmlinuz Append initrd=initrd.img ks=http://20.0.0.10/config/ks.cfg Label VESA Menu Label Install system with ^basic video driver Kernel Vmlinuz Append initrd=initrd.img Nomodeset Label Rescue Menu Label ^rescue installed system Kernel Vmlinuz Append initrd=initrd.img Rescue Label Local Menu label Boot from ^local Drive Localboot 0xFFFF Label Memtest86 Menu Label ^memory Test Kernel memtest Append-
|
[Email protected] ~]#/etc/init.d/xinetd restartstopping xinetd: [OK]starti ng xinetd: [OK]
13. Create a new virtual machine
650) this.width=650; "src=" http://s1.51cto.com/wyfs02/M02/83/EB/wKiom1d_cQXzruBkAAC87suDbWY884.jpg "title=" 2.jpg " alt= "Wkiom1d_cqxzrubkaac87sudbwy884.jpg"/>
Kickstart Automatic machine