zoukankan      html  css  js  c++  java
  • 专题:NFSv4 file server

      Network File System (NFS) is a file system protocol that allows client machines to access network attached filesystems. The newest version is version 4.

    <A> Kernel requirements:

      NFS server support is not required for NFS clients, and NFS client support is not required for NFS servers. Dnotify support is only required for NFSv4. NFSv3 is only required for compatibility with legacy clients e.g.

    File systems --->
      [*] Dnotify support
      [*] Network File Systems --->
            <*>   NFS client support
            <*>     NFS client support for NFS version 3
            <*>     NFS client support for NFS version 4
            [*]   NFS client support for NFSv4.1
            <*>   NFS server support
            [*]     NFS server support for NFS version 3
            [*]     NFS server support for NFS version 4
            [*]       NFSv4.1 server support for Parallel NFS (pNFS)

    <B> Install "net-fs/nfs-utils"(Gentoo) or "nfs-utils.x86_64"(RedHat)

      After installation, set the "rpcbind" and "nfs" service start with your OS:

    root # rc-update add nfs default && rc-update add rpcbind default
    OR
    root # systemctl enable nfs.service && systemctl enable rpcbind.service

    <C> Virtual root 

      The filesystems to be exported must be made available under a single directory. This directory is known as the virtual root directory, and it is required for NFSv4:

    root #mkdir /export
    #The dir_name "/export" can be changed it to any other.

      Create directories in the virtual root directory for the filesystems that are to be exported:

    root #mkdir /export/distfiles

      Write to "/etc/fstab"

    /PATH/TO/distfiles    /export/distfiles    none    bind    0 0

    <D> Exports

      The filesystems to be made accessible for clients are specified in /etc/exports. This file consists of the directories to be exported, the clients allowed to access those directories, and a list options for each client:

    /export          10.1.0.0/8(sync,rw,insecure,no_subtree_check,crossmnt,fsid=root)
    /export/distfiles    *(sync,ro,insecure,no_subtree_check)

      The following table briefly describes the client options used in the configuration above:

    1 insecure    The server will require that client requests originate on unprivileged ports (those above 1024). This option is required when mounting exported directories from OS X. The default is to use privileged ports.
    2 rw    The client will have read and write access to the exported directory. The default is to allow read-only access.
    3 sync    The server must wait until filesystem changes are committed to storage before responding to further client requests. This is the default.
    4 no_subtree_check    The server will not verify the requests from clients(wether it's in the appropriate filesystem or has the correct permissions). This is the default in NFSv4.
    5 crossmnt    The server will reveal filesystems that are mounted under the virtual root directory that would otherwise be hidden when a client mounts the virtual root directory.
    6 fsid=root    This option is required to uniquely identify the virtual root directory.

      If changes are made to /etc/exports after the NFS server has started, execute the following command:

    root #exportfs -rv
    OR
    root #/etc/init.d/nfs reload
    OR
    root #systemctl reload nfs.service

    <E> Daemon

      The NFS daemon is configured via /etc/conf.d/nfs:

    # /etc/conf.d/nfs
    # Options to pass to rpc.nfsd
    OPTS_RPC_NFSD="8 -N 2 -V 3 -V 4 -p 8888"

      The option 8 is the number of NFS server threads to start.The option -N 2 disables NFS version 2, while options -V 3 and -V 4 enable NFS versions 3 and 4, The option -p 8888 change listening port from the default 2049 to 8888. 

    <F> Client Service

      To be able to mount exported directories, start the NFS client:

    root # service rpcbind start
    OR
    root # systemctl start rpcbind

    <G> Mount on Client

    root # mount [-t nfs] 113.114.115.116:/ /mnt    #"-t nfs" argument is not necessary

    <H>Troubeshooting

      The system may become unresponsive during shutdown when the NFS client attempts to unmount exported directories after udev has stopped. To prevent this, a local.d script(Gentoo) can be used to forcibly unmount the exported directories during shutdown:

    #write in "/etc/local.d/NFS_umount.stop"
    /bin/umount -a -f -t nfs

      Remember to add "x" permission:

    chmod +x NFS_umount.stop

      Verify which NFS daemons are running:

    Gentoo > rpcinfo -p
       program vers proto   port  service
        100000    4   tcp    111  portmapper
        100000    2   udp    111  portmapper
        100024    1   udp  35261  status
        100024    1   tcp  59039  status
        100005    1   udp  53336  mountd
        100005    3   tcp  37138  mountd
        100003    3   tcp   2049  nfs
        100003    4   tcp   2049  nfs
        100003    3   udp   2049  nfs
        100003    4   udp   2049  nfs
        100021    1   udp  36565  nlockmgr

      List the exported directories from the NFS server:

    Gentoo > exportfs -v
    /export           10.1.7.0/24(rw,wdelay,crossmnt,insecure,root_squash,no_subtree_check,fsid=0,sec=sys,rw,insecure,root_squash,no_all_squash)

      List the established connections:

    Gentoo > ss -tuanp | grep 2049
    udp    UNCONN     0      0         *:2049                  *:*                  
    udp    UNCONN     0      0        :::2049                 :::*                  
    tcp    LISTEN     0      64        *:2049                  *:*                  
    tcp    LISTEN     0      64       :::2049                 :::*        
  • 相关阅读:
    Java蛇形数组的简单实现代码
    Android Studio生成javadoc出错的解决办法
    AngularJS指令嵌套时link函数执行顺序的问题
    [转]如果我有jQuery背景,我应该如何切换到AngularJS的思维模式?
    扩展ViewFlow避免和ViewPager滑动冲突,同时支持无限循环,并完美和CircleFlowIndicator结合
    人机交互的新方向:智能聊天机器人
    利用python自动清除Android工程中的多余资源
    巧用svn create patch(打补丁)方案解决定制版需求
    【Android开发坑系列】之经常被忽略的背景图片内存泄露
    【Android开发坑系列】之try-catch
  • 原文地址:https://www.cnblogs.com/hadex/p/5813214.html
Copyright © 2011-2022 走看看