Linux
下
nfs
文件共享方式和实现的方法。
 
    1
、首先要开启
portmap
和
nfs
服务。
 
     service portmap start 
     service nfs start 
    2
、查看服务是否开启。
 
     netstat -ntpl 
    3
、修改
 /etc/exports 
     vi /etc/exports 
    #/home/temp *(rw,sync,no_root_squash,all_squash) 
#/home/temp *(ro,sync,no_root_squash,all_squash)  
(/home/temp 
表示要被共享的目录)
 
#/mnt/inst *(ro,sync) 
(
* 
表示任意地址)
 
rw
:
             
可读写的权限;
 
ro
:
             
只读的权限;
 
no_root_squash
:
 
登入到
NFS
主机的用户如果是
ROOT
用户,他就拥有
ROOT
的权限
root_squash
:
     
在登入
 NFS 
主机使用目录的使用者如果是
 root 
时,那么这个使用者
的权限将被压缩成为匿名使用者,通常他的
 UID 
与
 GID 
都会变成
 nobody 
那个身份;
 
all_squash
:
     
不管登陆
NFS
主机的用户是什么都会被重新设定为
nobody
。
 
anonuid
:
        
将登入
NFS
主机的用户都设定成指定的
user id,
此
ID
必须存在于
/etc/passwd
中。
 
anongid
:
        
同
 anonuid 
,但是变成
 group ID 
就是了!
 
sync
:
           
资料同步写入存储器中。
 
async
:
          
资料会先暂时存放在内存中,不会直接写入硬盘。
 
insecure         
允许从这台机器过来的非授权访问。
 
    4
、
exportfs -a
 (
导出所有共享的目录
) 
    5
、
showmount -e
 127.0.0.1 (
查被共享的目录
) 
     Export list for 127.0.0.1: 
    /mnt/inst * 
    /home/temp * 
 
 
    6
、在客户端输入所需要的共享文件。
 
mount -t nfs 192.168.111.1:/mnt/inst  /mnt/inst 
(mount
服务器上的共享目录)
 
    7
、在客户端使用
mount
命令,就可以看到刚才被
mount
的文件了。
 
    
这样简单的就是实现了文件共享