Centos7 使用NFS

2025-11-05 05:22:42

1、服务端:1.关闭系统防火墙

[root@server ~]systemctl stop firewalld

2、服务端:2.禁用selinux

[root@server ~]vi /etc/sysconfig/selinux

Centos7 使用NFS

3、服务端:3.安装所需的软件包

[root@server ~]yum install -y rpc-bind nfs-utils

4、服务端:4.修改/etc/exports文件,定义NFS共享

如下:

/home/mallapp/nfs 172.18.0.0/16 (rw,no_root_squash,no_all_squash,sync)

Centos7 使用NFS

5、服务端:5.创建需要共享目录

将需要共享的资源放入此目录,或者第四步之前准备好目录,然后在编辑exports的时指向需要共享的目录

mkdir -p /home/mallapp/nfs

6、服务端:6.启动nfs和rpcbind 服务

[root@server ~]systemctl enable nfs

[root@server ~]systemctl start nfs

[root@server ~]systemctl enable rpcbind

[root@server ~]systemctl start rpcbind

7、服务端:7.查看服务状态 

查看NFS服务的服务状态[可忽略]

[root@server ~]systemctl status nfs

查看本机共享的文件系统[可忽略]

[root@server ~]exportfs

/home/mallapp/nfs

                172.18.0.0/16

8、客户端:1.关闭防火墙和selinux,方法见上面

9、客户端:2.安装nfs-utils

[root@client ~]yum install -y nfs-utils

10、客户端:3.创建需要挂载的目录

这里使用相同的目录路径,如:

[root@client ~]mkdir -p /home/mallapp/nfs

11、客户端:4.挂载

[root@client ~]mount -t nfs 172.18.112.80:/home/mallapp/nfs /home/mallapp/nfs -o proto=tcp -o nolock

12、客户端:5.查看挂载是否成功

通过进入目录查看或者使用命令mount -l

声明:本网站引用、摘录或转载内容仅供网站访问者交流或参考,不代表本站立场,如存在版权或非法内容,请联系站长删除,联系邮箱:site.kefu@qq.com。
猜你喜欢