文章目录

  • 一.NFS介绍
  • 二.部署安装
  • 1.测试机器
  • 2.NFS 服务安装
  • 三.NFS 配置及使用
  • 1.服务端系统(192.168.42.62)
  • 2.客户端系统(192.168.42.63、192.168.42.64)
  • 3.测试环节(192.168.42.63、192.168.42.64)
  • 四.问题
  • 1.NFS服务意外断开,导致挂载的客户端“df -Th”命令无法使用,及挂载目录无法cd ls
  • 2.mount挂载nfs服务器的文件夹以后会把客户端对应的文件夹覆盖(文件其实没有消失)


一.NFS介绍

NFS是 一个文件存储系统,依赖于RPC 信息的传输。

二.部署安装

1.测试机器

IP

模拟oracle服务器

服务器名称

192.168.42.62

NFS

node2

192.168.42.63

RAC1

node3

192.168.42.64

RAC2

node4

2.NFS 服务安装

NFS 服务需要依赖 RPC 服务,所以 NFS 服务端需要安装 rpcbind 和 nfs-utils,客户端只需要安装 nfs-utils 即可。

(1).确认下是否已安装 NFS(已经安装)

服务端系统(192.168.42.62):

[root@node2 arch]# rpm -qa nfs-utils rpcbind

rpcbind-0.2.0-16.el6.x86_64

nfs-utils-1.2.3-78.el6.x86_64

nfs 集群搭建 nfs client_服务端

客户端系统(192.168.42.63、192.168.42.64):

[root@node3 arch]# rpm -qa nfs-utils

nfs-utils-1.2.3-78.el6.x86_64

nfs 集群搭建 nfs client_nfs 集群搭建_02

(2)若未安装:
服务端 yum install -y nfs-utils rpcbind
客户端 yum install -y nfs-utils

三.NFS 配置及使用

1.服务端系统(192.168.42.62)

在服务端创建一个共享目录 /arch,作为客户端挂载的远端入口,然后设置权限

mkdir -p /arch
chmod 666 /arch

nfs 集群搭建 nfs client_nfs 集群搭建_03

修改 NFS 配置文件 /etc/exports
vim /etc/exports
设置内容
/arch * (rw,sync,insecure,no_subtree_check,no_root_squash)
此配置含义将 /arch文件目录设置为允许所有客户端(* 代表所有)挂载

若需要设置ip区间参考
/arch 192.168.42.0/100(rw,sync,insecure,no_subtree_check,no_root_squash)

启动 RPC 服务:

service rpcbind start 或者使用 /bin/systemctl start rpcbind.service

查看 NFS 服务项rpc 服务器注册的端口列表 rpcinfo -p localhost

没有启动 NFS 服务,只监听了 111 端口,接下来启动 NFS 服务,再来看下注册的端口列表

启动 NFS 服务 service nfs start 或者使用 /bin/systemctl start nfs.service

启动 NFS 服务后 rpc 服务已经启用对 NFS 的端口映射列表 rpcinfo -p localhost

nfs 集群搭建 nfs client_服务器_04

启动 NFS 服务后,rpc 注册的端口列表明显增多。服务端启动起来了,在服务端看下是否正确加载了设置的 /etc/exports 配置

showmount -e localhost

nfs 集群搭建 nfs client_nfs 集群搭建_05

2.客户端系统(192.168.42.63、192.168.42.64)

在2个节点客户端查看下 NFS 服务端 (上边服务端 IP 为:192.168.42.62) 设置可共享的目录信息

showmount -e 192.168.42.62

nfs 集群搭建 nfs client_nfs 集群搭建_06


nfs 集群搭建 nfs client_客户端_07

查看客户端挂载目录 /arch

nfs 集群搭建 nfs client_nfs 集群搭建_08


nfs 集群搭建 nfs client_客户端_09

挂载远端目录到本地 /arch目录
mount 192.168.42.62:/arch /arch

nfs 集群搭建 nfs client_客户端_10


nfs 集群搭建 nfs client_服务器_11

3.测试环节(192.168.42.63、192.168.42.64)

192.168.42.63:

nfs 集群搭建 nfs client_服务器_12


查看其他节点/arch目录

nfs 集群搭建 nfs client_服务端_13


nfs 集群搭建 nfs client_nfs 集群搭建_14

192.168.42.64:

nfs 集群搭建 nfs client_服务端_15


查看其他节点/arch目录

nfs 集群搭建 nfs client_服务器_16


nfs 集群搭建 nfs client_nfs 集群搭建_17

因为上边设置 NFS 远端目录权限为 rw 拥有读写权限,如果设置为 ro,那么客户端只能读取,不能写入

NFS 默认使用用 UDP 协议来进行挂载,为了提高 NFS 的稳定性,可以使用 TCP 协议挂载,那么客户端挂载命令可使用:
mount 192.168.42.62:/arch /arch -o proto=tcp -o nolock

四.问题

1.NFS服务意外断开,导致挂载的客户端“df -Th”命令无法使用,及挂载目录无法cd ls

强制取消客户端挂载
cat /etc/mtab
umount -lf /arch

重启NFS服务,客户端和服务端都需要重启
systemctl restart nfs
systemctl restart rpcbind

重新挂载NFS
mount 192.168.42.62:/arch /arch

2.mount挂载nfs服务器的文件夹以后会把客户端对应的文件夹覆盖(文件其实没有消失)

使用umont卸载共享盘
umount /arch
需要同步前先做备份复制到服务端目录/arch,同步完以后进行合并