首页 > 代码库 > pxe+tftp+kickstart+dhcp+apache无人值守安装centos

pxe+tftp+kickstart+dhcp+apache无人值守安装centos

一、安装环境

    centos6.5  IP:192.168.100.11/24  GW:192.168.100.1

    关闭iptables、selinux

二、需要安装组件

    dhcp服务器

    tftp服务器

    kickstart生成的ks.cfg配置文件

    提供安装镜像的httpd服务器

三、安装

   1安装dhcp服务器    

      #yum install -y dhcp 
      #cp -a /usr/share/doc/dhcp-4.1.1/dhcpd.conf.sample /etc/dhcp/dhcpd.conf
      #vim dhcpd.conf
       ddns-update-style none;
       option domain-name-servers 172.30.8.8,8.8.8.8;
       log-facility local7;
       allow booting; 
       allow bootp;
       subnet 192.168.100.0 netmask 255.255.255.0 {
            range  192.168.100.200 192.168.100.250;
            option routers                  192.168.100.1;
            option subnet-mask              255.255.255.0;
            option broadcast-address        192.168.100.255;
            default-lease-time 600;
            max-lease-time 7200;
            next-server 192.168.100.11; #TFTP Serverip
            filename "pxelinux.0";   #pxelinux
        }
~     #service dhcpd start
      #chkconfig dhcpd on

     2安装tftp服务器

      #yum install -y tftp-server
      #vim /etc/xinetd.d/tftp       #改如下两行
        server_args             = -s /tftpboot
        disable                 = no
      #mkdir -p /tftpboot/pxelinux.cfg

     3配置PXE

      #yum install -y syslinux
      #cp /usr/share/syslinux/pxelinux.0 /tftpboot
      #mount -o loop CentOS-6.5-x84_64-minimal.iso /mnt
      #cp  /mnt/images/pxeboot/vmlinuz /tftpboot/vmlinuz-centos6.5
      #cp  /mnt/images/pxeboot/initrd.img  /tftpboot/initrd-centos6.5.img
      #cp  /mnt/isolinux/isolinux.cfg  /tftpboot/pxelinux.cfg/default
      #vim /tftpboot/pxelinux.cfg/default
       default linux
       prompt 0 # 显示 ‘boot: ‘ 提示符。为 ‘0‘ 时则不提示,将会直接启动 ‘default‘ 参数中指定的内容
       timeout 60
       display boot.msg
       F1 boot.msg
       F2 options.msg
       F3 general.msg
       F4 param.msg
       F5 rescue.msg
       label linux
         kernel vmlinuz-centos6.5
         append ks=http://192.168.100.11/config/ks.cfg/6.5x64.cfg initrd=initrd-centos6.5.img
       label text
         kernel vmlinuz
         append initrd=initrd.img text
       label ks
         kernel vmlinuz
         append ks initrd=initrd.img
       label local
         localboot 1
       label memtest86
         kernel memtest
         append -
       #service xinetd restart

      4安装配置httpd

       #yum install -y httpd
       #cd /var/www/html
       #mkdir -p ISO/CentOS6.5
       #mkdir -p config/ks.cfg
       #cp -a /mnt/* /var/www/html/IOS/CentOS6.5
       #service httpd start
       #chkconfig httpd on

      5准备ks.cfg文件

       #cp /root/anaconda-ks.cfg  /var/www/html/config/ks.cfg/6.5x64.cfg
       #/var/www/html/config/ks.cfg/6.5x64.cfg
         #version=DEVEL
         install
         url --url=http://192.168.100.11/ISO/CentOS6.5/  #centos6.5镜像文件路径
         lang en_US.UTF-8
         keyboard us
         network --onboot yes --device eth0 --bootproto dhcp
         rootpw  --iscrypted $6$z4dCpAjrhQPJ12i5$XqJDhMMJC6nIFXJq8m.X8aEZ.QuBvynZifPDol1KBJHolNimNEe9.xFuv4hTgl5d7LNiEkPVlQvVjK/MVckdx.
         firewall --service=ssh
         authconfig --enableshadow --passalgo=sha512
         selinux --disabled
         timezone --utc Asia/Shanghai
         bootloader --location=mbr --driveorder=sda --append="crashkernel=auto rhgb quiet"
         #分区情况
         clearpart --linux --drives=sda
         part /boot --fstype=ext4 --size=100 --ondisk=sda
         part / --fstype=ext4 --size=5000 --ondisk=sda
         part swap --size 1000 --ondisk=sda
         #repo --name="CentOS"  --baseurl=cdrom:sr0 --cost=100  #这项注释
         %packages --nobase    #选择需要安装的包
         @core
         %end

       

      

      



       





本文出自 “不莱梅乐队” 博客,谢绝转载!