NFS+TFTP+DHCPD+PXE自动化运维(多系统)

# NFS+TFTP+DHCPD+PXE自动化运维(多系统)
NFS+TFTP+DHCPD+PXE自动化运维(多系统)
1.配置前准备

[root@node1 ~]# /etc/init.d/iptables stop
[root@node1 ~]#setenforce 0

2.dhcpd服务配置

[root@node1 ~]#yum install dhcp-y
[root@node1 ~]# vim /etc/dhcp/dhcpd.conf
#
# DHCP Server Configuration file.
#   see /usr/share/doc/dhcp*/dhcpd.conf.sample
#   see 'man 5 dhcpd.conf'
#

ddns-update-style interim;
ignore client-updates;
next-server 192.168.110.16;  # dhcpd服务器IP
filename "pxelinux.0";
option domain-name-servers 8.8.8.8;
option routers 192.168.110.254;
option subnet-mask 255.255.255.0;
allow booting;
allow bootp;

subnet 192.168.110.0 netmask 255.255.255.0 {
range dynamic-bootp 192.168.110.18 192.168.110.50;  #客户端ip分配范围
}

[root@node1 ~]#/etc/init.d/dhcpd start

3. tftp服务配置
3.1 tftp服务配

[root@node1 ~]#yum install tftp-server –y
[root@node1 ~]#vim /etc/xinetd.d/tftp
        server_args             = -s /tftpboot  #默认目录为/var/lib/tftpboot
        disable                 = no  #默认为yes,修改为no

3.2 tftp目录配置

[root@node1 ~]# yum install syslinux -y
[root@node1 ~]#mkdir /tftpboot/{centos6.4,centos6.5,pxelinux.cfg} -pv
[root@node1 ~]#cp /usr/share/syslinux/pxelinux.0 /tftpboot
[root@node1 ~]#cp /centosinstall/centos6.5/isolinux/ vesamenu.c32 /tftpboot
[root@node1 ~]#cp /centosinstall/centos6.5/isolinux/boot.msg /tftpboot
[root@node1 ~]# cp /centosinstall/centos6.5/images/vmlinuz /tftpboot/centos6.5
[root@node1 ~]#cp /centosinstall/centos6.5/images/initrd.img /tftpboot/centos6.5
[root@node1 ~]#cp /centosinstall/centos6.4/images/vmlinuz /tftpboot/centos6.4
[root@node1 ~]#cp /centosinstall/centos6.4/images/initrd.img /tftpboot/centos6.4
[root@node1 ~]#cp /centosinstall/centos6.5/isolinux/isolinux.cfg /tfpboot/pxelinux.cfg/default

3.3 修改/tftpboot/pxelinux.cfg/default文件,添加如下内容即可

[root@node1 ~]#vim /tftpboot/pxelinux.cfg/default
default vesamenu.c32  
label centos64
  menu label ^Install Centos6.4 system
  menu default
  kernel centos64/vmlinuz  #默认会在tftp服务目录下查找,当多系统时,需指定路径
  append ks=nfs:192.168.110.16:/centosnfs/centos64/ks64.cfg  initrd=centos64/initrd.img
label centos65
  menu label ^Install Centos6.5 system
  menu default
  kernel centos65/vmlinuz
  append ks=nfs:192.168.110.16:/centosnfs/centos65/ks65.cfg initrd=centos65/initrd.img

3.4 启动tftp服务

[root@node1 ~]#/etc/init.d/xinetd start

4. nfs服务配置
4.1 nfs服务配置

[root@node1 ~]#yum install nfs-utils –y
[root@node1 ~]# echo “/centosinstall/centos6.4 *(rw,sync)” /etc/exports
[root@node1 ~]#echo “/centosinstall/centos6.5 *(rw,sync)” /etc/exports
[root@node1 ~]# /etc/init.d/rpcbind start
[root@node1 ~]# /etc/init.d/nfs start

4.2 nfs共享文件配置(挂载光盘,复制iso镜像到共享目录)

[root@node1 ~]# mkdir /mnt/{centos6.4,centos6.5}
[root@node1 ~]#mount /dev/cdrom /mnt/centos6.4
[root@node1 ~]#cp –a /mnt/centos6.4 /centosinstall/centos6.4
[root@node1 ~]#cp /root/ks64.cfg /centosinstall/centos6.4
[root@node1 ~]#mount /dev/cdrom /mnt/centos6.5
[root@node1 ~]#cp –a /mnt/centos6.5 /centosinstall/centos6.5
[root@node1 ~]#cp /root/ks65.cfg  /centosinstall/centos6.5

4.3 启动nfs服务

[root@node1 ~]#/etc/init.d/rpcbind start
[root@node1 ~]#/etc/init.d/nfs start

5. 制作ks.cfg文件
ks.cfg文件可以自己编写,也可以使用软件system-config-kickstart生成。

firewall --disabled
install
nfs --server=192.168.110.16 --dir=/centosnfs/centos65
rootpw --iscrypted $1$2h9mMmFM$.rT/T4yqo/zj63mtkuueo/
auth  --useshadow  --passalgo=sha512
text
firstboot --disable
keyboard us
lang en_US
selinux --disabled
logging --level=info
reboot
timezone  Asia/Shanghai
network  --bootproto=dhcp --device=eth0 --onboot=on --noipv6  --nameserver=192.168.200.254
bootloader --location=mbr
zerombr
clearpart --all --initlabel 
part / --fstype="ext4" --grow --size=1

%packages 
@core
@base
wget

%end

6. 客户机进行测试
7. 要想全自动化,可以设置默认安装系统,只需要将第3步中的C步骤中

default vesamenu.c32  修改为 default centos6.4  (表示默认安装centos6.4) 

转载于:https://blog.51cto.com/pizining/2058545

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值