zoukankan      html  css  js  c++  java
  • 基于HTTP和TFTP的PXE批量自动化安装Linux系统

    CentOS 6.5 PXE自动化部署系统

    拓扑图如下:

     

    步骤:

    1、  安装http服务,上传ISO文件

    [root@UCS-1 ~]# yum install httpd –y

    [root@UCS-1 ~]# chkconfig --add httpd

    [root@UCS-1 ~]# chkconfig --level 35 httpd on

    [root@UCS-1 ~]# /etc/init.d/httpd start

    [root@UCS-1 ~]# mkdir -p /var/www/html/os/6

    [root@UCS-1 ~]# mount /dev/cdrom /mnt

    [root@UCS-1 ~]# cd /mnt

    [root@UCS-1 mnt]# cp -r * /var/www/html/os/6

    [root@UCS-1 ~]#  yum install tftp-server –y

    [root@UCS-1 mnt]# cp /var/www/html/os/6/isolinux/boot.msg /var/lib/tftpboot/

    [root@UCS-1 mnt]# cp /var/www/html/os/6/images/pxeboot/initrd.img /var/lib/tftpboot/

    [root@UCS-1 mnt]# cp /var/www/html/os/6/images/pxeboot/vmlinuz /var/lib/tftpboot/

    [root@UCS-1 html]# cp /var/www/html/os/6/isolinux/splash.jpg /var/lib/tftpboot/

    [root@UCS-1 html]# cp /var/www/html/os/6/isolinux/vesamenu.c32 /var/lib/tftpboot/

    [root@UCS-1 mnt]# yum -y install syslinux

    [root@UCS-1 mnt]# cp /usr/share/syslinux/pxelinux.0 /var/lib/tftpboot/

    [root@UCS-1 mnt]# mkdir /var/lib/tftpboot/pxelinux.cfg

    [root@UCS-1mnt]#cp /var/www/html/os/6/isolinux/isolinux.cfg /var/lib/tftpboot/pxelinux.cfg/default

    2、  修改tftp配置文件

    [root@UCS-1 mnt]# vi /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(原来yes修改成为no)

            per_source              = 11

            cps                     = 100 2

            flags                   = IPv4

    }

    [root@UCS-1 mnt]# chkconfig xinetd on

    [root@UCS-1 mnt]# chkconfig --level 35 xinetd on

    [root@UCS-1 mnt]# yum -y install dhcp

    [root@UCS-1 mnt]# vi /etc/dhcp/dhcpd.conf

    3、  安装dhcp服务

    [root@UCS-1 mnt]# vi /etc/dhcp/dhcpd.conf

    ddns-update-style interim;

    ignore client-updates;

    allow booting;

    allow bootp;

    subnet 192.168.8.0 netmask 255.255.255.0{

    range 192.168.8.110 192.168.8.120;

    option routers 192.168.8.254;

    option broadcast-address 192.168.8.255;

    default-lease-time 600;

    max-lease-time 7200;

    next-server 192.168.8.254;    

    filename "pxelinux.0";

    } [root@UCS-1 mnt]# /etc/init.d/dhcpd start                                                                                                        

    4、  安装system-config-kickstart.noarch

    [root@UCS-1 mnt]# yum install system-config-kickstart.noarch -y

    5、  进入图形界面执行[root@UCS-1 mnt]# /etc/init.d/dhcpd start

    6、  生成ks.cfg文件

    #platform=x87, AMD64, 或 Intel EM64T

    #version=DEVEL

    # Firewall configuration

    firewall --disabled

    # Install OS instead of upgrade

    install

    # Use network installation

    url --url="http://192.168.8.254/os/6"

    #repo --name="CentOS" --baseurl=cdrom:sr0 --cost=100(注释掉,否则启动从光盘安装)

    # Root password

    rootpw --iscrypted $1$EuW9dIZG$Vclkz/TcHRuoiBqYdPvTD0

    # System authorization information

    auth  --useshadow  --passalgo=sha512

    # Use text mode install

    text

    # System keyboard

    keyboard us

    # System language

    lang zh_CN

    # SELinux configuration

    selinux --disabled

    # Do not configure the X Window System

    skipx

    # Installation logging level

    logging --level=info

    # Reboot after installation

    reboot

    # System timezone

    timezone  Asia/Shanghai

    # Network information

    network  --bootproto=dhcp --device=eth0 --onboot=on

    network  --bootproto=dhcp --device=eth1 --onboot=on

    # System bootloader configuration

    bootloader --append="crashkernel=auto rhgb quiet" --location=mbr --driveorder="sda"

    # Clear the Master Boot Record

    zerombr

    # Partition clearing information

    clearpart --all

    # Disk partitioning information

    part / --fstype="ext4" --grow --size=1

    %packages

    @base

    @basic-desktop

    @chinese-support

    @core

    @debugging

    @desktop-debugging

    @desktop-platform

    @development

    @directory-client

    @fonts

    @general-desktop

    @graphical-admin-tools

    @input-methods

    @internet-applications

    @internet-browser

    @java-platform

    @legacy-x

    @network-file-system-client

    @office-suite

    @print-client

    @remote-desktop-clients

    @server-platform

    @server-policy

    @workstation-policy

    @x11

    abrt-gui

    certmonger

    device-mapper-persistent-data

    genisoimage

    jpackage-utils

    krb5-workstation

    libXmu

    mtools

    • oddjob

    pam_krb5

    pax

    samba-winbind

    sgpio

    systemtap-client

    wodim

    %end

    7、  修改PXE引导文件的ks.cfg,修改如下部分

    [root@UCS-1 html]# vi /var/lib/tftpboot/pxelinux.cfg/default

    timeout 60 # 修改等待时间为6秒

    display boot.msg

    menu background splash.jpg

    menu title Welcome to CentOS 6.5!

    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://192.168.8.254/ks.cfg 指定ks.cfg文件目录

    label vesa

      menu label Install system with ^basic video driver

      kernel vmlinuz

      append initrd=initrd.img xdriver=vesa nomodeset

    label rescue

      menu label ^Rescue installed system

    注意部分:如果是多个网卡的话,还要打开路由功能

  • 相关阅读:
    书写神器——markdown
    数据大作战
    Laraveladmin自定义拓展及常见问题(下)
    Laraveladmin自定义拓展及常见问题(上)
    打造网页版聊天页面的几个知识点
    说说windows系统的事儿
    《软件开发者路线路》读后感
    如何优雅的仿站Step One——扒网站篇
    SQLSERVER 独占锁 独占模式
    解决vs2010调试很慢的方法
  • 原文地址:https://www.cnblogs.com/networking/p/6122119.html
Copyright © 2011-2022 走看看