专注业务连续性支持与数据保护
2009-10-13技术合集

MySQL同步出错已关闭评论

MySQL同步出错

mysql>show slave status\G;
*************************** 1. row ***************************
Slave_IO_State: Waiting for master to send event
Master_Host: xxxxxxxx
Master_User: xxxxxxxx
Master_Port: 3306
Connect_Retry: 60
Master_Log_File: mysql-bin.000036
Read_Master_Log_Pos: 11719407
Relay_Log_File: localhost-relay-bin.000338
Relay_Log_Pos: 911985373
Relay_Master_Log_File: mysql-bin.000035
Slave_IO_Running: Yes
Slave_SQL_Running: No
Replicate_Do_DB: xxxxxxxx
Replicate_Ignore_DB:
Replicate_Do_Table:
Replicate_Ignore_Table:
Replicate_Wild_Do_Table:
Replicate_Wild_Ignore_Table:
Last_Errno: 1594
Last_Error: Relay log read failure: Could not parse relay log event entry. The possible reasons are: the master’s binary log is corrupted (you can check this by running ‘mysqlbinlog’ on the binary log), the slave’s relay log is corrupted (you can check this by running ‘mysqlbinlog’ on the relay log), a network problem, or a bug in the master’s or slave’s MySQL code. If you want to check the master’s binary log or slave’s relay log, you will be able to know their names by issuing ‘SHOW SLAVE STATUS’ on this slave.
Skip_Counter: 0
Exec_Master_Log_Pos: 911985228
Relay_Log_Space: 1085463840
Until_Condition: None
Until_Log_File:
Until_Log_Pos: 0
Master_SSL_Allowed: No
Master_SSL_CA_File:
Master_SSL_CA_Path:
Master_SSL_Cert:
Master_SSL_Cipher:
Master_SSL_Key:
Seconds_Behind_Master: NULL
Master_SSL_Verify_Server_Cert: No
Last_IO_Errno: 0
Last_IO_Error:
Last_SQL_Errno: 1594
Last_SQL_Error: Relay log read failure: Could not parse relay log event entry. The possible reasons are: the master’s binary log is corrupted (you can check this by running ‘mysqlbinlog’ on the binary log), the slave’s relay log is corrupted (you can check this by running ‘mysqlbinlog’ on the relay log), a network problem, or a bug in the master’s or slave’s MySQL code. If you want to check the master’s binary log or slave’s relay log, you will be able to know their names by issuing ‘SHOW SLAVE STATUS’ on this slave.
1 row in set (0.00 sec)

注意上面的黑色字体。

执行

mysql>stop slave;
mysql>change master to master_host=’xxxxx’, master_user=’xxxx’,master_password=’xxxxxx’,master_port=3306,master_log_file=’mysql-bin.000036‘,master_log_pos=911985228;
mysql>start slave;

2009-10-09技术合集

修改oracle默认编码已关闭评论

修改oracle默认编码

查看oracle数据库字符集:
select userenv(‘language’) from dual;

修改过程:
SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup mount
ORACLE instance started.
Total System Global Area 135337420 bytes
Fixed Size 452044 bytes
Variable Size 109051904 bytes
Database Buffers 25165824 bytes
Redo Buffers 667648 bytes
Database mounted.
SQL> Alter SYSTEM ENABLE RESTRICTED SESSION;
System altered.
SQL> Alter SYSTEM SET JOB_QUEUE_PROCESSES=0;
System altered.
SQL> Alter SYSTEM SET AQ_TM_PROCESSES=0;
System altered.
SQL> Alter DATABASE OPEN;
Database altered.
SQL>alter database character set INTERNAL_USE UTF8
或者修改成zhs16gbk编码格式
SQL> alter database character set zhs16gbk

SQL> shutdown immediate //先关闭数据库,再开启使之字符集生效
Database closed.
Database dismounted.
ORACLE instance shut down.

SQL>startup

2009-09-28技术合集

关于Autorun.inf及其命令详解已关闭评论

关于Autorun.inf及其命令详解

我们已经知道可以利用Autorun.inf来指定光盘自动加载的图标和运行的文件,其实Autorun.inf的用处可大了,下面就向大家详细介绍有关Autorun.inf的应用。
了解Autorun.inf
什么是Autorun.inf文件呢,严格的说它是一个必须存放在驱动器根目录下的有一定格式的文本文件,它是由一个或多个“节”组成,每个“节”民须以节名作为开始的一行,节名必须用中括号[]括起来,节名之下则为本节中的命令。
其中Autorun.inf一共支持三个节,它们分虽为[autorun]、[autorun.alpha]、[Deviceinstall],其中只有[autorun]是必须存在的。
实例应用
现在我们就来以实例的方式来详细了解Autorun.inf文件到底有哪些庆用。
(1)自动运行
自动运行在前文有所接触,即使用Open命令进行,要注意的是“Open=”指定的文件必须为可执行文件,例如com、exe、bat;如果指定的文件不在根目录下,则需要指定其路径,例如Open=soft .bat,这就表示运行光盘根目录下soft文件夹中的1.bat文件。
小提示:如果要运行的文件不是com、exe、bat,那么也没关系,我们可以手工编写一个bat文件,将要打开的文件所在路径和文件名添加在bat之中即可。
(2)自定义光盘图标
在Autorun节中,还有一个比较好玩的命令行,那就是icon,一般情况下指定的图标文件可以是ico和bmp格式,当然也可以是包含图标资源的exe和dll文件,如果exe和dll文件中包含多个图标文件,那么就必须指定希望使用的图标索引号,要注意的是图标索引号是从0开始编号的,例如“icon=icon.dll,1”,那么就表示将使用icon.dll文件中的第二个图标。
小提示:icon不仅可以应用在光盘上,我们也可以将该命令编写进autorun.inf文件放置在硬盘根目录自定义硬盘的图标。
(3)自定义卷标
虽然说光盘刻录软件中一般都可以设置光盘卷标,但是如果要批量刻录的话,那就会显的很麻烦,不如使用命令定义的快捷。
定义卷标是利用Label命令来完成的,它的语法和Open、Icon是一样的,在这里不再多述。
(4)添加右键菜单
当我们右击刻录的光盘时,经常会在右键菜单中发现一个自动播放的选项,其实这主要是利用Autorun.inf中的Open命令来实现的,其实我们还可以根据需要添加其它菜单命令。
添加其它菜单命令的格式是“Shell<菜单命令名>Command=<要执行的文件>”,例如我们编写了一个文件内容如下:
[autorun]
shell打开记事本command=notepad.exe
这样当我们将该文件刻录进光盘时,右击光盘时在弹出菜单中就会有一个“打开记事本”的命令了。
(5)改变缺省操作
一般情况下应用autorun.inf的光盘双击缺省操作大多是自动播放,即执行open后面的文件操作。其实我们也可以改变这种情况,而这同样是利用shell命令来完成。
我们先来看一个典型双击安装软件的示例:
[autorun]
shellsetupcommand=softsetup.exe
shell eadme=安装软件
shell=setup
要看懂这段语句,我们可以从下向上看,当我们双击光盘时,将调用最后一句Shell=setup,因为设置了该句,那么双击时将查找对应Shellsetupcommand后面指定的命令来作为默认操作,因此默认的操作将变成执行光盘根目录下的soft文件夹中的setup.exe文件。
在这里主要介绍的是autorun节内容的应用,而对于autorun.alpha来说我们很少用到,而Deviceinstall只能在Windows XP下使用,可以利用它指定硬件向导进行递归搜索的子目录。
理论基础
经常使用光盘的朋友都知道,有很多光盘放入光驱就会自动运行,它们是怎么做的呢?光盘一放入光驱就会自动被执行,主要依靠两个文件,一是光盘上的AutoRun.inf文件,另一个是操作系统本身的系统文件之一的Cdvsd.vxd。Cdvsd.vxd会随时侦测光驱中是否有放入光盘的动作,如果有的话,便开始寻找光盘根目录下的AutoRun.inf文件。如果存在AutoRun.inf文件则执行它里面的预设程序。
AutoRun.inf不光能让光盘自动运行程序,也能让硬盘自动运行程序,方法很简单,先打开记事本,然后用鼠标右键点击该文件,在弹出菜单中选择“重命名”,将其改名为AutoRun.inf,在AutoRun.inf中键入以下内容:
[AutoRun] //表示AutoRun部分开始,必须输入
Icon=C:\C.ico //给C盘一个个性化的盘符图标C.ico
Open=C:\1.exe //指定要运行程序的路径和名称,在此为C盘下的1.exe
保存该文件,按F5刷新桌面,再看“我的电脑”中的该盘符(在此为C盘),你会发现它的磁盘图标变了,双击进入C盘,还会自动播放C盘下的1.exe文件!
解释一下:“[AutoRun]”行是必须的固定格式,“Icon”行对应的是图标文件,“C:\C.ico”为图标文件路径和文件名,你在输入时可以将它改为你的图片文件所在路径和文件名。另外,“.ico”为图标文件的扩展名,如果你手头上没有这类文件,可以用看图软件ACDSee将其他格式的软件转换为ico格式,或者找到一个后缀名为BMP的文件,将它直接改名为ICO文件即可。
“Open”行指定要自动运行的文件及其盘符和路径。要特别说明的是,如果你要改变的硬盘跟目录下没有自动播放文件,就应该把“OPEN”行删掉,否则就会因为找不到自动播放文件而打不开硬盘,此时只能用鼠标右键单击盘符在弹出菜单中选“打开”才行.
相信大家学了之后一定会大开眼界,其实除了本文所介绍之外,还有很多精彩的应用等着你来挖掘。要知道学习是师傅领进门,修行靠个人,余下的事情就看你了。
另外:autorun可以被黑客利用,我们可以关闭自动运行,让它不能发生作用
方法
禁止硬盘的自动运行:注册表编辑器展开HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\Exploer主键下,右边窗口中的二进制值“NoDriveTypeAutoRun”决定了是否执行AutoRun功能,将“NoDriveTypeAutoRun”的默认键值由95, 00,00,00,改为9D,00,00,00,然后关闭注册表编辑器,重启电脑即可。
只禁止光盘的自动运行,可以将“NoDriveTypeAutoRun”的键值改为BD,00,00,00

2009-09-28技术合集

Yum安装与管理已关闭评论

Yum安装与管理

Yum(全称为 Yellow dog Updater, Modified)是一个在Fedora中的Shell前端软件包管理器。
基于RPM包管理,能够从指定的服务器自动下载RPM包并且安装,可以自动处理依赖性关系,并
且一次安装所有依赖的软体包,无须繁琐地一次次下载、安装。
YUM服务涉及到客户端与服务端,其中:
1 YUM Client:要保证安装有如下软件包:
yum-3.0.1-5.el5
yum-metadata-parser-1.0-8.fc6
2 YUM Server:要保证安装有如下软件包:
yum-3.0.1-5.el5
yum-metadata-parser-1.0-8.fc6
yum-rhn-plugin-0.4.3-1.el5
yum-updatesd-3.0.1-5.el5
createrepo-0.4.4-2.fc6.noarch.rpm
yum-arch-2.2.2-2.fc7.noarch.rpm
yum服务器的安装
1 存放YUM服务器上的软件包
放入redhatES5系统盘,将其挂载到/mnt
再生成/rhel5目录用于存放软件包:
[root@ns100 vmware]# mkdir /rhel5
将光盘上Server目录(该目录主要存放一些服务端软件包)下的所有软件包拷入/rhel5,因为Server
目录中软件包较多,rhel5可能放不下,此时可以格式化一块5G的分区,挂载于/rhel5目录下。
[root@ns100 vmware]# cp -R /mnt/Server /rhel5
将key文件(用于客户端与服务端的认证)拷入指定目录
[root@ns100 vmware]# cp /mnt/RPM-GPG-KEY-redhat-release /rhel5/Server
备注:如果有系统光盘的iso文件(光盘镜像文件),可以利用此文件来做虚拟光驱,再将此虚拟光驱
挂载到/mnt,方法如下:
mount -o loop redhat.iso /mnt
进入/mnt即可使用了;
2 服务端设置软件仓库及报告文件
首先,生成YUM的软件仓库:
[root@ns100 vmware]# yum-arch /rhel5/Server 注:即可有出错也可不管
再设置给客户端获取的报告文件:
[root@ns100 vmware]# createrepo /rhel5/Server
3 配置www服务,用于发布这些软件包
在/etc/httpd/conf/httpd.conf中进行如下配置(注:如果httpd起不来,此时用setenforce 0
将SELinux关闭即可)
DocumentRoot "/var/www/html" 改为 DocumentRoot "/rhel5"
<Directory "/var/www/html"> 改为<Directory "/rhel5">
接着重启http服务:
[root@localhost ~]# service httpd restart
Stopping httpd: [ OK ]
Starting httpd: [ OK ]
4客户端配置:
方法1
在/etc/yum.repos.d/下生成Server.repo 文件 注:如果/etc/yum.conf有设置的话优先从
yum.conf中查找;
Client:
最好把原来的.repo文件备份一下:
[root@network yum.repos.d]# mkdir -p /etc/yum.repos.d/backup
[root@network yum.repos.d]# mv /etc/yum.repos.d/*.repo /etc/yum.repos.d/backup
[root@network yum.repos.d]# touch /etc/yum.repos.d/Server.repo
[root@network yum.repos.d]# cat /etc/yum.repos.d/Server.repo (注:如果配置yum.conf
的话,其尾部也加入如下内容,其余不变;)
[Server]
name=Red Hat
baseurl=http://10.0.0.1/Server/
gpgcheck=1
gpgkey=http://10.0.0.1/Server/RPM-GPG-KEY-redhat-release
方法2
修改默认的/etc/rhel-debuginfo.repo 改两处地方
baseurl=http://10.0.0.1/Server/
enabled=1
5测试
在客户端执行如下命令:
yum install dasher
yum -y install firefox 安装自动应答为yes
yum remove httpd 删除软件包
yum clean all 清空下载的软件包的缓存
yum list 列出所有的软件包(包括已安装和在YUM服务器上存在的)
yum upgrade或yum update 升级软件包
yum list installed 列出所有已经安装的软件包
yum list available 列出所有可用的软件包
yum list updates 列出所有可升级的软件包
附:基于FTP的YUM服务器搭建
1 放入redhatES5系统盘,将其挂载到/mnt
[root@ns100 vmware]# cp -R /mnt/Server /var/ftp/Server
[root@ns100 vmware]# cp /mnt/RPM-GPG-KEY-redhat-release /var/ftp/Server
2
[root@ns100 vmware]# yum-arch /var/ftp/Server 注:即可有出错也可不管
[root@ns100 vmware]# createrepo /var/ftp/Server
3配置yum.conf
[root@ns100 vmware]# cat /etc/yum.conf
[main]
cachedir=/var/cache/yum
keepcache=0
debuglevel=2
logfile=/var/log/yum.log
pkgpolicy=newest
distroverpkg=redhat-release
tolerant=1
exactarch=1
obsoletes=1
gpgcheck=1
plugins=1
metadata_expire=1800
4 运行vsftp服务
service vsftpd restart
5客户端配置:
方法1
在/etc/yum.repos.d/下生成Server.repo 文件 注:如果/etc/yum.conf有设置的话优先从
yum.conf中查找;
Client:
[root@network yum.repos.d]# mkdir -p /etc/yum.repos.d/backup
[root@network yum.repos.d]# mv /etc/yum.repos.d/*.repo /etc/yum.repos.d/backup
[root@network yum.repos.d]# touch /etc/yum.repos.d/Server.repo
[root@network yum.repos.d]# cat /etc/yum.repos.d/Server.repo 注:yum.conf尾部也加入
如下内容,其余不变;
[Server]
name=Red Hat
baseurl=ftp://10.0.0.1/Server/
gpgcheck=1
gpgkey=ftp://10.0.0.1/Server/RPM-GPG-KEY-redhat-release
方法2
修改默认的/etc/rhel-debuginfo.repo 改两处地方
baseurl=ftp://10.0.0.1/Server/
enabled=1

2009-09-28技术合集

SystemImager系统部署已关闭评论

SystemImager系统部署

系统部署是构建集群的第一步,如何快速,高效地部署系统是值得讨论的问题。本文描述基于开源软件SystemImager的系统部署方法并给出基本操作步骤。
SystemImager由Brian Elliott Finley创建。目前的维护者和项目小组的领导者是Andrea
Righi。SystemImager,是System Installation Suite的一部份,它能自动安装GNU/Linux,发布软件及快速部署生产环境。
SystemImager的一个主要特征是与发行版本无关,并且能支持不同种类的硬件。这一特征可
以让我们将任何种类的GNU/Linux(标准的发行版本或者自定义的版本)部署到目标机。此项目的主要目标是实现轻松,快捷的部署大量的节点。典型的应用环境包括计算机实验室,render farms(注:视觉农场,很多大片在后期制作所使用的图形渲染的工作站,类似于超级计算机),Internet服务器中心,数据库服务器中心,公司桌面环境等。SystemImager已经被证实了在集群计算环境中很流行,如网格计算和高性能计算。
另一个设计上便于GNU/Linux发行以及不依赖于硬件的特点是SystemImager处理的是基于系统镜像的文件。镜像以文件形式储存目录体系节构,即为样本节点的一个全面的快照,包含节点根文件系统中所有文件及目录。镜像以多种方法获得,包括从目标系统(golden client)中获得,或应用第三方工具直接在镜像服务器中生成。
SystemImage的工作原理:安装并配置好镜像服务器及样本节点(Golden Client),然后镜
像服务器捕捉样本节点的镜像并存储,最后启动目标节点并将镜像分发下去,完成对目标节点的部署。如下图所示:
镜像服务器Golden Client
镜像服务器
硬盘
Golden Client
系统映像
集群节点1 集群节点2 集群节点n
克隆系统
……
具体步骤:
前一阵在我的博客中针对低版本(SystemImager3.2)的安装及使用写了一些步骤,现在针对
现在的稳定版本4写一下具体操作步骤。
实验环境:服务器P4-1.7/256M,CentOS5.1;在另一台P4-2.8/1G的机器上安装几台虚拟机
作为节点,虚拟机分配256M内存,其中一台作为Golden Client,所装系统为CentOS5.2,大小
约1.6G;100Mbits局域网。
1,安装软件
从https://sourceforge.net/project/platformdownload.php?group_id=259下载需要的软
件版本和相应硬件架构的启动包。SystemImage用Perl开发,所以安装时对Perl模块有依赖性。
如AppConfig,MLDBM,XML-Simple等,需要时可以自己下载安装,此处不做详细说明。
镜像服务器中执行如下命令:
# rpm -ivh –nodeps systemconfigurator-2.2.11-1.noarch.rpm \
> systemimager-server-4.0.2-1.noarch.rpm \
> systemimager-common-4.0.2-1.noarch.rpm \
> systemimager-i386boot-standard-4.0.2-1.noarch.rpm \
> systemimager-i386initrd_template-4.0.2-1.noarch.rpm
Golden Client中执行如下命令:
# rpm -ivh –nodeps systemconfigurator-2.2.11-1.noarch.rpm \
> systemimager-common-4.0.2-1.noarch.rpm \
> systemimager-client-4.0.2-1.noarch.rpm \
> systemimager-i386initrd_template-4.0.2-1.noarch.rpm
镜像服务器及Golden Client中已经安装所需的Perl模块,所以加上–nodeps参数。如果此处
没安装有的话系统会提示依赖性,可根据提示下载并安装相应软件包。
2,Golden Client端准备
在golden client上,以root执行si_prepareclient命令。这会在/etc/systemimager目录下
生成许多文件,其中包含分区方案,文件系统类型等。si_prepareclient会启动一个rsync进程来让
这些文件传输到服务器上。
# si_prepareclient –server 192.168.1.63
服务器地址为192.168.1.63,此处也可以写服务器名称。
执行完上面的命令后系统会以命令行交互方式询问是否继续,其中会更改一些文件配置并启动
rsync进程,如果回答y继续的话,系统会告知已经准备完毕,可以在服务器端执行si_getimage
命令。
3,服务器端获取镜像
在镜像服务器上执行si_getimage,从golden client捕捉镜像。应用si_getimage,镜像服
务器从样本节点文件系统的根目录中将所有文件及目录备份成镜像存放
于/var/lib/systemimager/images中。
# si_getimage –golden-client 192.168.1.67 –image backup
此处要指明golden client的地址或主机名以及生成镜像的名称。在询问是否继续后系统会做出
反映。如果同意继续并无其它阻碍(防火墙)的话此时会复制golden client中的文件。笔者所装大
小约为1.6G的golden client系统(在VM中安装的CentOS5.2)来说复制过程大约10分钟,如
果是实机的话此处会表现出更好的性能。
4,准备分发镜像
镜像获得后存放于/var/lib/systemimager/images/backup,其中所包含的内容即为golden
client的系统文件及目录。
可以通过四种方式启动节点来分发镜像:
? 从网络启动(PXE)
? 从自动安装CD启动
? 从自动安装盘启动(USB设备或软盘)
? 从一个启动的系统启动
此处可按不同的硬件环境来选择不同的方法,如果网卡不支持PXE的话可以选择用USB设备或
CD进行启动后安装,当然不同的安装方法使用不同的命令创建启动工具。本文介绍了以PXE方式
启动安装,这种方法的优点是简约而时尚,当然,如果硬件并不支持PXE的话可以创建另外的启动
工具,对安装的节点来说只是通过不同的方式获得引导信息。
SystemImager的si_mkbootserver命令用来配置启动服务器。执行si_mkbootserver启动一个交
互过程,它会创建tftproot目录,配置tftp服务器,并执行一些测试看看功能是否正常。一旦
si_mkbootserver检测出错误,它会宣告失败并生成错误日志。更正错误后,可以重新执行
si_mkbootserver,不断重复这个过程直到配置成功。si_mkbootserver同时会调用
si_mkdhcpserver命令,用来为节点分配IP。这个命令简化了DHCP的配置, 它会询问需要的所有
信息来创建适合SystemImager安装的DHCP配置文件。
下面是笔者进行的配置:
# si_mkbootserver
WARNING: this script may modify the following files:
–> /etc/services
–> /etc/inetd.conf
–> /etc/xinetd.d/tftp
And can restart inetd, xinetd or tftp servers.
Do you wish to continue (y/[n])? y
Ok, continuing…
/var/lib/tftpboot exists and is a symlink to /usr/share/systemimager/boot.
Checking for a tftp server… found.
Checking if tftp server is H. Peter Anvin’s tftp server… yup – right on!
Checking for a running inetd… Not found.
Checking for a running xinetd… 3262.
Looking for update-inetd… not found.
Backing up /etc/xinetd.d/tftp…
Moving /etc/xinetd.d/tftp to /etc/xinetd.d/tftp.si_mkbootserver.bak1…done.
Restaring xinetd …
停止 xinetd: [确定]
启动 xinetd: [确定]
done.
Looking for a tftp client… found.
Checking for loopback interface… up.
Does tftp server work… yes.
Looking for a pxe daemon… which: no pxe in
(/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin)
not found.
WARNING: your bootserver will be configured without a pxe daemon!
(ignore this warning if you’re using a recent distro)
done.
What is the path to the pxelinux bootloader [/usr/lib/syslinux/pxelinux.0]?
Backing up /var/lib/tftpboot/pxelinux.cfg…
Moving /var/lib/tftpboot/pxelinux.cfg to
/var/lib/tftpboot/pxelinux.cfg.si_mkbootserver.bak24…done.
Copying /var/lib/tftpboot/X86PC/UNDI/linux-install/pxelinux.cfg to
/var/lib/tftpboot/pxelinux.cfg…Ok, configuration complete.
Once you’re DHCP server is configured, you should be all set.
Do you want to run si_mkdhcpserver to configure your DHCP server ([y]/n)? y
Welcome to the SystemImager "si_mkdhcpserver" command. This command will
prepare this computer to be a DHCP server by creating a dhcpd.conf file
for use with your ISC DHCP server (v2 or v3).
If there is an existing file, it will be backed up with the
.beforesystemimager extension.
Continue? (y/[n]): y
Trying to probe your DNS domain. Please wait…
Type your response or hit <Enter> to accept [defaults]. If you don’t
have a response, such as no first or second DNS server, just hit
<Enter> and none will be used.
What is your DHCP daemon major version number (2 or 3)? [3]:
What is the name of your DHCP daemon config file? [/etc/dhcpd.conf]:
What is your domain name? []: changzi.centos
What is your network number? [192.168.1.0]:
What is your netmask? [255.255.255.0]:
What is the starting IP address for your dhcp range? [192.168.1.1]: 192.168.1.50
What is the ending IP address for your dhcp range? [192.168.1.254]: 192.168.1.80
What is the IP address of your first DNS server? []:
What is the IP address of your default gateway? [192.168.1.254]: 192.168.1.1
What is the IP address of your image server? [192.168.1.254]: 192.168.1.63
What is the IP address of your boot server? [192.168.1.254]: 192.168.1.63
What is the IP address of your log server? []:
Use tmpfs staging on client? (If unsure, choose "n") [n]:
Do you want to use Flamethrower (multicast) to install your clients? [n]:
What… is the air-speed velocity of an unladen swallow? []:
Wrong!!! (with a Monty Python(TM) accent…)
Press <Enter> to continue…
Ahh, but seriously folks…
Here are the values you have chosen:
############################################################
###########
ISC DHCP daemon version: 3
ISC DHCP daemon config file: /etc/dhcpd.conf
DNS domain name: changzi.centos
Network number: 192.168.1.0
Netmask: 255.255.255.0
Starting IP address for your DHCP range: 192.168.1.50
Ending IP address for your DHCP range: 192.168.1.80
First DNS server:
Second DNS server:
Third DNS server:
Default gateway: 192.168.1.1
Image server: 192.168.1.63
Boot server: 192.168.1.63
Log server:
Log server port:
Flamethrower directory port:
Use tmpfs staging on client: n
SSH files download URL:
############################################################
###########
Are you satisfied? (y/[n]): y
The dhcp server configuration file (/etc/dhcpd.conf) file has been
created for you. Please verify it for accuracy.
If this file does not look satisfactory, you can run this command again
to re-create it: "si_mkdhcpserver"
WARNING!: If you have multiple physical network interfaces, be sure to
edit the init script that starts dhcpd to specify the interface that
is connected to your DHCP clients. Here’s an example:
Change "/usr/sbin/dhcpd" to "/usr/sbin/dhcpd eth1".
Depending on your distribution, you may be able to set this with the
"INTERFACES" variable in "/etc/default/dhcp", "/etc/default/dhcp3-server",
or similar, or in your dhcpd initialization script ("/etc/init.d/dhcpd",
"/etc/init.d/dhcp3-server", or similar).
Also, be sure to start or restart your dhcpd daemon. This can usually
be done with a command like "/etc/init.d/dhcpd restart" or similar.
Would you like me to restart your DHCP server software now? (y/[n]): y
关闭 dhcpd: [确定]
启动 dhcpd: [确定]
5,创建相应连接
如果镜像服务器中有多个镜像的话,就要告知哪一个节点安装哪一个镜像。si_addclients为镜
像的安装脚本创建符号链接。si_addclients改写镜像服务器的/etc/hosts
和/var/lib/systemimager/scripts/hosts文件。Hosts文件为自动安装客户端查阅他们的主机名提供
默认的机制。
在si_addclients的第一个配置部分,需要指出自动安装节点的主机名称样式。一个主机范围的
字段和一个域名用来定义我们要自动安装的节点的主机名;在第二个配置部分,将前一部分定义的
节点映射到到镜像;在第三个配置部分,si_addclients命令请求IP地址范围,这个IP保存在/etc/
hosts和/var/lib/systemimager/scripts/hosts文件中。当自动安装客户端启动时,它会从镜像服务
器中检索后面的文件并应用它查找主机名。
# si_addclients
Welcome to the SystemImager "si_addclients" utility
——————————————————————————–
This utility has 3 sections.
"Section 1" will ask you for your hostname information.
"Section 2" will allow you to create softlinks from each client hostname to
your "master" script in the "/var/lib/systemimager/scripts" directory.
Example: www297.sh -> web_server_image_v1.master
"Section 3" will ask you for IP address information that will be combined
with the hostname information provided in Section 1 to create entries in
"/etc/hosts" for each of these same clients. New entries will be appended
to the end of "/etc/hosts". If you specify new hostnames for existing IP
addresses, those entries will be re-written in place to reflect the new
host names.
Continue? ([y]/n): y
si_addclients — Section 1 (hostname information)
——————————————————————————–
The next series of questions will be used to create a range of hostnames.
You will be asked for your domain name, the base host name, a beginning
number, and an ending number.
For example, if you answer:
domain name = systemimager.org
host range = www7-www11,www20
Then the result will be a series of hostnames that looks like this:
www7.systemimager.org
www8.systemimager.org
www9.systemimager.org
www10.systemimager.org
www11.systemimager.org
www20.systemimager.org
What is your domain name? []: changzi.centos
What is the hosts range that you want me to use? []: www50-www80
I will work with hostnames: www50-www80
in the domain: changzi.centos
Are you satisfied? (y/[n]): y
si_addclients — Section 2 (soft links to master script)
——————————————————————————–
Would you like me to create soft links to a "master" script so that hosts:
www50-www80
can be autoinstalled with one of the available images? ([y]/n): y
Here is a list of available autoinstall scripts:
backup
Which script would you like these hosts to be installed with?
[backup]:
Your soft links have been created.
Press <Enter> to continue…
si_addclients — Section 3 (adding or modifying /etc/hosts entries)
——————————————————————————–
Your target machines need to be able to determine their host names from their
IP addresses, unless their host name is specified in a local.cfg file.
The preferred method for doing this is with DNS. If you have a working DNS
that has IP address to hostname resolution properly configured for your
target machines, then answer "n" here.
If you don’t have a working DNS, or you want to override the information in
DNS, then answer "y" here to add entries to the "/etc/hosts" file on your
image server. After adding these entries, the /etc/hosts file will be
copied to "/var/lib/systemimager/scripts" where it can be retrieved by your
target machines.
I will ask you for your clients’ IP addresses one subnet at a time.
Would you like me to continue? (y/[n]): y
si_addclients — Section 3 (adding or modifying /etc/hosts entries — continued…)
——————————————————————————–
Hostnames range is: www50-www80
What is the IPs address range (e.g. 10.0.0.1-10.0.0.100,10.0.0.101)?
[]:192.168.1.50-192.168.1.80
I will work with IP addresses: 192.168.1.50-192.168.1.80
and hostnames: www50-www80
Are you satisfied? (y/[n]): y
These entries have been added to /etc/hosts, and /etc/hosts has been copied
to /var/lib/systemimager/scripts for use by your auto-install clients.
Press <Enter> to continue…
si_addclients: successfully completed.
6,创建启动介质
见第4步骤中所描述的四种启动方式。此处所用的是从网络启动。使用以下命令,其它启动方
法使用的命令详情见systemimager手册。
# si_mkclientnetboot –netboot –clients www50-www80
[netboot] using the kernel and initrd.img for architecture: i386
[netboot] using the flavor: standard
7,启动节点安装镜像
最后就是启动节点,此处的节点均为虚拟机,从DHCP获得节点IP,下图看到的IP为79,因为
装了两台,另一台的地址即为上面配置的80。开始自动安装,到了这一步是最令人欣喜的。
下载内核及initrd
检测硬件
开始传送文件
传送完毕,等待重启。
重启系统,checking filesystems后再次重启即可进入安装完成的系统中了。这一步用了10
分钟左右。同样,如果是实机的话性能会有所提高。为了进行比较一下,我用光盘安在虚拟机中安
装了同样配置的系统,去掉启动后手工配置的时间是13分钟。可见用这种方法部署系统还是有优
势的。
8,其它
节点系统更新也是SystemImager的一个强大的功能,例如,想将100台服务器的内核更新,
只需将样本节点的内核升级,获得样本节点的镜像,在其它节点系统中执行si_updateclient,指定
镜像后,便可以很快的与新的镜像同步,数据或是配置文件也可以用同样的方法分发。
SystemImager用来确保安全的生产部署,在更新镜像前保存当前生产环境的镜像,这样就提供了处
理意外情况的机制。建立一个带有版本号的镜像池是一个很不错的选择,如果发现新的生产环境有
问题,简单地用si_updateclient命令回滚到上次正常的生产镜像即可。
除了SystemImager这种工具可以执行自动化安装外,像Red Hat的Kickstart等,基于预定
义的安装包清单来安装系统。然而,这种基于包的安装非常有限,因为它对非安装包的文件没有办
法自动化安装,如果重新编译的内核,加入了一些非安装包的软件,或者是更改具体的配置文件,
基于包安装的方法通常要求你写某些脚本或是编程来处理这些“特别案例”。相比之下,不如
SystemImager使用起来方便快捷。在安全方面SystemImager还提供基于OpenSSH方式的安装。
SystemImager应用多种方法启动目标节点,将Linux 操作系统和应用软件一次安装到位。采用分
布式的网络传输结构和点对点的通信(SystemImager提供用BitTorrent进行安装)方式可以有效
缓解由网络带宽引起的性能瓶颈。
总结:这个实验做得不是很流畅,中间遇到好多问题,但大部份都google解决了。最近半个
月以来一直在学习如何使用这个软件。主要的参考资料来源于
http://wiki.systemimager.org/index.php/Documentation,笔者下载并翻译了SystemImager
手册,放到了博客里,但是对于这个软件所提供的更强大的功能尚未深入探究。
《SystemImager手册》中提到过一些实际安装的性能:
Ole Holm Nielsen,物理系,丹麦技术大学报告:
在我们用SystemImager安装时,可以在6分钟内安装1.8G的镜像到18个客户端。请见The
NIFLHEIM SystemImager
Page(http://www.fysik.dtu.dk/CAMP/Niflheim/systemimager.html)。我们的服务器拥有
Gigabit网络,2GB的RAM,dual Intel Xeon 2.4 GHz,客户端是Intel P4和100 Mbit网络。
James Braid 报告: 从一个Celeron 700/512Mb服务器,100Mbit网络,我们做到了7~10
分钟安装大概1G的镜像。硬盘是设置了LVM的5x 120Gb Seagate Barracuda V(non
striped),文件系统为ReiserFS。
参考:
[1]http://wiki.systemimager.org/index.php/Quick_Start_HOWTO
[2]http://www.howtoforge.com/howto_linux_systemimager
PS:有

2009-09-28技术合集

PXE安装linux已关闭评论

PXE安装linux

环境描述:
Network,HP Compaq V3212TU+1G Memory,Windows XP,VMware 6.0.3 build-80004,CentOS-5.1-i386-bin-DVD.iso
一、服务器自身配置状况:
编辑并查看我的服务器网络配置:
编辑IP,掩码,网关等
命令:
vim /etc/sysconfig/network-scripts/ifcfg-eth0
编辑文件内容为:
# Advanced Micro Devices [AMD] 79c970 [PCnet32 LANCE]
DEVICE=eth0
HWADDR=00:0c:29:d7:3e:c3
ONBOOT=yes
NETMASK=255.255.255.0
IPADDR=192.168.0.172
GATEWAY=192.168.0.1
TYPE=Ethernet
编辑主机用的DNS服务器信息
命令:vim /etc/resolv.conf
编辑内容为(注释掉了第二行):
nameserver 202.118.176.2
#search localdomain
也可随时查看网络状态
命令:
ifconfig
查看到的内容:
eth0      Link encap:Ethernet  HWaddr 00:0C:29:D7:3E:C3
inet addr:192.168.0.172  Bcast:192.168.0.255  Mask:255.255.255.0
inet6 addr: fe80::20c:29ff:fed7:3ec3/64 Scope:Link
UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
RX packets:22076 errors:0 dropped:0 overruns:0 frame:0
TX packets:7576 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:1403323 (1.3 MiB)  TX bytes:9996380 (9.5 MiB)
Interrupt:169 Base address:0x2000
lo        Link encap:Local Loopback
inet addr:127.0.0.1  Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING  MTU:16436  Metric:1
RX packets:79 errors:0 dropped:0 overruns:0 frame:0
TX packets:79 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:6448 (6.2 KiB)  TX bytes:6448 (6.2 KiB)
查看无误,重启network服务
命令:service network restart
下面真正开始配置作为服务器的几个关键服务:DHCP,TFTP,NFS
二、所需的文件:
虚拟机的光驱设置为CentOS-5.1-i386-bin-DVD.iso文件
挂载光驱到目录/media/dvd
命令:
mkdir /media/dvd
mount /dev/hdc /media/dvd
安装w3m(感觉w3m比CentOS带的links更上手,仅仅是因为我以前用过w3m)
用w3m访问网站http://www.kernel.org/pub/linux/utils/boot/syslinux/
命令:
yum install w3m
w3m http://www.kernel.org/pub/linux/utils/boot/syslinux/
找到并下载包syslinux-3.63.tar.gz
解压获得文件pxelinux.0,放在TFTP根目录/tftpboot下
命令:
tar -zxvf syslinux-3.63.tar.gz
mkdir /tftpboot
cp /syslinux-3.63/pxelinux.0 /tftpboot/
复制isolinux目录下的isolinux.cfg文件为tftpboot/pxelinux.cfg下的default
命令:
mkdir /tftpboot/pxelinux.cfg
cp /media/dvd/isolinux/isolinux.cfg /tftpboot/mkdir /tftpboot/pxelinux.cfg/default
复制安装盘isolinux目录下的两个重要文件vmlinuz和initrd.img到TFTP根目录/tftpboot下
命令:
cp /media/dvd/isolinux/vmlinuz /tftpboot
cp /media/dvd/isolinux/initrd.img /tftpboot
复制安装盘isolinux目录下的所有.msg文件(boot.msg,initrd.msg,param.msg,general.msg,options.msg,rescue.msg)到TFTP根目录/tftpboot下
命令:
cp /media/dvd/isolinux/*.msg /tftpboot
三、配置DHCP
安装dhcp,dhcp-devel和dhclient三个包,三个包都可以在CentOS安装光盘的CentOS目录下找到
命令:
cd /media/dvd/CentOS
rpm -ivh dhcp-3.0.5-7.el5.i386.rpm
rpm -ivh dhcp-devel-3.0.5-7.el5.i386.rpm
rpm -ivh dhclient-3.0.5-7.el5.i386.rpm
编辑DHCP配置文件/etc/dhcpd.conf,可以从/usr/share/doc/dhcp*/dhcpd.conf.sample将这个配置文件的样例复制过来,这样编辑起来会更快些
dhcpd.conf配置的有关说明:
parameters(参数):
ddns-update-style 配置DHCP-DNS互动更新模式
default-lease-time 指定缺省租赁时间的长度,单位是秒
max-lease-time 指定最大租赁时间长度,单位是秒
hardware 指定网卡接口类型和MAC地址
server-name 通知DHCP客户服务器名称
get-lease-hostnames flag 检查客户端使用的IP地址
fixed-address ip 分配给客户端一个固定的地址
authritative 拒绝不正确的IP地址的要求
declarations(声明):
shared-network 用来告知是否一些子网络分享相同网络
subnet 描述一个IP地址是否属于该子网
range 起始IP 终止IP 提供动态分配IP 的范围
host 主机名称 参考特别的主机
group 为一组参数提供声明
allow unknown-clients或deny unknown-client 是否动态分配IP给未知的使用者
allow bootp或deny bootp 是否响应激活查询
allow booting或deny booting 是否响应使用者查询
filename 开始启动文件的名称,应用于无盘工作站
next-server 设置服务器从引导文件中装如主机名,应用于无盘工作站
option(选项):
subnet-mask 为客户端设定子网掩码
domain-name 为客户端指明DNS名字
domain-name-servers 为客户端指明DNS服务器IP地址
host-name 为客户端指定主机名称
routers 为客户端设定默认网关
broadcast-address 为客户端设定广播地址
ntp-server 为客户端设定网络时间服务器IP地址
time-offset 为客户端设定和格林威治时间的偏移时间,单位是秒。
命令:
cp /usr/share/doc/dhcp*/dhcpd.conf.sample /etc/dhcpd.conf
vim /etc/dhcpd.conf
我编辑好的文件内容为:
ddns-update-style none;
ignore client-updates;
allow booting;
allow bootp;
filename "pxelinux.0";
subnet 192.168.0.0 netmask 255.255.255.0 {
# — default gateway
option routers                  192.168.0.1;
option subnet-mask              255.255.255.0;
option nis-domain               "domain.org";
option domain-name              "domain.org";
option domain-name-servers      192.168.1.1;
# — Selects point-to-point node (default is hybrid). Don’t change this unless
# — you understand Netbios very well
range dynamic-bootp 192.168.0.128 192.168.0.254;
default-lease-time 21600;
max-lease-time 43200;
# we want the nameserver to appear at a fixed address
host ns {
next-server 192.168.0.172;
hardware ethernet 12:34:56:78:AB:CD;
fixed-address 207.175.42.254;
}
}
检查文件/var/lib/dhcpd/dhcpd.leases,文件存在即可
如果考虑到安全问题,在多网卡的机器上可以编辑/etc/sysconfig/dhcpd文件来制定DHCP服务在那个设备上启动
命令:
vim /etc/sysconfig/dhcpd
编辑内容为:
# Command line options here
DHCPDARGS=eth0
重启DHCP服务
命令:
service dhcpd restart或/etc/rc.d/ini.d/dhcpd restart
四、配置TFTP
安装xinetd,tftp和tftp-server,可以在CentOS安装光盘的CentOS目录下找到
命令:
cd /media/dvd/CentOS
rpm -ivh xinetd-2.3.14-10.el5.i386.rpm
rpm -ivh tftp-0.42-3.1.el5.centos.i386.rpm
rpm -ivh tftp-server-0.42-3.1.el5.centos.i386.rpm
编辑TFTP的配置文件
命令:
vim /etc/xinetd.d/tftp
编辑内容为:
# default: off
# description: The tftp server serves files using the trivial file transfer \
#       protocol.  The tftp protocol is often used to boot diskless \
#       workstations, download configuration files to network-aware printers, \
#       and to start the installation process for some operating systems.
service tftp
{
socket_type             = dgram
protocol                = udp
wait                    = yes
user                    = root
server                  = /usr/sbin/in.tftpd
server_args             = -s /tftpboot -c
disable                 = no
per_source              = 11
cps                     = 100 2
flags                   = IPv4
}
重启TFTP服务需要重启xinetd这个守护服务
命令:
service xinetd restart
四、配置NFS
安装NFS包nfs-utils和nfs-utils-lib,可以在CentOS安装光盘的CentOS目录下找到
命令:
rpm -ivh nfs-utils-1.0.9-24.el5.i386.rpm
rpm -ivh nfs-utils-lib-1.0.8-7.2.z2.i386.rpm
编辑NFS的配置文件
命令:
vim /etc/exports
编辑内容为(我的硬盘不够,只好省去复制的步骤,直接将光盘的挂载目录设为NFS的目录):
/media/dvd/ *(ro,async)
重启NFS服务
命令:
service nfs restart
或者可以不必重启整个服务,用下面命令更新NFS服务
命令:
exportfs -arv
最后也可以检查一下NFS目录的设置
命令:
showmount -e localhost
显示内容为:
Export list for localhost:
/media/dvd *
至此,三项重要的服务设置完毕,可以启动客户机进行安装了。
五、启动客户虚拟机安装CentOS
开启电源后按Esc,选择Network boot
客户机将利用主机的DHCP服务获得IP,利用TFTP服务加载安装所需文件
在出现boot:提示后根据需要输入linux text回车(文本模式安装)或直接回车(图形模式安装)
选择
安装语言English
键盘布局us
安装方式(Installation Method)选择NFS image
去掉IPv6的支持,IPv4选择自动获取方式(DHCP)
获得IP后选择NFS服务器的位置
NFS server name:192.168.0.172
CentOS directory:/media/dvd
回车后就会挂载服务器上的NFS网络硬盘,进入到熟悉的安装界面了,linux的安装我就不再赘述了。

2009-09-28技术合集

linux系统远程启动已关闭评论

linux系统远程启动

一、远程启动原理
客户端在启动前,既无操作系统,又无启动的软盘或者硬盘,它只有计算机的基本部件: CPU, 内存,主板等。但最重要的必须有网卡和启动的BootRom。客户机只能通过网络获得操作系统。Linux的无盘远程启动与Novell、WinNT下的无盘启动技术不一样,不是采用RPL( Remote Initial Program Loader),而是基于标准的BootP/DHCP和TFTP协议,并通过NFS文件系统建立文件系统。相对前两种,更具有其通用性和适应性。可以基于Linux系统远程启动Dos,Win95,WinNT和Linux客户。
由于自己的网卡(3c905b-tpo100,有BUG,按照etherboot的说明没修正成功,现在是用软盘代替网卡的EPROM,不好多说,还请自己直接到http://sourceforge.net/下载所需要源码等或者编译自己所需要源码.
下面简单介绍Linux启动原理:
1.客户端个人电脑开机后, 在 TCP/IP Bootrom 获得控制权之前先做自我测试.
2.Bootprom 送出 BOOTP/DHCP 要求而取得 IP.
3.如果服务器收到个人电脑所送出的要求, 就会送回 BOOTP/DHCP 回应,内容包括客户端的 IP 地址, 预设网关及开机影像文件.否则, 服务器会忽略这个要求.
4.Bootprom 由 TFTP 通讯协议从服务器下载开机影像文件。
5.个人电脑通过这个开机影像文件开机, 这个开机文件可以只是单纯的开机程式也可以是操作系统.
6.开机影像文件将包含 kernel loader 及压缩过的 kernel, 此 kernel 将支持NFS root系统。
7.远程客户端根据下载的文件启动机器.
一切OK!!! 简单吧!好用吧!下面具体介绍如何建立Linux远程启动.
二、远程启动实例
作为例子定义以下:
Linux 服务器: server(IP:192.168.0.254)
第一个客户机:pc01(IP:192.168.0.1)
第二个客户机:pc02(IP:192.168.0.2)
所有远程启动客户目录:/client
第一个远程启动客户机目录:/client/pc01
第二个远程启动客户机目录:/client/pc02
支持rsh
首先重新编译Linux内核。
make menuconfig
注意网络的支持,NFS-Root 支持,BootP(DHCP) 的支持必须包括在内。
make clean
make dep
make bzImage
make modules
make modules_install
以上命令之后,你会发现客户端启动的影像文件在 /usr/src/linux/i386/boot 目录中,编译出新内核之后,用 mknbi-linux(mknbi-linux bzImage vmlinuz.nb)处理,将vmlinuz.nb 放在/tftpboot下即可。
然后执行以下命令:mknod /dev/nfsroot b 0 255 修改启动设备,让其指向NFSRoot.
下面为远程客户机修改服务器,用于建立远程客户机的文件系统。
在服务器/etc/exports 中加入:
/client/pc01 192.168.0.1(rw, no_root_squash)
/client/pc02 192.168.0.2(rw, no_root_squash)
/home 192.168.0.1/255.255.255.0(rw,no_root_squash)
使用DHCP,在/etc/dhcpd.conf 加入对远程客户的支持,其中server地址是192.168.0.254:
# dhcpd.conf
# Global options
option domain-name "server.ustc.edu.cn";
option domain-name-servers 202.38.64.1;
# Intranet
subnet 192.168.0.0 netmask 255.255.255.0 {
range 192.168.0.1 192.168.0.250;
default-lease-time -1;
# option root-path "/client/pc01";
option dhcp-server-identifier 192.168.0.254;
option broadcast-address 192.168.0.255;
# option routers 198.168.0.254;
server-name "server";
next-server 192.168.0.254;
filename "/boot/vmlinuz";
host pc01{
option root-path "/client/pc01";
hardware ethernet 00:01:02:96:65:92;
fixed-address 192.168.0.1;
}
host pc02{
option root-path "/client/pc02";
hardware ethernet 00:01:02:98:92:55;
fixed-address 192.168.0.2;
}
}
subnet 202.38.64.0 netmask 255.255.255.0 {
}
请参阅:DHCP-Howto
在服务器上建立远程客户机目录:
/client
/client/pc01
/client/pc02
下面说一下pc01的做法.
pc01目录下包括:bin,dev,etc,home,lib,mnt,proc,root,sbin,tmp,usr,var目录。
我们是把bin,dev,etc,lib,sbin,usr,var直接完全复制过来,home,mnt,proc,root,tmp是新建的空目录,(当时是重新安装了一个包括DHCP,NFS,RSH等支持的尽量小、尽量干净的Linux,然后完全将它们完全复制过来,这样一来必然有很多不必要的东西可以删除,可惜现在水平不照,按参考文献做不成功,只好用了这种省事的法子:(,等以后慢慢删除不必要的文件)
注意必须修改/client/pc01/etc/rc.d 启动文件:改 mount -avt nonfs 为 mount -av.允许使用NFS Root文件系统。(我们的是Debian Woody,这个文件变为了/client/pc01/etc/init.d/mountall.sh,并且我们的是mount -a -t noproc,nosmbfs )
以如下格式修改/client/pc01/etc/fstab文件:
192.168.0.254:/client/pc01 / nfs defaults,rw 0 0
192.168.0.254:/home /home nfs rw,bg 0 0
proc /proc proc defaults 0 0
修改client/pc01/etc/hostname:
pc01
修改client/pc01/etc/hosts:
127.0.0.1 localhost
192.168.0.254 pc00
192.168.0.1 pc01
192.168.0.2 pc02
修改client/pc01/etc/hosts.equiv:
+
server
pc01
pc02
修改client/pc01/etc/mtab:
192.168.0.254:/client/pc01 / nfs rw 0 0
proc /proc proc rw 0 0
devpts /dev/pts devpts rw,gid=5,mode=620 0 0
192.168.0.254:/home /home nfs rw,bg,addr=192.168.0.254 0 0
修改client/pc01/etc/network/interfaces
face eth0 inet static
address 192.168.0.1
netmask 255.255.255.0
network 192.168.0.0
broadcast 192.168.0.255
gateway 192.168.0.254
接下来必须建立一个链,将远程客户机的IP地址链接到/client/pc01目录。
$:ln -s pc01 192.168.0.1
做pc02则可以复制pc01过来,并将上述几个文件修改一下.
下面在个人目录下设置rsh支持:
home/username/.rhosts
192.168.0.254 username
192.168.0.1 username
192.168.0.2 username
最后请确认服务器上的nfsd,tftpd 和 bootpd daemons是否启动。
一切完事!远程启动很快十秒钟左右就可享用Linux.
关于NFS,TFTP,BOOTP(DHCP)的设置请参阅How-to.
一点经验之谈, 最好把client的所有文件放在一个独立分区里面,这样就可以在这给分区里装上一个基本的系统(就像普通的安装一样).然后作为修改的基础(建议使用Debian,比较易于裁剪). 如果以后需要在客户端安装什么软件的话,可以这样做:
chroot /client/pc01
dselect或者apt -get