-
安装所需要的软件:
# yum -y install dhcp* nfs* tftp* system-config-netboot*
- 配置tftp:
# vi /etc/xinetd.d/tftp
service tftp
{
disable = no #默认是yes,改为no
socket_type = dgram
protocol = udp
wait = yes
user = root
server = /usr/sbin/in.tftpd
server_args = -s /tftpboot #-s 表示用/tftpboot作为tftp目录的根目录
per_source = 11
cps = 100 2
flags = IPv4
}
重启xinetd服务:
# service xinetd restart
查看tftp是否启动;如显示tftp: on即OK了。
# chkconfig --list tftp
- 配置NFS服务:
建立diskless客户端存储的公共目录:
# mkdir -p /opt/diskless/root
配置NFS共享:
# vi /etc/exports
/opt/diskless/root/ *(ro,sync,no_root_squash)
/opt/diskless/snapshot/ *(rw,sync,no_root_squash)
重启NFS:
# exportfs -ra
配置NFS服务自启动:
# chkconfig nfs on
- 配置DHCP(这里使用eth0对内,其IP为10.0.0.1,我们做实验只开放了node41做dhcp)
# vi /etc/sysconfig/dhcpd
DHCPDARGS=eth0
注意等号后面千万不要有空格!
# vi /etc/dhcpd.conf
ddns-update-style none;
subnet 10.0.0.0 netmask 255.255.255.0 {
option routers 10.0.0.1; #router的ip地址
option subnet-mask 255.255.255.0; #subnet-mask地址
option domain-name "qibebt.ac.cn"; #域名根据你自己的情况定
option domain-name-servers 10.0.0.1; #域名服务器也就是DNS服务器地址
default-lease-time 21600;
max-lease-time 43200;
range dynamic-bootp 10.0.0.2 10.0.0.66;
filename "linux-install/pxelinux.0";
next-server 10.0.0.1;
host node41 {
hardware ethernet 00:E0:81:B1:2B:2C; #绑定MAC地址
fixed-address 10.0.0.41;
}
}
option space PXE;
class "pxeclients" {
match if substring(option vendor-class-identifier, 0, 9) = "PXEClient";
next-server 10.0.0.1;
}
重启DHCP服务:
# service dhcpd restart
- ssh到某个现有的客户节点(如ClientName节点)后安装客户节点所需要的busybox-anaconda,或利用现有的系统和chroot进行精简:
# yum install busybox-anaconda
将安装的系统copy(注意保持权限,不包括/proc、/sys、/tmp、/home、/opt目录)到diskless目录下,下面的ClientName表示现有的客户节点的名字:
# rsync -va -e ssh --exclude='/proc/*' --exclude='/sys/*'--exclude='/tmp/*' --exclude='/home/*' --exclude='/opt/*' ClientName:/ /opt/diskless/root/
# mkdir /opt/diskless/root/{home,opt}
- 客户端内核必须支持NFS-ROOT,按顺序打开:
- Networking->Networking options下的IP: kernel level autoconfiguration和IP: DHCP support
- File systems->Network File Systems-><*> NFS file system support(注意这里必须选择成*,否则看不到下面的[*] Root file system on NFS)和[*] Root file system on NFS
采用CentOS提供的内核源码编译时,如果出现__fscache_acquire_cookie之类的函数找不到等时,请手动编辑.config,将CONFIG_FSCACHE=m变为CONFIG_FSCACHE=y
- 生成单个客户端所需的配置:
# system-config-netboot
# vi /opt/diskless/root/etc/sysconfig/network-scripts/ifcfg-eth0
HWADDR=
DHCPDHCP_HOSTNAME=
或者用命令行方式(具体含义,请man pxeboot):
# pxeboot -a -S node41 -N admin.qibebt.ac.cn -O scc_dawning 10.0.0.41
- 文件系统挂载:
在客户端启动后将挂载/opt/diskless/snapshot/files定义的那些目录或者文件,如果不希望挂载,可以注释掉,例如我们注释掉了/home和/etc/fstab。
另外也可修改/opt/diskless/root/etc/fstab添加本地硬盘支持,如我们的为:
# /etc/fstab for diskless clients, written by system-config-netboot
none /dev/pts devpts gid=5,mode=620 0 0
none /dev/shm tmpfs defaults 0 0
#none /tmp tmpfs defaults 0 0
#/dev/cdrom /media/cdrom iso9660 noauto,owner,kudzu,ro 0 0
#/dev/fd0 /media/floppy auto noauto,owner,kudzu 0 0
LABEL=/tmp /tmp ext3 defaults 1 2
LABEL=SWAP-sda6 swap swap defaults 0 0