跳转到主内容

硬挂载与软挂载之间的区别是什么

Views:
510
Visibility:
Public
Votes:
3
Category:
ontap-9
Specialty:
nas
Last Updated:

适用场景

  • NFS 
  • NAS 协议

问题解答

硬挂载与软挂载有何区别?

使用NFS协议、NFS客户端可以挂载NFS服务器上的现有文件系统、就像本地文件系统一样。

例如、您可以按如下所示将host.server.com的"/home"目录挂载到客户端计算机:

# mount host.server.com:/home /mymountpoint

“/mymountpoint” 应在计算机中创建目录以存放NFS分区。
硬挂载或软挂载选项用于定义NFS客户端应如何处理NFS服务器崩溃/故障。

硬挂载:

硬挂载通常用于块资源、例如本地磁盘或SAN。如果NFS文件系统挂载为硬挂载、则会重复发出影响所挂载资源任何部分的NFS请求、直到满足此请求为止(例如、服务器崩溃并稍后恢复)。服务器恢复联机后、程序将继续从服务器崩溃期间的状态执行、而不会受到影响。我们可以使用挂载选项"intr (intr)"、如果服务器发生故障或无法访问、则可以中断NFS请求。因此、建议的设置为hard和intr选项。

优势

  • 如果连接丢失、则所有NFS客户端都会冻结、直到NFS服务器恢复联机为止。因此、不会丢失数据。
  • 数据完整性和消息传送得到保障。

缺点

  • 持续连接可能会影响性能。

用于从挂载点/mymountpoint上的远程计算机host.server.com硬挂载目录/home的命令。rw—用于挂载要读写的资源、并用于intr—用于启用键盘中断。 

mount -o rw,hard,intr host.server.com/home /mymountpoint

软挂载:

软挂载通常用于NFS或CIFS等网络文件协议。如果NFS文件系统挂载是软挂载、则程序或应用程序会从NFS文件系统请求文件、NFS客户端守护进程将尝试从NFS服务器检索数据。NFS会反复尝试与服务器联系、直到:

  • 已建立连接
  • 已达到NFS重试阈值
  • 已达到nfstimeout值

如果发生其中一个事件、control将返回到调用程序。
但是、如果由于NFS服务器发生任何崩溃、超时或故障而无法从NFS服务器获得任何响应、NFS客户端将向客户端计算机上请求文件访问的进程报告错误、然后退出。

优势

  • 这种机制的优势是"快速响应"、因为它不会等待NFS服务器做出响应。
  • 如果NFS服务器不可用、则内核会在经过预先配置的时间段后超时I/O操作。

缺点:

  • 缺点是、如果NFS驱动程序缓存数据且软挂载超时、应用程序可能无法知道哪些对NFS卷的写入操作实际提交到磁盘。
  • 数据损坏或数据丢失。

用于从挂载点/mymountpoint上的远程计算机host.server.com软挂载的命令

mount -o rw,soft host.server.com/home /mymountpoint

要检查系统上当前存在的挂载类型、请执行以下操作:

[usero1@Linux01 ~]$ nfsstat -m

/home from vrouter:/home
Flags: rw,relatime,vers=4.1,rsize=262144,wsize=262144,namlen=255,hard,proto=tcp,port=0,timeo=600,retrans=2,sec=sys,clientaddr= 10.0.0.1,local_lock=none,addr=10.0.0.2
/mnt/test from svm-data-lif1:/vol_unix
Flags: rw,relatime,vers=4.0,rsize=65536,wsize=65536,namlen=255,hard,proto=tcp,port=0,timeo=600,retrans=2,sec=sys,clientaddr= 10.0.0.1,local_lock=none,addr=10.0.0.2

追加信息

附加信息 _text

 

NetApp provides no representations or warranties regarding the accuracy or reliability or serviceability of any information or recommendations provided in this publication or with respect to any results that may be obtained by the use of the information or observance of any recommendations provided herein. The information in this document is distributed AS IS and the use of this information or the implementation of any recommendations or techniques herein is a customer's responsibility and depends on the customer's ability to evaluate and integrate them into the customer's operational environment. This document and the information contained herein may be used solely in connection with the NetApp products discussed in this document.