centos7 搭建nfs服务

    服务端:

    1.安装并检查nfs服务
    yum install nfs-utils

    2.配置共享目录
    vim /etc/exports
    /home/nfs/ 192.168.248.0/24(rw,sync,fsid=0)

    3.创建共享目录
    mkdir -p /home/nfs

    4.启动nfs服务
    先启动rpcbind,后启动nfs

    systemctl enable rpcbind.service
    systemctl enable nfs-server.service

    systemctl start rpcbind
    systemctl start nfs-server

    rpcinfo -p     #检查 NFS 服务器是否挂载我们想共享的目录 /home/nfs/:
    exportfs -r    #使配置生效

    客户端:

    1.安装nfs
    yum install nfs-utils

    2.启动nfs服务

    先为rpcbind做开机启动:

    systemctl enable rpcbind.service

    然后启动rpcbind服务:

    systemctl start rpcbind.service

    注意:客户端不需要启动nfs服务

    3.检查 NFS 服务器端是否有目录共享:showmount -e nfs服务器的IP

    [root@localhost ~]# showmount -e 192.168.3.184
    Export list for 192.168.3.184:
    /home/nfs 192.168.3.0/24

    4.在从机上使用 mount 挂载服务器端的目录/home/nfs到客户端某个目录下:
    df -h 查看是否挂载成功。

    [root@localhost ~]# mkdir /home/nfs
    [root@localhost ~]# mount -t nfs 192.168.3.184:/home/nfs /home/nfs
    [root@localhost ~]# df -h
    文件系统                 容量  已用  可用 已用% 挂载点
    /dev/mapper/centos-root   27G  3.5G   24G   13% /
    devtmpfs                 476M     0  476M    0% /dev
    tmpfs                    488M     0  488M    0% /dev/shm
    tmpfs                    488M  7.8M  480M    2% /run
    tmpfs                    488M     0  488M    0% /sys/fs/cgroup
    /dev/sda1               1014M  159M  856M   16% /boot
    tmpfs                     98M     0   98M    0% /run/user/0
    192.168.3.184:/home/nfs   27G  3.9G   24G   15% /home/nfs

猜你喜欢

转载自blog.csdn.net/qq389674856/article/details/83116854