📄 1565.html
字号:
<HTML><HEAD><TITLE>
linux知识宝库/samba/第5章局域网服务器</TITLE>
<META http-equiv=content-type content="text/html; charset=gb2312">
<META content=linuxtips,linux,php,mysql,apache name=keywords>
<STYLE type=text/css>A:link {
COLOR: #666666; TEXT-DECORATION: underline
}
A:active {
COLOR: #666666; TEXT-DECORATION: underline
}
A:visited {
COLOR: #666666; TEXT-DECORATION: underline
}
A:hover {
COLOR: #708090; TEXT-DECORATION: none
}
.articletitle {
FONT-WEIGHT: bold; FONT-SIZE: 18px; COLOR: #335588; LINE-HEIGHT: 26px; FONT-FAMILY: trebuchet ms, arial, verdana, helvetica, sans-serif; TEXT-DECORATION: none
}
INPUT {
FONT-WEIGHT: normal; FONT-SIZE: 11px; FONT-FAMILY: verdana, arial, helvetica, sans-serif,宋体
}
TEXTAREA {
FONT-WEIGHT: normal; FONT-SIZE: 11px; FONT-FAMILY: verdana, arial, helvetica, sans-serif,宋体
}
.bginput {
BORDER-RIGHT: #999999 1px solid; BORDER-TOP: #999999 1px solid; FONT-SIZE: 8pt; BORDER-LEFT: #999999 1px solid; BORDER-BOTTOM: #999999 1px solid; FONT-FAMILY: Verdana, Arial, Helvetica, sans-serif; BACKGROUND-COLOR: #f9f9f9
}
.text {
BORDER-RIGHT: #cccccc 1px solid; BORDER-TOP: #666666 1px solid; BORDER-LEFT: #666666 1px solid; BORDER-BOTTOM: #cccccc 1px solid
}
SELECT {
FONT-WEIGHT: normal; FONT-SIZE: 12px; COLOR: #000000; FONT-FAMILY: 宋体; BACKGROUND-COLOR: #ffffff
}
.firstalt {
BACKGROUND-COLOR: #eeeeee
}
.secondalt {
BACKGROUND-COLOR: #ffffff
}
.bigfont {
FONT-SIZE: 45px; FONT-FAMILY: verdana, arial, helvetica, sans-serif,宋体
}
.normalfont {
FONT-SIZE: 12px; FONT-FAMILY: verdana, arial, helvetica, sans-serif,宋体
}
.middlefont {
FONT-SIZE: 11px; FONT-FAMILY: verdana, arial, helvetica, sans-serif,宋体
}
.smallfont {
FONT-SIZE: 9px; FONT-FAMILY: verdana, arial, helvetica, sans-serif,宋体
}
.smallbold {
FONT-WEIGHT: bold; COLOR: #000000
}
.articletitle {
FONT-WEIGHT: bold; FONT-SIZE: 18px; FONT-FAMILY: verdana, arial, helvetica, sans-serif,宋体
}
.subhead {
FONT-WEIGHT: bold; FONT-SIZE: 13px; COLOR: #006699; FONT-FAMILY: verdana, arial, helvetica, sans-serif,宋体
}
#content A:link {
COLOR: #3366cc; TEXT-DECORATION: underline
}
#content A:active {
COLOR: #3366cc; TEXT-DECORATION: underline
}
#content A:visited {
COLOR: #3366cc; TEXT-DECORATION: underline
}
#content A:hover {
COLOR: #9966cc; TEXT-DECORATION: none
}
.content {
FONT-SIZE: 14px; LINE-HEIGHT: 130%; FONT-FAMILY: verdana, arial, helvetica, sans-serif,宋体
}
.titlefont {
FONT-SIZE: 12px; COLOR: #ffffff; FONT-FAMILY: verdana, arial, helvetica, sans-serif,宋体
}
.bodyline {
BORDER-RIGHT: #aebdc4 1px solid; BORDER-TOP: #aebdc4 1px solid; BORDER-LEFT: #aebdc4 1px solid; BORDER-BOTTOM: #aebdc4 1px solid; BACKGROUND-COLOR: #ffffff
}
.cattitle {
FONT-WEIGHT: bold; FONT-SIZE: 12px; COLOR: #000000; LETTER-SPACING: 1px
}
.tableoutline {
BORDER-RIGHT: #c4c4c4 1px solid; BORDER-TOP: #c4c4c4 1px solid; BORDER-LEFT: #c4c4c4 1px solid; BORDER-BOTTOM: #c4c4c4 1px solid
}
.root_td {
PADDING-LEFT: 5px; FONT-WEIGHT: bold; FONT-SIZE: 12px; FONT-FAMILY: Verdana; HEIGHT: 22px; BACKGROUND-COLOR: #ffffff; font-color: #000000
}
.child_td {
PADDING-RIGHT: 10px; PADDING-LEFT: 10px; FONT-SIZE: 12px; PADDING-BOTTOM: 3px; COLOR: #000000; FONT-FAMILY: Verdana; HEIGHT: 22px; BACKGROUND-COLOR: #f5f5f5; TEXT-DECORATION: underline
}
#cattitle A:link {
COLOR: #000000; TEXT-DECORATION: none
}
#cattitle A:visited {
COLOR: #000000; TEXT-DECORATION: none
}
#cattitle A:active {
COLOR: #000000; TEXT-DECORATION: none
}
#cattitle A:hover {
COLOR: #000000; TEXT-DECORATION: none
}
</STYLE>
<SCRIPT language=JavaScript type=text/javascript>
<!--
if (parent.frames.length > 0) {
parent.location.href = self.document.location
}
function ToggleNode(nodeObject, imgObject){
if(nodeObject.style.display == '' || nodeObject.style.display == 'inline'){
nodeObject.style.display = 'none';
imgObject.src = 'images/plus.gif'/*tpa=http://www.linuxhero.com/docs/images/plus.gif*/;
}else{
nodeObject.style.display = 'inline';
imgObject.src = 'images/minus.gif'/*tpa=http://www.linuxhero.com/docs/images/minus.gif*/;
}
}
-->
</SCRIPT>
<BODY text=#000000 bgColor=#ffffff leftMargin=0 topMargin=0 marginwidth="0"
marginheight="0">
<CENTER>
<TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
<TR>
<TD vAlign=top>
<TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
<TBODY>
<TR>
<TD><IMG height=1 src="images/spacer.gif" tppabs="http://www.linuxhero.com/docs/images/spacer.gif" width=296
border=0></TD>
<TD><IMG height=1 src="images/spacer.gif" tppabs="http://www.linuxhero.com/docs/images/spacer.gif" width=76
border=0></TD>
<TD><IMG height=1 src="images/spacer.gif" tppabs="http://www.linuxhero.com/docs/images/spacer.gif" width=100
border=0></TD>
<TD><IMG height=1 src="images/spacer.gif" tppabs="http://www.linuxhero.com/docs/images/spacer.gif" width=98
border=0></TD>
<TD><IMG height=1 src="images/spacer.gif" tppabs="http://www.linuxhero.com/docs/images/spacer.gif" width=79
border=0></TD>
<TD><IMG height=1 src="images/spacer.gif" tppabs="http://www.linuxhero.com/docs/images/spacer.gif" width=103
border=0></TD>
<TD><IMG height=1 src="images/spacer.gif" tppabs="http://www.linuxhero.com/docs/images/spacer.gif" width=26
border=0></TD>
<TD><IMG height=1 src="images/spacer.gif" tppabs="http://www.linuxhero.com/docs/images/spacer.gif" width=1
border=0></TD></TR>
<TR>
<TD colSpan=3><A title=linux知识宝库
href="index.html" tppabs="http://www.linuxhero.com/docs/index.html"><IMG height=83
src="images/header_r1_c1.gif" tppabs="http://www.linuxhero.com/docs/images/header_r1_c1.gif" width=472 border=0
name=header_r1_c1></A></TD>
<TD colSpan=3>
<form action="http://www.linuxhero.com/docs/search.html" method=get>
<table
style="BORDER-RIGHT: #c4c4c4 1px solid; BORDER-TOP: #c4c4c4 1px solid; BORDER-LEFT: #c4c4c4 1px solid; BORDER-BOTTOM: #c4c4c4 1px solid"
cellspacing=0 cellpadding=3 width="95%" border=0 align="center">
<tbody>
<tr>
<td noWrap background="images/bgline.gif" tppabs="http://www.linuxhero.com/docs/images/bgline.gif">
<div align=center><font class=normalfont>搜索文章:
<input type=hidden value=result name=action2>
<input type=radio checked value=title name=type>标题
<input type=radio value=content name=type>内容
<input type=image src="images/button_go.gif" tppabs="http://www.linuxhero.com/docs/images/button_go.gif" border=0 name=image2>
</font></div>
</td>
</tr>
<tr>
<td noWrap>
<div align="center">
<input maxlength=100 size=30 name=keyword2>
</div>
</td>
</tr></tbody>
</table>
</form>
</TD>
<TD rowSpan=2><IMG src="images/header_r1_c7.gif" tppabs="http://www.linuxhero.com/docs/images/header_r1_c7.gif" width=26 border=0 name=header_r1_c7></TD>
<TD><IMG height=83 src="images/spacer.gif" tppabs="http://www.linuxhero.com/docs/images/spacer.gif" width=1 border=0></TD></TR>
<TR>
<TD background="images/bgline.gif" tppabs="http://www.linuxhero.com/docs/images/bgline.gif"><IMG height=22
src="images/header_r2_c1.gif" tppabs="http://www.linuxhero.com/docs/images/header_r2_c1.gif" width=296 border=0
name=header_r2_c1></TD>
<TD background="images/bgline.gif" tppabs="http://www.linuxhero.com/docs/images/bgline.gif" colSpan=5>
<DIV align=right><FONT class=normalfont>当前位置:
<A href="index.html" tppabs="http://www.linuxhero.com/docs/index.html">本站首页</A>
<font color="#FF6699">>></font>
<A href="type23.html" tppabs="http://www.linuxhero.com/docs/type23.html">samba</A> | <A href="copyright.html" tppabs="http://www.linuxhero.com/docs/copyright.html">版权说明</A></font></DIV>
</TD>
<TD><IMG height=22 src="images/spacer.gif" tppabs="http://www.linuxhero.com/docs/images/spacer.gif" width=1
border=0></TD></TR></TBODY></TABLE>
<TABLE cellSpacing=10 cellPadding=0 width="100%" bgColor=#ffffff
border=0>
<TR>
<TD>
<TABLE cellSpacing=0 cellPadding=3 width="100%" border=0>
<TR>
<TD vAlign=top align=middle width="60%">
<TABLE cellSpacing=0 cellPadding=0 width="100%"
background="images/back.gif" tppabs="http://www.linuxhero.com/docs/images/back.gif" border=0>
<TBODY>
<TR>
<TD vAlign=top width="80%">
<DIV align=center>
<FORM action="search.html" tppabs="http://www.linuxhero.com/docs/search.html" method=get>
</FORM>
<TABLE cellSpacing=0 cellPadding=0 width="95%"
border=0><TBODY>
<TR>
<TD background="images/bgi.gif" tppabs="http://www.linuxhero.com/docs/images/bgi.gif"
height=30></TD></TR></TBODY></TABLE>
<TABLE cellSpacing=0 cellPadding=3 width="95%"
align=center border=0>
<TBODY>
<TR>
<TD>
<TABLE cellSpacing=0 cellPadding=3 width="100%"
border=0>
<TBODY>
<TR>
<TD vAlign=top>
<p><FONT class=normalfont><B><font color=blue>第5章局域网服务器</font></B></FONT><BR><FONT class=smallfont color=#ff9900>2004-04-23 15:18 pm</FONT><BR><FONT class=normalfont>作者:作者<br>来自:Linux知识宝库<br>联系方式:无名<br><br>本章要点:<br>
<br>
本章介绍如何将Linux机器配置称为局域网上的文件/打印服务器或者计算服务器,同<br>
时也介绍可能出现的问题以及解决方法。<br>
<br>
本章具体包括以下内容。<br>
<br>
NFS文件服务<br>
<br>
BSD打印服务器<br>
<br>
Samba文件/打印服务<br>
<br>
WINS、DHCP和NIS<br>
<br>
图形/计算服务器<br>
<br>
5.1 NFS和文件/打印服务<br>
<br>
NFS是Sun发明的用来在UNIX系统之间共享文件的一种服务协议,事实上,如果你的系<br>
统中不是有很多的UNIX机器,我们并不建议使用NFS。因为在windows 95上访问NFS相当<br>
困难。但是,如果你的系统中包含Sun或者SCO这样的UNIX系统,也许你除了使用NFS以外<br>
别无选择。<br>
<br>
5.1.1 共享文件系统<br>
<br>
NFS实际就是将某个UNIX机器的一个目录共享出来,由其他机器直接使用。共享的动作<br>
称为“输出”(export)。例如,host1机器的mydoc目录可以被输出,然后host2机器的管<br>
理员将它连接到/host1/mydoc目录下,以后host2对这个目录的操作自动转化为对host1<br>
上相应目录的操作。技术上,通常用UDP协议来实现NFS的数据传输。<br>
<br>
首先我们需要来制作一个NFS服务器,由于NFS要依赖于远程过程调用(RPC),所以服<br>
务器上必须启动SUNRPC服务,这个服务的另一个名字是port mapper,在目前版本中的L<br>
inux里面,用portmap程序来启动SUNRPC服务:<br>
<br>
$ /sbin/portmap<br>
<br>
尽管不通过tcpd程序,但是port mapper是基于一个类似的程序tcp wrapper的运行库<br>
,所以也可以使用host.deny和host.allow程序来限制访问。另外,通常portmap使用的端<br>
口在/etc/services里面定义。<br>
<br>
为了使用NFS服务,需要启动mountd和nfsd程序,这两个程序在Linux中被称为rpc.mo<br>
untd和rpc.nfsd:<br>
<br>
$/usr/sbin/rpc.mountd<br>
<br>
$/usr/sbin/rpc.nfsd<br>
<br>
其中,rpc.nfsd程序支持一个数字参数,用来表示启动nfsd程序的个数,例如:<br>
<br>
$rpc.nfsd 7<br>
<br>
$ps ax|grep nfsd<br>
<br>
606 pts/0 SW 0:00 [nfsd]<br>
<br>
607 pts/0 SW 0:00 [nfsd]<br>
<br>
608 pts/0 SW 0:00 [nfsd]<br>
<br>
609 pts/0 SW 0:00 [nfsd]<br>
<br>
610 pts/0 SW 0:00 [nfsd]<br>
<br>
611 pts/0 SW 0:00 [nfsd]<br>
<br>
612 pts/0 SW 0:00 [nfsd]<br>
<br>
由于NFS是基于无连接的UDP服务,所以nfsd程序不得不在端口上等待并且处理,当nf<br>
s访问比较多的时候,增加nfsd程序的个数会有助于提高NFS的工作效率(因为避免了线<br>
程阻塞),但是太多的nfsd程序又可能会影响CPU的处理速度。正确的数值只有自己实验<br>
得到,不过,对于一般的系统,10-20个nfsd程序应该可以工作的很好。<br>
<br>
另外一个需要注意的是,按照Sun的定义,NFS是无状态的,有时这一点很讨厌,特别<br>
是有可能发生文件访问的冲突,为此,Linux提供nfs lock功能,对NFS访问进行监控,<br>
可以用rpc.lockd和rpc.statd程序来执行这个功能:<br>
<br>
$/sbin/rpc.lockd<br>
<br>
$/sbin/rpc.statd<br>
<br>
要想在启动的时候自动使用NFS服务,可以按照我们以前介绍的那样,编辑相应的启动<br>
脚本,不过,有些Linux系统提供了设置程序,最常用的是NTSYSV程序,如redhat和TLC<br>
都提供了这个程序:<br>
<br>
$/usr/sbin/ntsysv<br>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -