centos7 nfs 搭建

NFS(Network File System)即网络文件系统,是FreeBSD支持的文件系统中的一种,它允许网络中的计算机之间通过TCP/IP网络共享资源。在NFS的应用中,本地NFS的客户端应用可以透明地读写位于远端NFS服务器上的文件,就像访问本地文件一样。
image.png

nfs 服务端安装

  • 在服务端安装nfs服务
yum -y install nfs-utils rpcbind
  • 新建共享文件夹
mkdir /data/
  • 配置nfs

配置nfs目录,客户端ip和读写同步方式

vim /etc/exports
#新增文本
/home/nfs-data *(rw,sync,no_root_squash)

/home/nfs-data (rw,sync) #这里的为客户端ip。*表示所有的客户端

  • 配置生效和服务重启
exportfs -r
service nfs restart
service rpcbind start
  • 设置开机自启
chkconfig nfs on
chkconfig rpcbind on

安装nfs客户端

  • 安装
yum -y install nfs-utils rpcbind
  • 新建共享文件夹
mkdir /home/nfs-data
  • 启动
service nfs restart
service rpcbind start
  • 设置开机自启
chkconfig nfs on
chkconfig rpcbind on
  • 挂载服务端目录
mount -t nfs 192.168.3.5:/home/nfs-data /home/nfs-data
  • 重启自动挂载
vi /etc/rc.local  
mount -t nfs 192.168.3.5:/home/nfs-ai /home/nfs-ai

校验

服务端和客户端目录下新建文件,检测服务端和客户端是否能看到相应的文件。

评论

公众号:mumuser

企鹅群:932154986

Your browser is out-of-date!

Update your browser to view this website correctly. Update my browser now

×