1、安装epel源
[[email protected] src]# rpm -Uvh epel-release-6-8.noarch.rpm
2、安装DHCP
[[email protected] ~]# yum install dhcp -y
3、配置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 修改dhcpd.conf配置文件 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、指定网卡启动DHCP服务
[[email protected] ~]# vim /etc/sysconfig/dhcpd # Command line options here DHCPDARGS=eth1
5、启动DHCP
[[email protected] ~]# service dhcpd restart [[email protected] ~]# ps -ef | grep dhcpd | grep -v grep dhcpd 2832 1 0 23:41 ? 00:00:00 /usr/sbin/dhcpd -user dhcpd -group dhcpd eth1
6、安装TFTP
[[email protected] ~]# yum install tftp-server -y [[email protected] ~]# vim /etc/xinetd.d/tftp service 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 start Starting xinetd: [ OK ] [[email protected] ~]# netstat -lnup Active 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:* 2832/dhcpd udp 0 0 0.0.0.0:69 0.0.0.0:* 2893/xinetd |
7、安装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 \ |
8、创建kickstart存放centos镜像的目录
[[email protected] ~]# mkdir /data/www/Cent6.7 -p [[email protected] ~]# mount /dev/sr0 /data/www/Cent6.7 [[email protected] ~]# ls /data/www/Cent6.7 CentOS_BuildTag GPL Packages RPM-GPG-KEY-CentOS-6 RPM-GPG-KEY-CentOS-Testing-6 EFI images RELEASE-NOTES-en-US.html RPM-GPG-KEY-CentOS-Debug-6 TRANS.TBL EULA isolinux repodata RPM-GPG-KEY-CentOS-Security-6 |
9、Nginx配置
user nginx nginx; worker_processes 4; error_log /var/log/nginx/error.log notice; worker_rlimit_nofile 65535; events http { log_format main ‘$remote_addr - $remote_user [$time_local] "$request" ‘ sendfile 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; } } |
10、配置PXE引导
[[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.c32 boot.msg initrd.img isolinux.cfg pxelinux.0 TRANS.TBL vmlinuz [[email protected] ~]# cd /var/lib/tftpboot/ [[email protected] tftpboot]# cp /data/www/Cent6.7/isolinux/isolinux.cfg pxelinux.cfg/default |
11、创建ks.cfg配置文件
[[email protected] ~]# mkdir /data/www/config [[email protected] ~]# vim /data/www/config/ks.cfg # Kickstart file automatically generated by anaconda. #version=RHEL6 install url --url="http://20.0.0.10/CentOS6.7/" lang en_US.UTF-8 keyboard us network --bootproto=dhcp --device=eth0 --onboot=on # Root passwd rootpw redhat firewall --disabled auth --useshadow --enablemd5 selinux --disabled timezone Asia/Shanghai bootloader --location=mbr --driveorder=sda --append="nomodeset crashkernel=auto rhgb quiet" firstboot --disable logging --level=info zerombr skipx #part /boot --fstype=ext4 --asprimary --size=200 #part swap --asprimary --size=512 #part / --fstype=ext4 --grow --asprimary --size=200 clearpart --all --initlabel part /boot --fstype=ext4 --size=200 part swap --fstype=swap --size=2048 part / --fstype=ext4 --grow --size=1 reboot %packages @development %end |
12、修改/var/lib/tftpboot/pxelinux.cfg/default
[[email protected] ~]# vim /var/lib/tftpboot/pxelinux.cfg/default default linux #prompt 1 display boot.msg menu background splash.jpg label linux |
[[email protected] ~]# /etc/init.d/xinetd restart Stopping xinetd: [ OK ] Starting xinetd: [ OK ]
13、新建虚拟机