nfs做server和做client的用法,我都测试过,没有问题
发表于:2007-06-09来源:作者:点击数:
标签:
[这个贴子最后由南非蜘蛛在2002/12/1707:30pm编辑] nfs的用法,因为我经常用,所有就总结出来了,希望对你有帮助 freebsd和solaris的我都用过,互相mount和share都没有问题, linux 我没有用过,谁用过就贴出来吧 作者:南非蜘蛛zhedou@sohu.com 个人主页:htt
[这个贴子最后由南非蜘蛛在 2002/12/17 07:30pm 编辑]
nfs的用法,因为我经常用,所有就总结出来了,希望对你有帮助
freebsd和solaris的我都用过,互相mount和share都没有问题,
linux我没有用过,谁用过就贴出来吧
作者:南非蜘蛛 zhedou@sohu.com
个人主页:http://www.douzhe.com
转载请保留作者信息
(一)solaris
做server
1:基本运行程序是/etc/init.d/rpc和/etc/init.d/nfs.server
启动服务
/etc/rc3.d/S15nfs.server start
S15nfs.server包含了rpc和nfs.server,还有日志等一些其它有用的程序.建议用S15nfs.server启动nfs的server端
要是想每次从起后都运行,保证S15nfs.server在/etc/rc3.d目录下
2:共享目录
vi /etc/dfs/dfstab文件中有共享条目,这些共享目录会在守护进程启动时自动共享。
这些进程在系统进入运行级别2时自动运行。
挂接远程网络文件系统
# share -F nfs -o rw=engineering -d "home dirs" /export/home2
例如:share -F nfs -o ro=202.108.42.90:202.108.42.91 /home2
share -F nfs -o ro=@202.108.42.0/24 /home2
-o specific_options
The specific_options are used to control a
clearcase/" target="_blank" >ccess of the
shared resource. (See share_nfs(1M) for the NFS
specific options.) They may be any of the following:
rw pathname is shared read/write to all clients.
This is also the default behavior.
rw=client[:client]... 或一个网段 rw=@202.108.42.0/24
pathname is shared read/write only to the listed
clients. No other systems can access pathname.
ro pathname is shared read-only to all clients.
ro=client[:client]... 或一个网段 rw=@202.108.42.0/24
pathname is shared read-only only to the listed
clients. No other systems can access pathname.
-d description
The -d flag may be used to provide a description of
the resource being shared.
dfshares命令
用以查看服务器的共享资源
dfmounts命令
服务器上查看共享资源被利用的状况
用nfsstat看nfs的全部状态
做client
1:基本运行程序是/usr/lib/nfs/statd和/usr/lib/nfs/lockd
启动服务
/etc/rc3.d/S73nfs.client start
S73nfs.lient包含了statd和lockd,还有日志等一些其它有用的程序.建议用S73nfs.client启动nfs的client端
要是想每次从起后都运行,保证S73nfs.client在/etc/rc2.d目录下
(二)freebsd
做server,系统至少要运行nfsd和mountd守护进程,一运行nfsd,mountd会自动运行
1: vi /etc/rc.conf
portmap_enable="YES"
nfs_server_enable="YES"
mountd_flags="-r" (mountd runs automatically whenever the NFS server is enabled.)
2: 设置共享目录
# cat /etc/exports
/home/tommy -ro -maproot=root -network 202.108.44.0
目录的访问限制中具有多种选项,这些选项对于保证NFS的
安全性相当重要。
-ro---以只读形式输出文件系统,远程客户只能读不能写这个目录
-maproot---将客户机上的root用户映射为服务器中的某个用户和族,也可以使用UID 和GID的形式,如maproot=root,maproot=10,或maproot=10:1。这个设置选项可以用来保护服务器上的文件系统不被客户中的使用者非法访问。
-mapall---将客户上的所有用户都映射为本机的某个用户,使用形式与maproot相同。它同样也是用于保护服务器文件系统的安全性的。
-alldirs---允许安装该目录下的所有子目录。
-network---允许一定网络上的计算机可以装载这个文件系统。
-mask---用于修订 network中的网络号使用的缺省掩码,可定义对网络的一部分开放文件系统。
当更改了exports文件之后,需要向mountd发送SIGHUP信号,使其重读exports文件的内容。
要是改变了共享目录,就要运行
# kill -HUP `cat /var/run/mountd.pid`
查看共享目录
# showmount -e ip
做client
vi /etc/rc.conf:
nfs_client_enable="YES"
(三)linux
做server
控制网络文件系统输出的配置文件是/etc/exports。它的格式是:
directory hostname(options)
其中(options)是可选的。举个例子:
/mnt/export speedy.redhat.com
将允许主机speedy.redhat.com安装/mnt/export 而
/mnt/export speedy.redhat.com(ro)
则仅仅允许speedy以只读方式安装/mnt/export。
每当您改变了/etc/exports,您需要告诉NFS进程重新检查配置信息。一个简单的方法是 停下再启动该服务器进程:
/etc/rc.d/init.d/nfs stop
/etc/rc.d/init.d/nfs start
还有一种方法:
killall -HUP rpc.nfsd rpc.mountd
请查看nfsd(8),mountd(8) 和exports(5)的man 手册以获得详细信息 。
做client
cybermoon 回复于:2002-08-22 21:28:30
|
In solaris the startup scripts for level 3 can not be under
/etc/rc3.d/backup/
it should be /etc/rc3.d/
|
littletiger 回复于:2002-08-22 23:24:07
|
好东西 我喜欢 斑竹辛苦
|
josephxd 回复于:2002-08-23 08:11:24
|
這是蜘蛛的見面禮吧.
|
study12 回复于:2002-08-23 08:28:44
|
第一次看到蜘蛛写东西。我个人认为很好,很实用。使哪些对UNIX似懂非懂的人可以上一个台阶。
|
ultra-guest 回复于:2002-08-23 08:44:00
|
置顶。
|
aaron2002 回复于:2002-08-23 09:45:41
|
真是好人,我正需要这方面的东西呢,谢谢啦!
|
南非蜘蛛 回复于:2002-08-23 11:40:41
|
[quote][b]下面引用由[u]cybermoon[/u]在 [i]2002/08/22 09:28pm[/i] 发表的内容:[/b] In solaris the startup scripts for level 3 can not be under /etc/rc3.d/backup/ it should be /etc/rc3.d/ [/quote] 不好意思,是写错了,因为我把rc3.d没有用的东西都放到/etc/rc3.d/backup下了,所以就顺手贴上了,应该是在 /etc/rc3.d下
|
amiao 回复于:2002-09-06 14:39:24
|
我又上了一个台阶,呵呵
|
南非蜘蛛 回复于:2002-09-06 14:41:39
|
[quote][b]下面引用由[u]amiao[/u]在 [i]2002/09/06 02:39pm[/i] 发表的内容:[/b] 我又上了一个台阶,呵呵 [/quote] 你都已经那么厉害了,还要上台阶呀:)
|
amiao 回复于:2002-09-06 14:44:07
|
开玩笑,我什么都不懂的。
那光明使者是灌水得来的。
|
原文转自:http://www.ltesting.net