[基礎]RHEL6下LINUX服務器批量部署
包准備:xinetd,tftp-server,dhcp,httpd,system-config-kickstart,syslinux,nfs
試驗環境:
本機地址:192.168.46.98
本地網關:192.168.46.254
配置DHCP服務器:
Sample:
subnet 192.168.46.0 netmask 255.255.255.0 {
range 192.168.46.100 192.168.46.105;
option routers 192.168.46.254;
default-lease-time 600;
max-lease-time 7200;
next-server 192.168.46.98; /*指向tftp服務器*/
filename="pxelinux.0"; } /*ftp根目錄的相對路徑*/
參考文件:
ddns-update-style interim; /*dhcp支持的dns動態更新方式*/
ignore client-updates; /*忽略客戶端DNS動態更新*/
authoritative; /*授權*/
allow booting; /*支持PXE啟動*/
allow bootp; /*支持boottp*/
subnet 192.168.129.0 netmask 255.255.255.0 { /*作用域*/
range 192.168.129.30 192.168.129.78; /*ip地址段范圍*/
option routers 192.168.129.1; /*網關*/
option subnet-mask 255.255.255.0; /*子網掩碼*/
option domain-name-servers 203.103.24.68; /*DNS服務器的地址*/
default-lease-time 21600; /*租期,秒數*/
max-lease-time 43200; /*最大租期,秒數*/
next-server 192.168.129.22; /*TFTPServer的IP*/
filename "/pxelinux.0"; /*Bootstrap文件*/
掛載系統光盤到 /mnt
配置TFTP根目錄(tftpboot)
# cp /mnt/images/pxeboot/vmlinuz /mnt/images/pxeboot/initrd.img /var/lib/tftpboot
# cp /mnt/isolinux/boot.msg /mnt/isolinux/splash.jpg /var/lib/tftpboot
# cp /usr/share/syslinux/pxelinux.0 /var/lib/tftpboot/
# mkdir /var/lib/tftpboot/pxelinux.cfg
# cp -p /media/cdrom/isolinux/isolinux.cfg /var/lib/tftpboot/pxelinux.cfg/default
TFTP下default配置
# vi /var/lib/tftpboot/pxelinux.cfg/default
default linux
#prompt 1
timeout 600
display boot.msg
menu background splash.jpg
menu title Welcome to Red Hat Enterprise Linux 6.4!
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 local
localboot 0
label linux
kernel vmlinuz
append initrd=initrd.img devfs=nomount ks=http://192.168.46.98/ks.cfg
NFS共享目錄配置
# vi /etc/exports
/mnt 192.168.46.0/255.255.255.0(ro,sync)
配置Kickstart文件ks.cfg
# cd /var/www/html
# vi ks.cfg
#platform=x86, AMD64, or Intel EM64T
#version=DEVEL
# Firewall configuration
firewall --enabled --ssh
# Install OS instead of upgrade
install
# Use NFS installation media
nfs --server=192.168.46.98 --dir=/mnt
# Root password
#rootpw --iscrypted $1$kC9vxUwe$l.U7ZGNt9Yjcvt2YHy3J50
# System authorization information
auth --useshadow --passalgo=sha512
# Use text mode install
text
# System keyboard
keyboard us
# System language
lang en_US
# 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 --isUtc Asia/Shanghai
# 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 --asprimary --fstype="ext4" --size=128
part swap --asprimary --fstype="swap" --size=2048
part / --asprimary --fstype="ext4" --size=8000
part /data --asprimary --fstype="ext4" --size=1
%packages
@base
@chinese-support
%end
開啟服務
tftp包含於xinetd中,所以要進入配置文件中開啟
# 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
per_source = 11
cps = 100 2
flags = IPv4
}
開啟
# service dhcpd start
# service xinetd start
# service httpd start
# service nfs start