客户端:windows2008
服务器端:linux6.9
linux上/ftp目录共享给windows挂接,防火墙目的端linux开通指定端口tcp/udp即可:111,662,875,892,2049,32803,32769。
[root@db ~]# cp /etc/sysconfig/nfs /etc/sysconfig/nfs.bak
[root@db ~]# cat /etc/sysconfig/nfs
添加
RQUOTAD_PORT=875
LOCKD_TCPPORT=32803
LOCKD_UDPPORT=32769
MOUNTD_PORT=892
STATD_PORT=662
[root@db ~]# cat /etc/exports
/ftp *(rw,sync,no_root_squash,no_all_squash,no_subtree_check)
[root@db ~]# service nfs restart
关闭 NFS 守护进程:[确定]
关闭 NFS mountd:[确定]
关闭 NFS quotas:[确定]
关闭 NFS 服务: [确定]
Shutting down RPC idmapd: [确定]
启动 NFS 服务: [确定]
关掉 NFS 配额:[确定]
启动 NFS mountd:[确定]
启动 NFS 守护进程:[确定]
正在启动 RPC idmapd:[确定]
[root@db ~]# netstat -tunlp|grep -
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:2049 0.0.0.0:* LISTEN -
tcp 0 0 0.0.0.0:32803 0.0.0.0:* LISTEN -
tcp 0 0 :::2049 :::* LISTEN -
tcp 0 0 :::32803 :::* LISTEN -
udp 0 0 0.0.0.0:32769 0.0.0.0:* -
udp 0 0 0.0.0.0:2049 0.0.0.0:* -
udp 0 0 :::32769 :::* -
udp 0 0 :::2049 :::* -
[root@db ~]# netstat -tunlp|grep LISTEN|grep -
tcp 0 0 0.0.0.0:2049 0.0.0.0:* LISTEN -
tcp 0 0 0.0.0.0:32803 0.0.0.0:* LISTEN -
tcp 0 0 :::2049 :::* LISTEN -
tcp 0 0 :::32803 :::* LISTEN -
[root@db ~]# netstat -tunlp|grep LISTEN|grep rpc
tcp 0 0 0.0.0.0:875 0.0.0.0:* LISTEN 63026/rpc.rquotad
tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN 2363/rpcbind
tcp 0 0 0.0.0.0:892 0.0.0.0:* LISTEN 63031/rpc.mountd
tcp 0 0 :::111 :::* LISTEN 2363/rpcbind
tcp 0 0 :::892 :::* LISTEN 63031/rpc.mountd
[root@db ~]# netstat -tunlp|grep LISTEN|grep mount
tcp 0 0 0.0.0.0:892 0.0.0.0:* LISTEN 63031/rpc.mountd
tcp 0 0 :::892 :::* LISTEN 63031/rpc.mountd
rpcinfo -p
program vers proto port service
100000 4 tcp 111 portmapper
100000 3 tcp 111 portmapper
100000 2 tcp 111 portmapper
100000 4 udp 111 portmapper
100000 3 udp 111 portmapper
100000 2 udp 111 portmapper
100011 1 udp 875 rquotad
100011 2 udp 875 rquotad
100011 1 tcp 875 rquotad
100011 2 tcp 875 rquotad
100005 1 udp 892 mountd
100005 1 tcp 892 mountd
100005 2 udp 892 mountd
100005 2 tcp 892 mountd
100005 3 udp 892 mountd
100005 3 tcp 892 mountd
100003 2 tcp 2049 nfs
100003 3 tcp 2049 nfs
100003 4 tcp 2049 nfs
100227 2 tcp 2049 nfs_acl
100227 3 tcp 2049 nfs_acl
100003 2 udp 2049 nfs
100003 3 udp 2049 nfs
100003 4 udp 2049 nfs
100227 2 udp 2049 nfs_acl
100227 3 udp 2049 nfs_acl
100021 1 udp 32769 nlockmgr
100021 3 udp 32769 nlockmgr
100021 4 udp 32769 nlockmgr
100021 1 tcp 32803 nlockmgr
100021 3 tcp 32803 nlockmgr
100021 4 tcp 32803 nlockmgr
[root@db ~]# chmod -R 777 /ftp
[root@db ~]# showmount -e
Export list for db:
/ftp *
[root@db ~]# showmount -a
All mount points on db:
10.22.1.2:/ftp
[root@db ~]#
windows客户端挂接:
C:\Users\Administrator>mount -u:root -p:"password" 10.62.2.181:/ftp F:
F: 现已成功连接到 10.62.2.181:/ftp
命令已成功完成。
参考:
windows2008x64上操作:【添加角色:文件服务器,勾选网络文件系统服务】才有mount命令
https://blog.csdn.net/qq_35590198/article/details/97130636
补充:虽然给了777但很可能mount所在客户端程序写入后的文件还是变成其它用户的权限,导致other用户无读取权限。
此时需要检查挂接点的文件权限在服务端和客户端看到的uid和gid是否一致。
案例:客户端weblogic用户启动的weblogic应用写入nfs目录文件后,ls -l看到的文件权限竟然不是weblogic而是xxx
结果是-rw-r-----
检查id weblogic的uid,gid为107,
检查服务器端没有weblogic用户,有xxx用户的uid,gid也为107。
所以尝试在服务器端也创建weblogic用户,然后修改/etc/passwd,/etc/group的uid为107,原来xxx用户的uid和gid改成其它不冲突的即可。这样保证客户端和服务器端都有weblogic用户同时uid和gid一致,客户端程序再次写入文件后权限为-rw-rw-r--了。
到此满足需求。