歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux基礎 >> 關於Linux >> 使用tftp、dhcp、nfs,網絡PEX批量部署linux

使用tftp、dhcp、nfs,網絡PEX批量部署linux

日期:2017/3/3 16:34:52   编辑:關於Linux
[root@www ~]# yum install tftp-server -y 安裝tftp服務 安裝完啟動

[root@www mnt]# vi /etc/xinetd.d/tftp 修改tfpt配置
service tftp
{
disable = no
socket_type = dgram
protocol = udp
wait = yes
user = root
server = /usr/sbin/in.tftpd
server_args = -u nobody -s /tftpboot
per_source = 11
cps = 100 2
flags = IPv4
}
[root@www ~]# netstat -tunlp |grep 69 確保69端口打開狀態
[root@www ~]# yum install dhcp -y 安裝dhcp服務(安裝過程出錯,卸載dhclient安裝成功)
[root@www ~]# vi /etc/dhcp/dhcpd.conf 修改dhcp配置文件
option domain-name "cnnb.com";
option domain-name-server 220.189.220.67;
filename "pxelinux.0";
net-server 192.168.0.241;
default-lease-time 600;
max-lease-time 7200;
subnet 192.168.0.0 netmask 255.255.255.0{
range 192.168.0.242 192.168.0.243;
option broadcast-address 192.168.0.0;
}
[root@www mnt]# mkdir -p /tftpboot 創建dhcp服務指定目錄
[root@www tftpboot]# cd /tftpboot/ 進入目錄
[root@localhost tftpboot]# yum install syslinux -y
[root@www tftpboot]# cp /usr/share/syslinux/pxelinux.0 ./ 復制pxelinux.0配置文件到/tftpboot
[root@www tftpboot]# mount -t iso9660 /dev/cdrom /mnt/cdrom/ 掛載centos系統鏡像
[root@localhost tftpboot]# cp /mnt/cdrom/isolinux/vmlinuz ./
[root@localhost tftpboot]# cp /mnt/cdrom/isolinux/initrd.img ./
[root@www tftpboot]# mkdir -p pxelinux.cfg 創建PXE服務的配置文件夾
[root@www tftpboot]# cp /mnt/cdrom/isolinux//isolinux.cfg pxelinux.cfg/default 復制ISO鏡像中的isolinux.cfg 並重命名為default
[root@www tftpboot]# vi pxelinux.cfg/default 配置默認的配置
default linux
#prompt 1
timeout 10
display boot.msg
menu background splash.jpg
menu title Welcome to CentOS 6.0!
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
display boot.msg
F1 boot.msg
F2 options.msg
F3 general.msg
F4 param.msg
F5 rescue.msg
label linux
kernel vmlinuz
append ks=nfs:192.168.0.241:/centosinstall/ks.cfg ksdevice=eth0 initrd=initrd.img
label linux
menu label ^Install or upgrade an existing system
menu default
kernel vmlinuz
append initrd=initrd.img
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
kernel vmlinuz
append initrd=initrd.img rescue
label local
menu label Boot from ^local drive
localboot 0xffff

配置好後重啟tftp

[root@www tftpboot]# mkdir -p /centosinstall 創建NFS的ISO鏡像目錄

[root@www tftpboot]# cp -rf /mnt/cdrom/* /centosinstall/ 復制鏡像中的文件到/centosinstall/

[root@www mnt]# vi /etc/exports 設置共享

/centosinstall *(rw,sync)

[root@www mnt]# cd /centosinstall/ 進入/centosinstall/文件夾

[root@www centosinstall]# vi ks.cfg 創建ks.cfg配置文件

#ckstart file automatically generated by anaconda.

install

text

nfs --server=192.168.0.241 --dir=/centosinstall

key --skip

lang en_US.UTF-8

keyboard us

network --device eth0 --bootproto=dhcp --noipv6

rootpw 87688768

firewall --disabled

authconfig --enableshadow --enablemd5

selinux --disabled

timezone Asia/Shanghai

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

# The following is the partition information you requested

# Note that any partitions you deleted are not expressed

# here so unless you clear all partitions first, this is

# not guaranteed to work

clearpart --all --initlabel

part /boot --fstype ext4 --size=100

part swap --size=8196

part / --fstype ext4 --size=100 --grow

[root@www centosinstall]# chmod 777 ks.cfg 將ks.cfg文件權限設置為777

service    xinetd  restart  &&  service nfs restart  && service  dhcpd restart 重啟所有相關服務

本文出自 “lustlost-迷失在欲望之中” 博客,請務必保留此出處http://lustlost.blog.51cto.com/2600869/844226

Copyright © Linux教程網 All Rights Reserved