• nfs挂载


    操作步骤

    yum   install  -y  nfs-utils rpcbind
    
    vim /etc/exports
    /home/ap/nas     192.168.1.0/24(rw,no_root_squash,no_all_squash,sync)
    
    
    systemctl start  rpcbind
    systemctl start  nfs-serve
    
    systemctl enable  rpcbind
    systemctl enable  nfs-server
    
    
     exportfs -r
     showmount -e localhost
     showmount -e   192.168.1.148
    
    chmod   777   nas_a
    
    
    更改同一的user  uid  gid groups 
    groupmod  --help 
    groupmod  -g 1001 xxxx
    usermod 
    usermod -u 1001 -g 1001  xxxx
    
    
    挂载端启动
    
    systemctl enable  nfs
    
    mount -t nfs 192.168.1.58:/home/ap/nas_a   /home/ap/nas_a    -o proto=tcp -o nolock
    
    

    自动挂载

    格式
    :</remote/export> </local/directory> nfs < options> 0 0`

    开机自动挂载:
    如果服务端或客户端的服务器重启之后需要手动挂载,我们可以加入到开机自动挂载
    在客户端/etc/fstab里添加
    192.168.163.128:/nfsdir /nfsdir nfs defaults,_rnetdev 1 1
    备注:第1个1表示备份文件系统,第2个1表示从/分区的顺序开始fsck磁盘检测,0表示不检测。
    _rnetdev 表示主机无法挂载直接跳过,避免无法挂载主机无法启动

    注意:开机自动挂载不生效,两种办法
    1,

    chmod +x /etc/rc.d/rc.local
    
    vi /etc/rc.d/rc.local
    mount -a 
    #或 
    mount -t nfs 192.168.1.58:/home/ap/nas_a   /home/ap/nas_a    -o proto=tcp -o nolock
    

    2,自动挂在autofs
    1.在客户端安装软件autofs
    2.修改主配置文件 vim /etc/auto.master
    增加一条 /home/text-autonfs /etc/auto.nfs
    /home/autofs-test不需要存在这个目录,挂载后自动创建。
    3.编辑auto.nfs (原先不存在,编辑时会自动创建)
    vi /etc/auto.nfs
    增加一条: xxcc -rw 192.168.1.3:/home/xxcc

    4.重启autofs服务
    5.测试:卸载原来的挂载,仅输入命令:mount 就会自动挂载设置好的命令。
    6.查看自动生成的挂载目录

    问题

    clnt_create: RPC: Port mapper failure - Unable to receive: errno 111 (Connection refused)
    客户端挂载问题!需要关闭服务端和客户端防火墙以及selinux。

    这种情况,重新停止防火墙,确定selinux关闭
    showmount -e 192.168.1.12

    [root@lsx03 ~]# showmount -e 192.168.1.12 //测试有没有挂载的权限
    clnt_create: RPC: Port mapper failure - Unable to receive: errno 111 (Connection refused)
    第一种:先启动rpc服务,在启动nfs服务
    服务器端开启防火墙或者做了设置。出现这种情况。
    排查方式:可以客户端telnet 服务端 111端口不通
    服务端showmount自己通的话配置没问题

    备注:

    当在服务器运行df -h 卡死的时候,很有可能是nfs的原因。

    1、在客户端找到挂载的服务器的ip及挂载目录

    2、 showmount -e 服务端IP 来查看客户端挂载的目录。

    3、重启nfs

    4、现在客户端就可以操作了,先卸载之前的挂载

    umount /opt/aa

    5、重新挂载

    mount -t nfs 服务器IP:/服务器目录 客户端挂载目录

    nas服务器分享的目录挂掉

    nas客户端因为服务器分享的文件导出失败,导致被挂载的目录 ll 时文件属性乱码,需umount后重新挂载恢复

    NFS Stale File Handle error and solution

    Sometime NFS can result in to weird problems. For example NFS mounted directories sometimes contain stale file handles. If you run command such as ls or vi you will see an error:
    $ ls
    .: Stale File Handle

    First let us try to understand the concept of Stale File Handle. Managing NFS and NIS, 2nd Edition book defines filehandles as follows (a good book if you would like to master NFS and NIS):
    A filehandle becomes stale whenever the file or directory referenced by the handle is removed by another host, while your client still holds an active reference to the object. A typical example occurs when the current directory of a process, running on your client, is removed on the server (either by a process running on the server or on another client).

    So this can occur if the directory is modified on the NFS server, but the directories modification time is not updated.

    a) The best solution is to remount directory from the NFS client using mount command:

    umount -f /mnt/local

    mount -t nfs nfsserver:/path/to/share /mnt/local

    First command (umount) forcefully unmount a disk partition /mnt/local (NFS).

    (b) Or try to mount NFS directory with the noac option. However I don’t recommend using noac option because of performance issue and Checking files on NFS filesystem referenced by file descriptors (i.e. the fcntl and ioctl families of functions) may lead to inconsistent result due to the lack of consistency check in kernel even if noac is used.

  • 相关阅读:
    二、Redis服务启动以及请求流程
    三、Redis数据结构动态字符串SDS(simple dynamic string)
    java中Math类的常用API
    MySQL 8.0安装教程
    ERROR 1396 (HY000): Operation ALTER USER failed for 'root'@'%'
    记录一些壁纸/图片网站
    LeetCode No32. 最长有效括号
    LeetCode No35. 搜索插入位置
    LeetCode No942. 增减字符串匹配
    LeetCode Weekly Contest 292
  • 原文地址:https://www.cnblogs.com/g2thend/p/12061332.html
Copyright © 2020-2023  润新知