NFS网络文件系统自动和手动挂载



用于linux 和linux 之间或者linux和unix之间
将nfs服务器的共享文件夹挂载到客户端,使用协议RPC(远程进程调度)
  www.2cto.com  

NFS使用rpc
1.当服务器端的nfs和rpc 服务 启动后会形成很多进程:mountd ,nfs,nlockmgr,status进程。
2. 客户端有rpc.mountd ,rpciod , nlockmgr,status进程。
3.客户端需要挂载服务器端的文件,使用rpc.mountd进程项服务器的portmapper 发送请求连接。
4.服务器端的portmapper 收到请求后,向客户端回应,同时告诉客户端使用哪个端口与服务器相连。
5.客户端使用rpc.mountd 请求服务器端进程mountd,进行挂载。
6.挂载完毕后,客户端使用进程rpciod 调用服务端的nfs进程,进行磁盘io操作。
7.两端都调用nlockmgr锁机制,当服务器端在编写文档时,禁止客户端的访问。
8. 为了维持连接,两端都使用status进程。
  www.2cto.com  
查看本机nfs
[root@localhost ~]# rpm -qa |grep nfs
nfs-utils-lib-1.0.8-7.6.el5
nfs-utils-1.0.9-42.el5
[root@localhost ~]# service nfs start 启动
查看自己进程:
[root@localhost ~]# mkdir /public 建立文件夹
[root@localhost ~]# cd /public
[root@localhost public]# touch fi.txt
[root@localhost ~]# vi /etc/exports 编辑
[root@localhost ~]# service nfs restart

另打开一台linux虚拟机:地址为192.168.145.200
[root@localhost ~]# rpcinfo -p 192.168.145.100
[root@localhost ~]# showmount -e 192.168.145.100 查看145.100上的共享文件
Export list for 192.168.145.100:
/public *
[root@localhost ~]#
将192.168.145.100上的共享文件挂载到自己的/mnt/public/上
[root@localhost ~]# mount 192.168.145.100:/public /mnt/public
在客户端上(192.168.145.200)实现自动挂载;
[root@localhost ~]# vi /etc/fstab
加入以下内容
192.168.145.100:/public /mnt/public nfs defaults,soft,intr 0 0
[root@localhost public]# pwd
/mnt/public
因为这时就在挂载目录上/mnt/public/所以就卸载不了了。
可以这样做:
[root@localhost public]# fuser -v /mnt/public

USER  PID ACCESS COMMAND
/mnt/public: root 4602 ..c.. bash

[root@localhost public]# fuser -kv /mnt/public
敲完之后直接跳出来,然后再进去执行
发现卸掉了
 
下面实现控制时间挂载:
[root@localhost ~]# umount /mnt/public
进入/etc/fstab把里面加的内容删除了。
编辑/etc/auto.master文件可以借助命令chkconfig –list |grep auto来查看帮助文档
[root@localhost ~]# cd /etc
[root@localhost etc]# ls auto*
autofs_ldap_auth.conf auto.master auto.misc auto.net auto.smb
[root@localhost etc]# cp auto.misc auto.nf
[root@localhost etc]# vi auto.nfs 编辑
添加以下内容:
[root@localhost etc]# service autofs restart 重启服务
Stopping automount:  [ OK ]
Starting automount:  [ OK ]
[root@localhost etc]#
 
查看挂载上了:
等一分钟后在查看发现没有了:
 
 

相关内容

    暂无相关文章