pxe批量部署linux服务器



一、pxe介绍

PXE是 有intel设计的协议,它可以使计算机通过网络启动,协议分为client和server两端,PXEclient在网卡的ROM中,当计算机引导 时,BIOS把PXE client调入内存中执行,并显示出命令菜单,经用户选择PXE启动后,PXE client获取网络地址信息,然后将放置在远端的服务器上的操作系统文件通过网络下载到本地运行

    既然是通过网络传输,就需要IP地址,也就是说在PXE启动过程中,PXE客户端会请求DHCP服务器分配IP地址,之后PXEclient使用TFTP client通过TFTP协议连接服务器下载启动安装程序所需要的文件到本地

二、yum install tftp  tftp-server syslinux dhcp -y  
       yum install system-config-kick start.noarch  #安装需要的软件 

三、配置dhcp服务
vim /etc/dhcp/dhcpd.conf
ddns-update-style interim;
ignore client-updates;
  subnet 192.168.1.0 netmask 255.255.255.0 {
    option routers  192.168.1.1;
    option subnet-mask 255.255.255.0;
    option domain-name-servers 192.168.1.1;
    option time-offset  -18000;
    range dynamic-bootp 192.168.1.100 192.168.1.120;
    default-lease-time 21600;
    max-lease-time 43200;
    next-server 192.168.1.27;
    filename "pxelinux.0";
}

四、配置tftp服务 
v im /etc/xinetd.d/tftp
service tftp
{
        socket_type             = dgram
        protocol                = udp
        wait                    = yes
        user                    = root
        server                  = /usr/sbin/in.tftpd
        server_args             = -s /tftpboot  #改了路径随自己方便
        disable                 = no     #开启tftp服务,默认为yes
        per_source              = 11
        cps                     = 100 2
        flags                   = IPv4
}
mkdir  /tftpboot
vim /tftpboot/boot.msg
__      ____      ____ _ _ __   __ _ _ __ (_)_ __   __ _
\ \ /\ / /\ \ /\ / / _` | '_ \ / _` | '_ \| | '_ \ / _` |
 \ V  V /  \ V  V / (_| | | | | (_| | | | | | | | | (_| |
  \_/\_/    \_/\_/ \__,_|_| |_|\__, |_| |_|_|_| |_|\__, |
__      ____ _ _ __   __ _ _ __ (_)_ __   __ _
\ \ /\ / / _` | '_ \ / _` | '_ \| | '_ \ / _` |
 \ V  V / (_| | | | | (_| | | | | | | | | (_| |
  \_/\_/ \__,_|_| |_|\__, |_| |_|_|_| |_|\__, |
INSTALLATION MENU
Choose installation type:
0 Local Boot (default)
1 RHEL6.1 Base System
2 RHEL6.1 Workstation

五、拷贝所需文件

cp /usr/share/syslinux/pxelinux.0 /tftpboot/ #TFTP服务器为客户端主要提供pxelinux.0引导文件
cd /media/CentOS_6.6_Final/ images/ pxeboot/ 
cp initrd.img  vmlinuz /tftpboot/    #vmlinuz内核文件,initrd.img基础安装平台
chcon -R -t tftpdir_t /tftpboot/       #修改上下文
mkdir /tftpboot/pxelinux.cfg   
vim /tftpboot/pxelinux.cfg/default  
default 0   #default项中标记的启动内核为默认启动项
prompt 1   #显示boot:提示符。为0时则不提示,将会直接启动default参数中指定的内容。
为1时会等待输入label后关键字,从而启动相应内核
timeout 3000  #等待超时时间
display boot.msg 
label 0
localboot 0
label 1
 kernel vmlinuz
 append initrd=initrd.img noipv6 ks=ftp://192.168.1.25/ks.cfg

label 2
kernel vmlinuz
append initrd=initrd.img noipv6 ks=ftp://192.168.10.2/ks.cfg


六、配置Kickstart,用于自动应答安装
cd /var/ftp/
system-config-kickstart   #生成ks.cfg文件
cp /root/桌面  ks.cfg   /var/ftp/
vim /var/ftp/ks.cfg
#platform=x86, AMD64, 或 Intel EM64T
#version=DEVEL
# Firewall configuration
firewall --disabled
# Install OS instead of upgrade
install   #表示全新安装,而不是升级update
# Use network installation
url --url="ftp://192.168.1.25/mmd"  #OS文件所在的位置
# Root password
rootpw --iscrypted $1$Bhae8ZM.$VrifntqxujukFsdWEJ/Ux0
# System authorization information
auth  --useshadow  --passalgo=sha512
# Use text mode install
text
firstboot --disable
# System keyboard
keyboard us
# System language
lang zh_CN
# SELinux configuration
selinux --enforcing
# Installation logging level
logging --level=info
# Reboot after installation
reboot
# System timezone
timezone  Africa/Abidjan
# Network information
network  --bootproto=dhcp --device=eth0 --onboot=on
# System bootloader configuration
bootloader --location=mbr
# Clear the Master Boot Record
zerombr
# Partition clearing information
clearpart --all --initlabel 
# Disk partitioning information
part /boot --fstype="ext4" --size=200
part pv.01 --size=10000
volgroup vg_root pv.01
logvol / --vgname=vg_root --size=2000 --grow --name=lv_root
part pv.02 --size=2048
volgroup vg_swap pv.02
logvol swap --vgname=vg_swap --size=1 --grow --name=lv_swap
part pv.03 --size=2048
volgroup vg_home pv.03
logvol /home --vgname=vg_home --size=1024 --name=lv_home


%packages
@base
@chinese-support
@development
@dial-up
@emacs
@fonts
@hardware-monitoring
@input-methods
@internet-browser
@legacy-x

@network-tools
@scalable-file-systems
git
-ibus-table-cangjie
-ibus-table-erbi
-ibus-table-wubi
mkdir /var/ftp/mmd
cp -R  /media/CentOS_6.6_Final/*   /var/ftp/centos6/
service vsftpd restart
service xinetd restart
service  dhcpd  restart








一、pxe介绍

PXE是 有intel设计的协议,它可以使计算机通过网络启动,协议分为client和server两端,PXEclient在网卡的ROM中,当计算机引导 时,BIOS把PXE client调入内存中执行,并显示出命令菜单,经用户选择PXE启动后,PXE client获取网络地址信息,然后将放置在远端的服务器上的操作系统文件通过网络下载到本地运行

    既然是通过网络传输,就需要IP地址,也就是说在PXE启动过程中,PXE客户端会请求DHCP服务器分配IP地址,之后PXEclient使用TFTP client通过TFTP协议连接服务器下载启动安装程序所需要的文件到本地

二、yum install tftp  tftp-server syslinux dhcp -y  
       yum install system-config-kick start.noarch  #安装需要的软件 

三、配置dhcp服务
vim /etc/dhcp/dhcpd.conf
ddns-update-style interim;
ignore client-updates;
  subnet 192.168.1.0 netmask 255.255.255.0 {
    option routers  192.168.1.1;
    option subnet-mask 255.255.255.0;
    option domain-name-servers 192.168.1.1;
    option time-offset  -18000;
    range dynamic-bootp 192.168.1.100 192.168.1.120;
    default-lease-time 21600;
    max-lease-time 43200;
    next-server 192.168.1.27;
    filename "pxelinux.0";
}

四、配置tftp服务 
v im /etc/xinetd.d/tftp
service tftp
{
        socket_type             = dgram
        protocol                = udp
        wait                    = yes
        user                    = root
        server                  = /usr/sbin/in.tftpd
        server_args             = -s /tftpboot  #改了路径随自己方便
        disable                 = no     #开启tftp服务,默认为yes
        per_source              = 11
        cps                     = 100 2
        flags                   = IPv4
}
mkdir  /tftpboot
vim /tftpboot/boot.msg
__      ____      ____ _ _ __   __ _ _ __ (_)_ __   __ _
\ \ /\ / /\ \ /\ / / _` | '_ \ / _` | '_ \| | '_ \ / _` |
 \ V  V /  \ V  V / (_| | | | | (_| | | | | | | | | (_| |
  \_/\_/    \_/\_/ \__,_|_| |_|\__, |_| |_|_|_| |_|\__, |
__      ____ _ _ __   __ _ _ __ (_)_ __   __ _
\ \ /\ / / _` | '_ \ / _` | '_ \| | '_ \ / _` |
 \ V  V / (_| | | | | (_| | | | | | | | | (_| |
  \_/\_/ \__,_|_| |_|\__, |_| |_|_|_| |_|\__, |
INSTALLATION MENU
Choose installation type:
0 Local Boot (default)
1 RHEL6.1 Base System
2 RHEL6.1 Workstation

五、拷贝所需文件

cp /usr/share/syslinux/pxelinux.0 /tftpboot/ #TFTP服务器为客户端主要提供pxelinux.0引导文件
cd /media/CentOS_6.6_Final/ images/ pxeboot/ 
cp initrd.img  vmlinuz /tftpboot/    #vmlinuz内核文件,initrd.img基础安装平台
chcon -R -t tftpdir_t /tftpboot/       #修改上下文
mkdir /tftpboot/pxelinux.cfg   
vim /tftpboot/pxelinux.cfg/default  
default 0   #default项中标记的启动内核为默认启动项
prompt 1   #显示boot:提示符。为0时则不提示,将会直接启动default参数中指定的内容。
为1时会等待输入label后关键字,从而启动相应内核
timeout 3000  #等待超时时间
display boot.msg 
label 0
localboot 0
label 1
 kernel vmlinuz
 append initrd=initrd.img noipv6 ks=ftp://192.168.1.25/ks.cfg

label 2
kernel vmlinuz
append initrd=initrd.img noipv6 ks=ftp://192.168.10.2/ks.cfg


六、配置Kickstart,用于自动应答安装
cd /var/ftp/
system-config-kickstart   #生成ks.cfg文件
cp /root/桌面  ks.cfg   /var/ftp/
vim /var/ftp/ks.cfg
#platform=x86, AMD64, 或 Intel EM64T
#version=DEVEL
# Firewall configuration
firewall --disabled
# Install OS instead of upgrade
install   #表示全新安装,而不是升级update
# Use network installation
url --url="ftp://192.168.1.25/mmd"  #OS文件所在的位置
# Root password
rootpw --iscrypted $1$Bhae8ZM.$VrifntqxujukFsdWEJ/Ux0
# System authorization information
auth  --useshadow  --passalgo=sha512
# Use text mode install
text
firstboot --disable
# System keyboard
keyboard us
# System language
lang zh_CN
# SELinux configuration
selinux --enforcing
# Installation logging level
logging --level=info
# Reboot after installation
reboot
# System timezone
timezone  Africa/Abidjan
# Network information
network  --bootproto=dhcp --device=eth0 --onboot=on
# System bootloader configuration
bootloader --location=mbr
# Clear the Master Boot Record
zerombr
# Partition clearing information
clearpart --all --initlabel 
# Disk partitioning information
part /boot --fstype="ext4" --size=200
part pv.01 --size=10000
volgroup vg_root pv.01
logvol / --vgname=vg_root --size=2000 --grow --name=lv_root
part pv.02 --size=2048
volgroup vg_swap pv.02
logvol swap --vgname=vg_swap --size=1 --grow --name=lv_swap
part pv.03 --size=2048
volgroup vg_home pv.03
logvol /home --vgname=vg_home --size=1024 --name=lv_home


%packages
@base
@chinese-support
@development
@dial-up
@emacs
@fonts
@hardware-monitoring
@input-methods
@internet-browser
@legacy-x

@network-tools
@scalable-file-systems
git
-ibus-table-cangjie
-ibus-table-erbi
-ibus-table-wubi
mkdir /var/ftp/mmd
cp -R  /media/CentOS_6.6_Final/*   /var/ftp/centos6/
service vsftpd restart
service xinetd restart
service  dhcpd  restart








  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值