![两台服务器可以通过 NFS 共享同一个 ocfs2 FS 吗?](https://linux22.com/image/730661/%E4%B8%A4%E5%8F%B0%E6%9C%8D%E5%8A%A1%E5%99%A8%E5%8F%AF%E4%BB%A5%E9%80%9A%E8%BF%87%20NFS%20%E5%85%B1%E4%BA%AB%E5%90%8C%E4%B8%80%E4%B8%AA%20ocfs2%20FS%20%E5%90%97%EF%BC%9F.png)
问题如下:我有 2 台服务器,其 FS 安装为 ocfs2:
root [server01]% mount | grep ocfs2
ocfs2_dlmfs on /dlm type ocfs2_dlmfs (rw)
/dev/sddlmam1 on /share type ocfs2 (rw,_netdev,datavolume,heartbeat=local)
和
root [server02]% mount | grep ocfs2
ocfs2_dlmfs on /dlm type ocfs2_dlmfs (rw)
/dev/sddlmam1 on /share type ocfs2 (rw,_netdev,datavolume,heartbeat=local)
并且两者都通过 NFS 协议共享此 FS:
root [server01]% cat /etc/exports
/share *(rw,sync,no_root_squash)
和
root [server02]% cat /etc/exports
/share *(rw,sync,no_root_squash)
OCFS2 的配置看起来正常:
root [server01]% cat /etc/ocfs2/cluster.conf
cluster:
node_count = 2
name = ocfs2
node:
number = 0
cluster = ocfs2
ip_port = 7778
ip_address = 10.1.1.2
name = server01
node:
number = 1
cluster = ocfs2
ip_port = 7778
ip_address = 10.1.1.3
name = server02
root [server02]% cat /etc/ocfs2/cluster.conf
cluster:
node_count = 2
name = ocfs2
node:
number = 0
cluster = ocfs2
ip_port = 7778
ip_address = 10.1.1.2
name = server01
node:
number = 1
cluster = ocfs2
ip_port = 7778
ip_address = 10.1.1.3
name = server02
这些服务器是集群的和平衡的:
root [client01]% nslookup servercluster
Server: 10.108.1.1
Address: 10.108.1.1#53
servercluster.domain.com canonical name = servercluster.domain.com.
Name: servercluster.domain.com
Address: 10.1.1.2
Name: servercluster.domain.com
Address: 10.1.1.3
Name: servercluster.domain.com
Address: 10.1.1.4
root [client01]% mount | grep servercluster
servercluster:/share on /share type nfs4 (rw,relatime,vers=4.0,rsize=1048576,wsize=1048576,namlen=255,hard,proto=tcp,port=0,timeo=600,retrans=2,sec=sys,clientaddr=10.1.1.5,local_lock=none,addr=10.1.1.2)
和
root [client02]% nslookup servercluster
Server: 10.108.1.1
Address: 10.108.1.1#53
servercluster.domain.com canonical name = servercluster.domain.com.
Name: servercluster.domain.com
Address: 10.1.1.2
Name: servercluster.domain.com
Address: 10.1.1.3
Name: servercluster.domain.com
Address: 10.1.1.4
root [client02]% mount | grep servercluster
servercluster:/share on /share type nfs4 (rw,relatime,vers=4.0,rsize=1048576,wsize=1048576,namlen=255,hard,proto=tcp,port=0,timeo=600,retrans=2,sec=sys,clientaddr=10.1.1.6,local_lock=none,addr=10.1.1.3)
server01 出现故障,并报告了 NFS 错误:
dracut.log
Info: Not stripping '/tmp/initramfs.6SdU0W/lib/modules/3.8.13-118.16.4.el6uek.x86_64/kernel/fs/nfsd/nfsd.ko', because module signature appended.
消息:
Dec 8 02:18:19 server01 kernel: NFSD: Using /var/lib/nfs/v4recovery as the NFSv4 state recovery directory
Dec 8 02:18:19 server01 kernel: NFSD: starting 90-second grace period (net ffffffff81983940)
我的问题是:错误是否可能由于两个不同的服务器通过 NFS 共享相同的 FS 而引起?
答案1
由于底层 OCFS2 文件系统自行处理锁定,因此其本身不应存在任何损坏。
显然,两个 NFS 服务器之间没有协调,因此您可能会遇到这样的情况:一个客户端发送对现有文件的更新,同时另一个客户端也执行相同的操作 - 通常第二个客户端的数据将立即覆盖第一个客户端的更新,可能会有延迟,因为在第一个客户端进行写入时文件将暂时打开 - 但至少您不应该看到任何实际的损坏。