NFS 配置

服务端(192.168.216.128)配置:

[root@localhost ~]$ yum install -y nfs-utils rpcbind    # 安装NFS和RPC
[root@localhost ~]$ vim /etc/exports                    # 编辑NFS配置文件
/data  192.168.216.129/32(rw,sync,all_squash,anonuid=1000,anongid=1000)    # 指定要共享的目录,以及要共享给哪些客户端,及客户端的挂载选项
[root@localhost ~]$ mkdir /data                         # 创建要共享的目录
[root@localhost ~]$ chmod 777 /data                     # 修改目录权限,这里改成777是为了实验方便,应该要根据实际需求来改
[root@localhost ~]$ /etc/init.d/rpcbind start           # 启动rpcbind服务
[root@localhost ~]$ /etc/init.d/nfs start               # 启动nfs服务
[root@localhost ~]$ chkconfig rpcbind on                # 开机启动rpcbind服务
[root@localhost ~]$ chkconfig nfs on                    # 开机启动nfs服务

客户端(192.168.216.129)配置:

[root@localhost ~]$ yum install -y nfs-utils                   # 安装NFS
[root@localhost ~]$ showmount -e 192.168.216.128               # 可以查看服务端是否有共享目录,如果出错则表明服务端的rpc服务没有开启,或者没有放通防火墙
[root@localhost ~]$ mount -t nfs 192.168.216.128:/data /mnt    # 挂载服务端共享的目录,这里把服务端的/data目录挂载到本地的/mnt目录下
[root@localhost ~]$ df -h                                      # 查看是否已经挂载了服务端共享的目录
[root@localhost ~]$ touch /data/1.txt                          # 最后,测试一下在客户端的挂载目录上创建文件,在服务端是否也实时同步即可

 

 

 

 

 

    

posted @ 2019-01-02 22:46  孔雀东南飞  阅读(216)  评论(0编辑  收藏  举报