• 配置 NFS Server 及 Client 来在局域网共享并公用文件夹


    https://vitux.com/install-nfs-server-and-client-on-ubuntu/

    https://help.ubuntu.com/community/SettingUpNFSHowTo

    quick start:

    nfs目录提供方即为nfs server,一下配置server:

    1、安装 NFS Kernel Server

    sudo apt install nfs-kernel-server

    2、创建被共用的文件夹

    sudo mkdir -p /mnt/sharedfolder

    我们希望所有客户端都能访问该目录,所以将通过以下命令删除被共用文件夹的权限限制:

    sudo chown -R nobody:nogroup /mnt/sharedfolder
    sudo chmod -R 777 /mnt/sharedfolder

    3、配置文件夹被公用时的权限,在文件 /etc/exports 里添加:

    /mnt/sharedfolder clientIP(rw,sync,no_subtree_check)

    如果要添加多个ip,则:

    /mnt/sharedfolder client1IP(rw,sync,no_subtree_check)
    /mnt/sharedfolder client2IP(rw,sync,no_subtree_check)

    如果要添加某个子网的所有ip,则:

    /mnt/sharedfolder subnetIP/24(rw,sync,no_subtree_check)

    rw,sync,no_subtree_check 的意思:

    rw:   客户端具有读写权限;

    sync: 实时将变化写进磁盘,即文件一改变就sync,然后对端就立即可以使用新的文件;

    no_subtree_check:  子目录放行;

    4、正式共享文件夹:

    sudo exportfs -a

    为了让配置起效,可能需要:

    sudo systemctl restart nfs-kernel-server

    5、server 的防火墙部分开放给 client:

    格式如下:

    sudo ufw allow from [clientIP or clientSubnetIP] to any port nfs

    示例:

    sudo ufw allow from 192.168.100/24 to any port nfs

    你可以检查view一下防火墙的设置:

    sudo ufw status

    1、client 的配置:

    安装 NFS Common client:

    sudo apt-get install nfs-common

    2、client 预先为目录创建挂载点:

    sudo mkdir -p /mnt/sharedfolder_client

    3、挂载:

    格式:

    sudo mount serverIP:/exportFolder_server /mnt/mountfolder_client

    示例:

    sudo mount 192.168.100.5:/mnt/sharedfolder /mnt/sharedfolder_client

    结束,现在文件夹已经公用了。

    附加说明:

    1、In order for the ID names to be automatically mapped, both the client and server require the /etc/idmapd.conf file to have the same contents with the correct domain names. Furthermore, this file should have the following lines in the Mapping section:

    [Mapping]
    
    Nobody-User = nobody
    Nobody-Group = nogroup

    2、There are three configuration files that relate to an NFS server: /etc/default/nfs-kernel-server/etc/default/nfs-common and /etc/exports.

      (The only important option in /etc/default/nfs-kernel-server for now is NEED_SVCGSSD. It is set to "no" by default, which is fine, because we are not activating NFSv4 security this time.)

  • 相关阅读:
    google的几道面试题
    轮盘赌算法
    基于packstack的openstack单节点安装
    攻克python3-字典(第四篇)
    攻克python3-列表与元组(第三篇)
    攻克python3-字符串(第二篇)
    攻克python3(第一篇)
    二维数组
    小白对c语言指针的基础总结
    小白对c语言数组的基础总结
  • 原文地址:https://www.cnblogs.com/welhzh/p/12148052.html
Copyright © 2020-2023  润新知