首页 > 代码库 > pxe linux装机(多系统安装)

pxe linux装机(多系统安装)

PXE 服务器批量布署
1、无人值守自动安装
2、使LVM方式管理磁盘
3、安装后的自动初始化配置
service 176.20.32.208ls


# yum-config-manager --add-repo ftp://176.20.32.208/rhel6 成生一个yum源
# echo ‘gpgcheck=0‘ >> /etc/yum.repos.d/176.20.32.208_rhel6.repo

一、配置DHCP(动态主机配置协议)
dhcp端口号 udp67/68
客户端发送DHCPDiscover广播消息,服务器回应DHCPoffer消息,客户端回应该
DHCPRequest消息,最后服务发送DHCPAck消息确认。

# yum -y install dhcp
# cp /usr/share/doc/dhcp-4.1.1/dhcpd.conf.sample /etc/dhcp/dhcpd.conf
# vim /etc/dhcp/dhcpd.conf //导入模板

subnet 176.20.32.0 netmask 255.255.255.0 { //声明网段
option routers 176.20.32.208; //网关
option domain-name-servers 176.20.32.208; //DNS服务器地址
range 176.20.32.101 176.20.32.200; //分配的地址池范围
default-lease-time 86400; //最小租约时间
max-lease-time 172800; //最大租约时间
next-server 176.20.32.208; //tftp服务器地址
filename "pxelinux.0"; //网卡引导文件名

}

# service dhcpd start //启动DHCP
# vim /var/log/messages //错误日志

# vim /etc/sysconfig/dhcpd
DHCPDARGS=eth0

二、tftp 安装
UDP69

# yum -y install tftp-server
# cd /var/lib/tftpboot/
# mkdir pxelinux.cfg
# cp /var/ftp/rhel6/isolinux/* /var/lib/tftpboot/
把RHEL6光盘isolinux目录下的所有文件拷贝到/var/lib/tftpboot/下
# cp isolinux.cfg pxelinux.cfg/default
# chmod 644 pxelinux.cfg/default

# vim pxelinux.cfg/default 添加一个菜单项

label rhel6.7 //定义名为rhel6.7r 标签
menu label ^Install rhel6.7
menu default
kernel vmlinuz /下载指定的内核并运行
append initrd=initrd.img ks=ftp://176.20.32.208/rhel6/rhel6.cfg repo=ftp://176.20.32.254/rhel6 ks.device=bootif //下载指定初始文件并运行,指定无人值守安装的 cfg文件


# yum -y install syslinux

# rpm -ql syslinux|grep pxelinux

# cp /usr/share/syslinux/pxelinux.0 /var/lib/tftpboot

# chkconfig tftp on
# service xinetd start; chkconfig xinetd on
# nestat -ulnp |grep :69

三、配置kickstart
# yum -y install vsftpd
# yum install -y system-config-kickstart
# system-config-kickstart //生成一个自动安装脚本保存到/var/ftp/rhel6/rhel6.cfg

# vim /etc/ftp/rhel6/rhel6.cfg
vim /var/ftp/rhel6/rhel6.cfg
echo 123456 |passwd --stdin bob
useradd -u 800 bob
echo 123456 |passwd --stdin bob
cat <<EOF> /etc/yum.repos.d/server.repo
[Server]
name=server
baseurl=ftp://176.20.32.208/rhel6
enabled=1
gpgcheck=0
EOF
rpm -rf
rpm -rf /etc/yum.repos.d/CentOS*
yum -y install vsftp
yum -y install ftp
yum -y install dhcp
%end

 


%packages
@base
@chinese-support
@performance
"/var/ftp/rhel6/rhel6.cfg" 65L, 1301C 已写入
[root@176-20-32-208-dynamic ~]# vim /var/ftp/rhel6/rhel6.cfg
%post
useradd -u 800 bob
echo 123456 |passwd --stdin bob
cat <<EOF> /etc/yum.repos.d/server.repo
[Server]
name=server
baseurl=ftp://176.20.32.208/rhel6
enabled=1
gpgcheck=0
EOF
rpm -rf
rpm -rf /etc/yum.repos.d/CentOS*
yum -y install vsftp
yum -y install ftp
yum -y install dhcp
%end

 


%packages
@base
@chinese-support
"/var/ftp/rhel6/rhel6.cfg" 65L, 1301C 50,1 90%
reboot
# System timezone
timezone Africa/Abidjan
# System bootloader configuration
bootloader --location=mbr
# Clear the Master Boot Record
zerombr
# Partition clearing information
clearpart --all --initlabel
# Disk partitioning information
part / --fstype="ext4" --size=10000
part /boot --fstype="ext4" --size=200
part swap --fstype="swap" --size=1024

%post
useradd -u 800 bob
echo 123456 |passwd --stdin bob
cat <<EOF> /etc/yum.repos.d/server.repo
[Server]
name=server
baseurl=ftp://176.20.32.208/rhel6
enabled=1
gpgcheck=0
EOF
rpm -rf
rpm -rf /etc/yum.repos.d/CentOS*
yum -y install vsftp-server
yum -y install ftp
yum -y install dhcp
%end

 


%packages
@base
@chinese-support
@performance
@storage-client-multipath

%end

五、提供rhel7系统安装
# cd /var/lib/tftpboot/
# mkdir rhel7
将RHEL7光盘目录中相关的文拷贝到tftp服务器
# cp /var/ftp/rhel7/images/pxeboot/* /var/lib/tftpboot/rhel7
# vim pxelinux.cfg/default


lable rhel7.0
menu lable Install ^Rhel7
kernel rhel7/vmlinuz
append initrd=rhel7/initrd.img ks=ftp://176.20.32.208/rhel7/rhel7.cfg repo=ftp://176.20.32.208/rhel7 ks.device=bootif

注意:rhel7的ks文件需要在rhel7系统上生成,生成后放到176.20.32.208的FTP服务器目录下的rhel7,名为rhel7.cfg

 

 

# service vsftpd start; chkconfig vsftpd on

四、测试
创建一台虚拟机,连接到private1网上

 

pxe linux装机(多系统安装)