快捷搜索:   nginx

Ubuntu无盘工作站安装详细步骤

首先,请注意本文所述的“无盘工作站”与“无盘终端”的异同:
相同之处是二者的客户端都没有磁盘。
相异之处是,“无盘终端”完全使用端的资源(CPU和磁盘),与直接登录在控制台差别不大,所以适用于客户端是极其老旧的机器,因为,即使用 较新的机器则其运算能力同样无法发挥、从而造成资源浪费。
而“无盘工作站”的客户端在登录阶段,将服务器端作为登录服务器(tftp和dhcp),在登录完成后,则主要是把服务器端作为nfs服务器提供磁盘空 间,此磁盘空间映射为客户机端的根目录,随后所有的运算工作在客户机端完成、并不占用服务器的CPU资源。所以,“无盘工作站”较适合当今性能中等以上的 客户端使用,以平衡服务器、客户机的负载。
从实现的方式来说,Ubuntu自带的ltsp服务属于“无盘终端”,虽然设置简易,但并不适合我们遇到的大多数情况:如今谁还会用一堆256M的586 机器去组网呢?有鉴于此,Ubuntu社区曾经试图调和两者,提出了“胖客户机”的概念,是从基本的ltsp延伸出来,详情请见
但是说老实话,上述基于ltsp的“无盘工作站”是毫无必要地自找麻烦,比如说里面用到了openLDAP,还要修改一堆脚本,实际操作的难度可想而知, 所以:

【注意】
本文并不讨论ltsp“无盘终端”或“ltsp胖客户机”,而是基于Linux系统固有的能力,建构一个可以适用于所有Linux发行版的“无盘工作站” 方法,而Ubuntu只是作为一个实例使用。

【成功结果展示】
在进入正文之前,可以先到:

这一名为“Ubuntu高地”的博客看一下无盘工作站安装成功后的类似效果。本文的由来,就是参考了此一重要文献,但因为作者是位高手,所以文中省略了很 多他认为是天经地义的,这就造成了象作者这样的初学者的困难。好在该文的下面链接了另一篇文章: 是名为“天使之翼”的另一高手的安装记录,本文的大部分将转载自该安装记录。
但是“天使之翼”的文章也有一个小问题,就是其中的客户端使用了一台有磁盘的机器作为初始安装,然后再将已经生成在磁盘上的所有文件打包拷贝到服务器端的 nfs空间(也即实际运行时的客户端远程虚拟根目录)里。这样做当然有简便、稳妥的好处,但是如果拟安装的客户端从一开始就没有磁盘呢?文中并没有提供后 一种情况的替代办法。
而本文在包含了“天使之翼”的“有盘安装”的内容的同时,另外补充了彻底无盘安装客户端系统的方法(也就是Ubuntu高地一文中已实现但没有披露的部 分)。所以:

【正文前提示】
从现在开始,请不要再去回顾上述的三个链接,以免混乱。本文已经包含了上述的所有有效内容。


【正文第一部分】服务器端(机器名为ubuntu)准备


首先,本文中的服务器端名为ubuntu(IP是192.168.1.88),而客户机端名为netfs,和“天使之翼”文中的命名方法相同,以方便拷贝 相关命令和内容。以下显示为root@ubuntu的即指在服务器端操作,而显示为root@netfs的即指在客户机端操作。

【正文第一部分-1】服务器端三大服务

服务器端需准备tftp、dhcp、nfs这三个服务,其过程如下:
(以下全部来自“天使之翼”原文,仅加了必要的注解)

第一步 安装tftp服务器

1 安装
root@ubuntu:/# apt-get install tftpd-hpa
正在读取软件包列表... 完成
正在分析软件包的依赖关系树
Reading state information... 完成
下列新软件包将被安装:
tftpd-hpa
共升级了 0 个软件包,新安装了 1 个软件包,要卸载 0 个软件包,有 0 个软件未被升级。
需要下载 34.0kB 的软件包。
解压缩后会消耗掉 152kB 的额外空间。
获取:1 http://Ubuntu.cn99.com hardy/main tftpd-hpa 0.43-1.1ubuntu1 [34.0kB]
下载 34.0kB,耗时 5s (5921B/s)
正在预设定软件包 ...
选中了曾被取消选择的软件包 tftpd-hpa。
(正在读取数据库 ... 系统当前总共安装有 112536 个文件和目录。)
正在解压缩 tftpd-hpa (从 .../tftpd-hpa_0.43-1.1ubuntu1_i386.deb) ...
正在设置 tftpd-hpa (0.43-1.1ubuntu1) ...

root@ubuntu:/#

2 设置tftpd
root@ubuntu:~# nano /etc/default/tftpd-hpa
#Defaults for tftpd-hpa
RUN_DAEMON="yes"

#上面这句表示启动守护进程,tftpd工作
OPTIONS="-l -s /var/lib/tftpboot"
#上面这句表示tftp客户端能取得的文件所存放的位置

3 启动服务
root@ubuntu:/# /etc/init.d/tftpd-hpa start
Starting HPA's tftpd: in.tftpd.
root@ubuntu:/# ps aux|grep tftp
root 26853 0.0 0.1 2196 288 ? Ss 17:26 0:00 /usr/sbin/in.tftpd -l -s /var/lib/tftpboot
root 26862 0.0 0.2 3180 748 pts/1 R+ 17:27 0:00 grep tftp
root@ubuntu:/#

4 查看服务是否开始工作
root@ubuntu:/# netstat -pna|grep tft
udp 0 0 0.0.0.0:69 0.0.0.0:* 26853/in.tftpd
unix 2 [ ] DGRAM 164700 26853/in.tftpd
root@ubuntu:/#


第二步 安装dhcp服务器

1 服务器环境
root@ubuntu:/# uname -a
Linux ubuntu 2.6.22-14-generic #1 SMP Sun Oct 14 23:05:12 GMT 2007 i686 GNU/Linux
root@ubuntu:/#

2 安装命令
root@ubuntu:/# apt-get install dhcp3-server
正在读取软件包列表... 完成
正在分析软件包的依赖关系树
Reading state information... 完成
dhcp3-server 已经是最新的版本了。
共升级了 0 个软件包,新安装了 0 个软件包,要卸载 0 个软件包,有 0 个软件未被升级。

3 设置dhcpd工作接口
root@ubuntu:~# nano /etc/default/dhcp3-server
# Defaults for dhcp initscript
# sourced by /etc/init.d/dhcp
# installed at /etc/default/dhcp3-server by the maintainer scripts
#
# This is a POSIX shell fragment
#

# On what interfaces should the DHCP server (dhcpd) serve DHCP requests?
# Separate multiple interfaces with spaces, e.g. "eth0 eth1".

# 下面这句用来定义工作接口,如果是多个就中间空格
# 比如INTERFACES="eth0 eth1 eth2"
INTERFACES="eth0"
(注*上面一行指明服务器端通过哪一块网卡提供dhcp服务)

4 主要设置
root@ubuntu:~# nano /etc/dhcp3/dhcpd.conf

#
# Sample configuration file for ISC dhcpd for Debian
#
# $Id: dhcpd.conf,v 1.1.1.1 2002/05/21 00:07:44 peloy Exp $
#

# The ddns-updates-style parameter controls whether or not the server will
# attempt to do a DNS update when a lease is confirmed. We default to the
# behavior of the version 2 packages ('none', since DHCP v2 didn't
# have support for DDNS.)
ddns-update-style none;

#下面是全局设置,这里定义的信息全dhcp服务器生效
#我一般注释掉了,下面可以分不同的子网进行设置
# option definitions common to all supported networks...
#option domain-name "apt-get.cn";
#option domain-name-servers 202.103.0.117, 202.103.24.68;
#default-lease-time 600;
#max-lease-time 7200;

# If this DHCP server is the official DHCP server for the local
# network, the authoritative directive should be uncommented.
#authoritative;

# Use this to send dhcp log messages to a different log file (you also
# have to hack syslog.conf to complete the redirection).
log-facility local7;

# No service will be given on this subnet, but declaring it helps the
# DHCP server to understand the network topology.

#subnet 10.152.187.0 netmask 255.255.255.0 {
#}

# This is a very basic subnet declaration.

#subnet 10.254.239.0 netmask 255.255.255.224 {
# range 10.254.239.10 10.254.239.20;
# option routers rtr-239-0-1.example.org, rtr-239-0-2.example.org;
#}

# This declaration allows BOOTP clients to get dynamic addresses,
# which we don't really recommend.

#subnet 10.254.239.32 netmask 255.255.255.224 {
# range dynamic-bootp 10.254.239.40 10.254.239.60;
# option broadcast-address 10.254.239.31;
# option routers rtr-239-32-1.example.org;
#}

# A slightly different configuration for an internal subnet.
#subnet设置一个子网192.168.1.0/24
#range定义可以分配出去的地址为1.50到1.70
#option domain-name-servers定义dns为202.103.0.117等三个,这里注意每个之间要有个逗号
#option domain-name定义域名称
#option routers定义网关地址
#broadcast-address定义广播地址
#default-lease-time默认租约时间
#max-lease-time 最大租约时间
(注*下面这一段是生效部分,请按照实际情况修改)
subnet 192.168.1.0 netmask 255.255.255.0 {
range 192.168.1.50 192.168.1.70;
(注*上行的动态IP范围请不要与系统中已有的dhcp服务器冲突,比如无线路由器上自带的dhcp,但是也不需要把原有的关掉,只要范围不冲突就可以 了,因为客户端在启动时会自动使用服务器端的dhcp所分配的地址、而不使用无线路由器上分配的)
option domain-name-servers 202.103.0.117,202.103.24.68,202.103.150.44;
option domain-name "apt-get.cn";
(注*上行的domain-name在联网系统里会起作用,所以请选择一个你肯定不会去访问的名字、即使你并不知道它是否被注册成为域名)
option routers 192.168.1.1;
option broadcast-address 192.168.1.255;
default-lease-time 864000;
max-lease-time 86400000;
filename "pxelinux.0";
(注*上面这一行是要手工加的很关键的信息,实际就是启动无盘工作站网卡的方式,而其中的pxelinux.0其实是一个文件名,下文将谈到这个文件如何 生成)
}

# Hosts which require special configuration options can be listed in
# host statements. If no address is specified, the address will be
# allocated dynamically (if possible), but the host-specific information
# will still come from the host declaration.

#host passacaglia {
# hardware ethernet 0:0:c0:5d:bd:95;
# filename "vmunix.passacaglia";
# server-name "toccata.fugue.com";
#}

# Fixed IP addresses can also be specified for hosts. These addresses
# should not also be listed as being available for dynamic assignment.
# Hosts for which fixed IP addresses have been specified can boot using
# BOOTP or DHCP. Hosts for which no fixed address is specified can only
# be booted with DHCP, unless there is an address range on the subnet
# to which a BOOTP client is connected which has the dynamic-bootp flag
# set.
#host fantasia {
# hardware ethernet 08:00:07:26:c0:a5;
# fixed-address fantasia.fugue.com;
#}

# You can declare a class of clients and then do address allocation
# based on that. The example below shows a case where all clients
# in a certain class get addresses on the 10.17.224/24 subnet, and all
# other clients get addresses on the 10.0.29/24 subnet.

#class "foo" {
# match if substring (option vendor-class-identifier, 0, 4) = "SUNW";
#}

#shared-network 224-29 {
# subnet 10.17.224.0 netmask 255.255.255.0 {
# option routers rtr-224.example.org;
# }
# subnet 10.0.29.0 netmask 255.255.255.0 {
# option routers rtr-29.example.org;
# }
# pool {
# allow members of "foo";
# range 10.17.224.10 10.17.224.250;
# }
# pool {
# deny members of "foo";
# range 10.0.29.10 10.0.29.230;
# }
#}

5 启动服务器
root@ubuntu:/# /etc/init.d/dhcp3-server start
* Starting DHCP server dhcpd3 [ OK ]
root@ubuntu:/#

6 查看服务是否已经正常监听
root@ubuntu:/# netstat -aunp|grep dhcp
udp 0 0 0.0.0.0:67 0.0.0.0:* 23011/dhcpd3
已经在67号udp口上开始监听了

第三步 安装配置nfs服务器

1 安装
root@ubuntu:/# apt-get install nfs-common nfs-kernel-server nfs-client
正在读取软件包列表... 完成
正在分析软件包的依赖关系树
Reading state information... 完成
nfs-common 已经是最新的版本了。
nfs-kernel-server 已经是最新的版本了。
注意,我选了 nfs-common 而非 nfs-client
nfs-common 已经是最新的版本了。
共升级了 0 个软件包,新安装了 0 个软件包,要卸载 0 个软件包,有 0 个软件未被升级。

2 配置
root@ubuntu:~# nano /etc/exports

# /etc/exports: the access control list for filesystems which may be exported
# to NFS clients. See exports(5).
#
# Example for NFSv2 and NFSv3:
# /srv/homes hostname1(rw,sync) hostname2(ro,sync)
#
# Example for NFSv4:
# /srv/nfs4 gss/krb5i(rw,sync,fsid=0,crossmnt)
# /srv/nfs4/homes gss/krb5i(rw,sync)
/home/cache/netboot 192.168.1.0/24(rw,no_root_squash,sync)
(注*上面这一行是服务器端提供的磁盘空间的位置,可以是服务器的任一目录,建议将一个单独的磁盘分区挂在这个目录下。但是请注意:这个服务器端 的/home/cache/netboot并不是将来客户端的虚拟根目录,因为在/home/cache/netboot下面将会有一个名为root的子 目录,而这个/home/cache/netboot/root才是本文中的客户端的虚拟根目录,在启动完成后、实际运行过程中,工作就仅局限在 /home/cache/netboot/root中了。建立root的问题下文将会讲到)

3 启动nfs或者重新加载
启动nfs
root@ubuntu:/# /etc/init.d/nfs-kernel-server start
* Exporting directories for NFS kernel daemon...
exportfs: /etc/exports [1]: Neither 'subtree_check' or 'no_subtree_check' specified for export "192.168.1.0/24:/home/cache/netboot".
Assuming default behaviour ('no_subtree_check').
NOTE: this default has changed since nfs-utils version 1.0.x
...done.
* Starting NFS kernel daemon
...done.
如果是修改了/etc/exports 配置文件,不需要重新启动nfs服务器,只需要刷新一下,命令如下
root@ubuntu:/# exportfs -r
exportfs: /etc/exports [1]: Neither 'subtree_check' or 'no_subtree_check' specified for export "192.168.1.0/24:/home/cache/netboot".
Assuming default behaviour ('no_subtree_check').
NOTE: this default has changed since nfs-utils version 1.0.x


【正文第一部分-2】服务器端其他必要准备

服务器端还需准备上文提到的pxelinux.0(也即远程启动客户端网卡的核心模块),其过程如下:
(以下全部来自“天使之翼”原文,仅加了必要的注解)

第四步 安装syslinux
1 安装syslinux,其实也就是为了要里面的pxelinux部分的文件
root@ubuntu:/# apt-get install syslinux
正在读取软件包列表... 完成
正在分析软件包的依赖关系树
Reading state information... 完成
syslinux 已经是最新的版本了。
共升级了 0 个软件包,新安装了 0 个软件包,要卸载 0 个软件包,有 0 个软件未被升级。

2 拷贝pxelinux.0文件到tftpboot目录
root@ubuntu:/# cp /usr/lib/syslinux/pxelinux.0 /var/lib/tftpboot/
root@ubuntu:/#
(注*本文中将会涉及两个不同的tftpboot目录,这里是其中的第一个,请不要和下文的/home/cache/netboot/tftpboot混 淆)

3 在tftpboot目录建立pxelinux.cfg目录,然后在pxelinux.cfg目录下建立default文件
也可以是以某个ip地址为文件名称
root@ubuntu:/# nano /var/lib/tftpboot/pxelinux.cfg/default
(注*所谓default其实是假设系统中只有一台客户端时的简易操作,如果有多台客户端,则需建立多个文件、以客户端各自的IP地址为文件名。服务器也 就是通过这种方法来区别不同的客户端,以导入各自不同的虚拟根目录)

DEFAULT ubuntu
LABEL ubuntu
kernel linux
append initrd=initrd.nfs root=/dev/nfs nfsroot=192.168.1.88:/home/cache/netboot/root ip=dhcp rw
(注*注意这一行出现的/home/cache/netboot/root就是上文说到的default客户端将来的虚拟根目录在服务器端上的位 置,而非其上级的/home/cache/netboot。当有多个客户端时,其各自的以IP命名的文件中,这一行的目录路径应该是不同的、以此来区别各 自独立的虚拟根目录)
PROMPT 1
TIMEOUT 3


【正文第二部分】有盘客户机端(机器名为netfs)安装
顶(0)
踩(0)

您可能还会对下面的文章感兴趣:

最新评论