返回NFS主页【Server Manager——>File and Storage Services——>Shares】
在共享【SHARES】框中可以看到已经存在了存储阵列。
在数据卷【VOLUME】框中可以看到刚才创建的NFS共享数据卷F:
打开【Control Panel】——>【Programs】——>【Programs and Features】——>【Turn Windows features on or off】——>【Service for NFS】,将两个选项都勾选,最后点击【OK】。
打开cmd(不要用powershell),输入
mount.exe 172.16.1.10:/WIN-NFS F:
mount <IP_ADDRESS><PATH_TO_DIR>\ drive:
输入mount.exe命令验证挂载成功。
通过【VMware vSphere Client】/ 【VMware Host Client】新建数据存储,选择NFS类型。
在Windows Server 2019上,使用的是NFS 4.1+(存在Kerberos身份验证),因此可以选择NFS 4.1版本。
完成后,可以看到WIN-NFS已经成功挂载到vSphere Client中。
进入WIN-NFS存储中查看ESXi主机,可以看到有三台ESXi主机挂载了NFS共享存储。
在配置NFS服务端和连接客户端过程中,我遇到了一个很特别的错误。
在ESXi上的报错信息是
vmkwarning.log
2022-08-25T06:39:38.713Z cpu7:524856)WARNING: NFS: 220: Got error 2 from mount call
2022-08-25T06:41:09.835Z cpu6:524856)WARNING: NFS: 220: Got error 2 from mount call
2022-08-25T06:45:05.085Z cpu6:524856)WARNING: NFS: 220: Got error 2 from mount call
2022-08-25T06:54:03.520Z cpu5:527930 opID=b65e32ed)WARNING: NFS41: NFS41FSGetStaticAttributes:3351: NFS41_ProcGetAttrProcess failed: Permission denied
2022-08-25T06:54:03.520Z cpu5:527930 opID=b65e32ed)WARNING: NFS41: NFS41FSGetAttributes:3387: Failed to get static FS attributes for volume Datastore: Permission denied
2022-08-25T06:54:03.520Z cpu5:527930 opID=b65e32ed)WARNING: NFS41: NFS41FSCompleteMount:3957: NFS41FSGetAttributes failed: Permission denied
2022-08-25T06:54:03.520Z cpu5:527930 opID=b65e32ed)WARNING: NFS41: NFS41FSDoMount:4584: First attempt to mount the filesystem failed: Permission denied
2022-08-25T06:54:03.520Z cpu5:527930 opID=b65e32ed)WARNING: NFS41: NFS41_FSMount:4888: NFS41FSDoMount failed: Permission denied
2022-08-25T06:54:03.520Z cpu5:527930 opID=b65e32ed)WARNING: NFS41: NFS41_VSIMountSet:413: NFS41_FSMount failed: Permission denied
hostd.log
2022-08-25T09:02:41.047Z info hostd[526909] [Originator@6876 sub=Vimsvc.ha-eventmgr] Event 454 : Restored connection to server 172.16.1.10 moun
2022-08-25T09:02:42.043Z info hostd[527319] [Originator@6876 sub=Hostsvc.DatastoreSystem] NfsClientUpdateInt: [N11HostdCommon17VmkernelUpdateNF
2022-08-25T09:02:42.043Z info hostd[526900] [Originator@6876 sub=Hostsvc.DatastoreSystem] StorageApdUpdateInt: Processing Storage APD msg [N11H
2022-08-25T09:02:42.044Z info hostd[527319] [Originator@6876 sub=Libs] Unable to connect to vaai-nasd socket [No such file or directory]
2022-08-25T09:02:42.044Z info hostd[526900] [Originator@6876 sub=Libs] Unable to connect to vaai-nasd socket [No such file or directory]
2022-08-25T09:02:42.047Z info hostd[527319] [Originator@6876 sub=Libs] SlowRefresh: path /vmfs/volumes/5a305530-b3516bb5-0000-000000000000 tota
2022-08-25T09:02:42.050Z info hostd[526900] [Originator@6876 sub=Libs] SlowRefresh: path /vmfs/volumes/5a305530-b3516bb5-0000-000000000000 tota
2022-08-25T09:02:42.050Z info hostd[527319] [Originator@6876 sub=Hostsvc.DatastoreSystem] NfsClientUpdateInt: [N11HostdCommon17VmkernelUpdateNF
2022-08-25T09:02:42.053Z info hostd[526900] [Originator@6876 sub=Libs] Unable to connect to vaai-nasd socket [No such file or directory]
2022-08-25T09:02:42.055Z info hostd[526900] [Originator@6876 sub=Libs] SlowRefresh: path /vmfs/volumes/5a305530-b3516bb5-0000-000000000000 tota
2022-08-25T09:02:42.057Z info hostd[526900] [Originator@6876 sub=Hostsvc.DatastoreSystem] StorageApdUpdateInt: Processing Storage APD msg [N11H
2022-08-25T09:02:42.058Z info hostd[526900] [Originator@6876 sub=Libs] Unable to connect to vaai-nasd socket [No such file or directory]
2022-08-25T09:02:42.061Z info hostd[526900] [Originator@6876 sub=Libs] SlowRefresh: path /vmfs/volumes/5a305530-b3516bb5-0000-000000000000 tota
2022-08-25T09:02:42.063Z info hostd[526900] [Originator@6876 sub=Libs] Unable to connect to vaai-nasd socket [No such file or directory]
2022-08-25T09:02:42.065Z info hostd[526900] [Originator@6876 sub=Libs] SlowRefresh: path /vmfs/volumes/5a305530-b3516bb5-0000-000000000000 tota
2022-08-25T09:02:44.677Z info hostd[527454] [Originator@6876 sub=Hostsvc.VmkVprobSource] VmkVprobSource::Post event: (vim.event.EventEx)
....
2022-08-25T09:05:37.730Z warning hostd[527452] [Originator@6876 sub=Libs] VmFileSystem: Slow refresh failed: Unable to get FS Attrs for /vmfs/volumes/5a305530-b3516bb5-0000-000000000000
2022-08-25T09:05:37.730Z warning hostd[527456] [Originator@6876 sub=Libs] VmFileSystem: Slow refresh failed: Cannot open volume: /vmfs/volumes/5a305530-b3516bb5-0000-000000000000
2022-08-25T09:05:37.736Z info hostd[527456] [Originator@6876 sub=Hostsvc.Datastore] CheckIfAccessibleChanged: Datastore 172.16.1.10:/WIN-NFS at path /vmfs/volumes/5a305530-b3516bb5-0000-000000000000 now has accessibility of false due to AllPathsDown_Start
2022-08-25T09:05:37.737Z verbose hostd[526902] [Originator@6876 sub=Vmsvc.vm:/vmfs/volumes/62fdb662-56b97c30-eb01-005056b4ca74/centos7/centos7.vmx] Got DSSYS change: [N11HostdCommon18DatastoreSystemMsgE:0x0000006fdfbbf800]DatastoreSystemMsg::DsChange{Type=UPDATE-NOW-DISCONNECTED, Msg=DatastoreAvailableMsg{DatastoreMsg{Type=2, MoId=172.16.1.10:/WIN-NFS, Path=/vmfs/volumes/5a305530-b3516bb5-0000-000000000000}}}; DatastoreSystemMsg::DsChange{Type=UPDATE_CAPACITY, Msg=DatastoreResizedMsg{DatastoreMsg{Type=2, MoId=172.16.1.10:/WIN-NFS, Path=/vmfs/volumes/5a305530-b3516bb5-0000-000000000000}, NewCap=0, OldCap=322104717312}};
2022-08-25T09:05:37.738Z info hostd[527319] [Originator@6876 sub=Vslmsvc.DatastoreStateListener] Datastore /vmfs/volumes/5a305530-b3516bb5-0000-000000000000/ has gone into disconnected stat
在vSphere Client上的报错信息是:
在结合GUI和CLI的日志信息后,我得到了两个重要的信息点:
主机配置过程中出错。 操作失败,诊断报告: Cannot open volume: /vmfs/volumes/a7d34684-788cb312
failed: Permission denied
由于博主在排错中反复试了好几次,所截取的a7d34684-788cb312的数值可能发生了变化,因为它是随机生成的。
使用自下而上的排错方法。
首先检查硬件,由于是虚拟环境,其它服务能正常运行,因此排除硬件问题。
其次是网络检查,因为NFS服务器中也部署了iSCSI服务,并能正常连接数据存储,所以底层网络是互通的(能ping通)。
接下来检查防火墙设置,先检查ESXi中的防火墙配置,确认无误后。在检查NFS服务器中的防火墙配置,确认无误。
第四,尝试使用命令行进行NFS共享存储挂载。先在VCSA Shell中进行mount,
mount -t nfs 172.16.1.10:/WIN-NFS /opt/winnfs/
对其映射目录进行访问,出现以下报错
但确实是挂载成功,只不过没有访问权限。此时使用 ls -l命令查看 /opt/winnfs目录的权限,结果显示为 777。
使用ESXi Shell挂载NFS存储,
esxcli storage nfs add -H 172.16.1.10 -s /WIN-NFS -v WIN-NFS-DATASTORE
查看NFS存储
esxcli storage nfs list
通过esxcli工具能正常挂载NFS,但在vSphere Client中无论怎么刷新或重新扫描数据存储,依然无法让其在vSphere Client中出现。
查看esxi磁盘使用情况。
df -h
得到错误信息。
又是同样的报错:Error getting data for filesystem on ‘/vmfs/volumes/a7d34684-788cb312’: Cannot open volume: /vmfs/volumes/a7d34684-788cb312, skipping.
在ESXi中/vmfs/volumes/目录是存放数据存储的映射目录,而类似a7d34684-788cb312的目录是NFS共享目录在ESXi上创建的软链接。
结合这些测试以及报错信息,我推测客户端可以正常连接NFS服务端,但无权访问目录,所以才会导致出现Cannot open volume和Permission denied。
根据排错思路,我断定是NFS服务器端某一个步骤配置错误。在创建共享目录时,关于权限的配置有三处,【Authentication】页和【Share Permissions】页和【Permissions】页。经过仔细检查配置,报错原因是【Authentication】中没有勾选了一处权限释放选项。红框下方的复选框。
翻译过来的意思如下:
正是因为没有勾选【Enable unmapped user access】才导致NFS客户端无权限访问映射后的共享目录。