• 利用nfs将linux服务器上的目录共享到windows服务器


    linux服务器上修改2049端口没有成功,有修改成功的,麻烦评论区说一下

    测试的linux服务器ip 192.168.74.129

    在linux服务器上执行

    yum install nfs-utils -y #安装nfs文件系统软件
    编辑配置文件
    vim /etc/exports
    添加内容:
    /root/test *(rw,sync,no_root_squash)
    
    参数含义:
    首先是目录,然后星号表示任何ip都能访问
    
    rw:读写,如果想要只读,可设为"o"
    sync:数据同步写入硬盘
    no_root_squash:当远程访问使用root用户时,不映射成匿名用户,如果想用映射,可设为"root_squash"
    no_subtree_check:这个表示不确认父目录的权限,上面没设置这个
    
    systemctl start nfs-server #开启服务
    
    systemctl status nfs-server #查看服务状态
    
    查看共享出去的目录
    showmount --exports
    
    远程访问挂载
    先安装nfs客户端(看本文最上面),建立/nfs目录,然后执行:
    
    mount -t nfs 10.22.35.1:/root/test /nfs/

    如果服务端的开启了防火墙,则使用下面的语句开启nfs的端口 firewall-cmd --state systemctl start firewalld.service
    firewall-cmd --add-service=nfs --permanent
    也可以使用 rpcinfo -p 查看nfs使用到的端口,在开启对应的端口,比如

    firewall-cmd --permanent --add-port=14001/udp
    firewall-cmd --permanent --add-port=14001/tcp

    firewall-cmd --reload
    firewall-cmd --list-ports



     

    windows

     

    在控制台输入以下命令挂载:

    如果要卸载全部的NFS挂载:

    umount -f -a

    如果想让windows上挂载的目录有操作权限,要进行如下操作:

    查看root用户UID 输入 id root  

    uid=0(root) gid=0(root) 组=0(root)

    修改win注册表

    按win+R输入regeditHKEY_LOCAL_MACHINESOFTWAREMicrosoftClientForNFSCurrentVersionDefault下新建两个QWORD(64)位值,添加值AnonymousGid,值为0,AnonymousUid,值为0。然后重启。

    修改linux上nfs的默认端口,默认是2049 改成 12049

    vi /etc/services

  • 相关阅读:
    iOS:解决打包可能会出现环境错误问题
    iOS:关于self.perfrom(:_, with: afterDelay: )不执行问题
    docker容器中安装vi命令
    java-1 基础一
    java-0 重拾java
    柯里化函数的实现
    flex布局最后一行列表左对齐的N种方法
    【第一弹】微服务认证与授权企业级理解
    MySQL性能优化(慢查询日志、Explain执行计划、show profile、MySQL服务优化)
    MySQL锁详解
  • 原文地址:https://www.cnblogs.com/james-roger/p/13448089.html
Copyright © 2020-2023  润新知