centos7.2 安装nfs

来源:互联网 发布:java方法是什么意思 编辑:程序博客网 时间:2024/06/05 02:53

1、安装nfs 和 rpcbind

        安装nfs-utils ,rpcbind:

           yum -y install nfs-utils ,rpcbind

2、关闭防火墙:

      关闭防火墙

       systemctl stop firewalld.service

        禁止防火墙开机自启动

       systemctl disable firewalld.service

3、启动服务:

       nfs需要向rpc注册,rpc一旦重启,注册的文件都丢失,向他注册的服务都需要重启,注意启动顺序

       启动rpc服务:

             systemctl start   rpcbind.service      

      启动nfs服务: 

            systemctl start  nfs.service

4、设置开机自启动

     设置rpc自启动:

         systemctl enable rpcbind.service

      设置rpc自启动 :  

         systemctl enable nfs.service

    

5、查看rpc ,nfs状态

        查看rpc状态:active

               systemctl status rpcbind.service

         查看nfs状态:active

              systemctl status nfs.service


客户端的安装配置

1、安装nfs 和 rpcbind

        安装nfs-utils ,rpcbind:

           yum -y install nfs-utils ,rpcbind

2、关闭防火墙:

      关闭防火墙

       systemctl stop firewalld.service

        禁止防火墙开机自启动

       systemctl disable firewalld.service

3、启动服务:

       nfs需要向rpc注册,rpc一旦重启,注册的文件都丢失,向他注册的服务都需要重启,注意启动顺序

       启动rpc服务:

             systemctl start   rpcbind.service      

      启动nfs服务: 

            systemctl start  nfs.service

4、设置开机自启动

     设置rpc自启动:

         systemctl enable rpcbind.service

      设置rpc自启动 :  

         systemctl enable nfs.service

5、查看rpc ,nfs状态

        查看rpc状态:active

               systemctl status rpcbind.service

         查看nfs状态:active

              systemctl status nfs.service


服务器端

1、在/etc/exports设置NFS服务共享文件夹的位置

       vi /etc/exports

       /etc/exports追加:

     /data  *(rw,sync,no_root_squash) 

              /data 共享的目录

               * :任何人

               rw :读写权限

               sync:资料会先暂存于内存中,而非直接写入硬盘。

               no_root_squash:当登录NFS主机使用共享目录的使用者是root时,其权限将被转换成为匿名使用者,通常它的UID与GID                                             都会变成nobody身份。

2、重启rpcbind 然后重启 nfs:

    重启rpc服务:

             systemctl restart  rpcbind.service      

      重启nfs服务: 

            systemctl restart  nfs.service


客户端

1、在所有客户端挂载服务器192.168.1.100的/data目录

        在服务端192.168.1.100查看可挂载的目录:

               showmount -e 192.168.1.100 

        进行挂载:

               mount -t nfs 192.168.1.100:/data   /data


2、设置客户端开机时自动挂载192.168.1.100:/data到本地的/data

          在root用户下:

           vi /etc/fstab

            新增:

           192.168.1.100:/data  /data

原创粉丝点击