java 发表于 2017-11-29 10:17:42

centos 7 安装 NFS

本帖最后由 java 于 2017-11-29 15:04 编辑

服务端
sudo yum -y install nfs-utils rpcbind

nfs 的配置文件 /etc/expots默认为空vi /etc/exports/opt/server_nfs/ 192.168.1.0/24(rw,no_root_squash,no_all_squash,sync,anonuid=501,anongid=501)或 /opt/server_nfs/*(rw,sync,no_root_squash)二、使配置生效exportfs -r注:配置文件说明:/opt/test 为共享目录192.168.1.0/24可以为一个网段,一个IP,也可以是域名,域名支持通配符 如: *.qq.com    也可为任何人表示为 *rw:read-write,可读写;ro:read-only,只读;sync:文件同时写入硬盘和内存;async:文件暂存于内存,而不是直接写入内存;no_root_squash:NFS客户端连接服务端时如果使用的是root的话,那么对服务端分享的目录来说,也拥有root权限。显然开启这项是不安全的。root_squash:NFS客户端连接服务端时如果使用的是root的话,那么对服务端分享的目录来说,拥有匿名用户权限,通常他将使用nobody或nfsnobody身份;all_squash:不论NFS客户端连接服务端时使用什么用户,对服务端分享的目录来说都是拥有匿名用户权限;anonuid:匿名用户的UID值,可以在此处自行设定。anongid:匿名用户的GID值。
NFS的共享权限和访问控制
chmod 777 -R /opt/server_nfs/

启动服务:一定要先启动rpc,然后启动nfs
       nfs需要向rpc注册,rpc一旦重启,所以注册的文件都丢失,其他向注册的服务都需要重启       启动rpc服务:             systemctl startrpcbind.service      或 service rpcbind start      启动nfs服务:             systemctl startnfs.service  或 service nfs start
查看rpc ,nfs状态      查看rpc状态:active
               systemctl status rpcbind.service
         查看nfs状态:active
            systemctl status nfs.service
关闭rpc ,nfs服务               systemctl stop rpcbind.service            systemctl stop nfs.service
客户端Ubuntu默认并不安装nfs客户端,所以首先要安装:
sudo apt-get install nfs-common  会报 showmount: 未找到命令    这样  sudo apt-get install portmap nfs-common 也不行,看来要安装服务端才支持 showmount命令 这里不安装了,直接挂载安装完成后新建一个目录用于挂载:
sudo mkdir /mnt/nfs假设服务器的IP地址为192.168.134.106,使用showmount查看服务器上已被共享的目录:showmount -e 192.168.134.106 然后即可用mount命令挂载,假设服务器上的目录为/opt/server_nfs,则使用以下命令:sudo mount -t nfs 192.168.134.106:/opt/server_nfs /mnt/nfs/取消mount
sudo umount /mnt/nfs/
查看mount状态  df -h

像操作本地文件一下操作挂载目录cp /home/hechengjin/demo/test0.txt /mnt/nfs/test0.txt


查看 nfs版本
客户端
mount -v | grep /mnt/nfs

客户端在挂载的时候遇到的一个问题如下,可能是网络不太稳定,NFS默认是用UDP协议,换成TCP协议即可:mount -t nfs 192.168.1.97:/opt/test /mnt -o proto=tcp -o nolock

java 发表于 2017-11-29 14:54:52

http://www.codeweblog.com/java-access-to-the-shared-directory-samba-and-nfs-configuration-and-implementation/

http://bbs.csdn.net/topics/391055500?page=1

import com.sun.nfs.XFileExtensionAccessor;
import com.sun.xfile.XFile;
import com.sun.xfile.XFileInputStream;
import com.sun.xfile.XFileOutputStream;


http://nfsv4bat.org/Documents/ConnectAThon/1998/webnfs.pdf


https://www.oracle.com/sun/index.html


http://www.sun.com/webnfs


http://nfs.sourceforge.net/


https://linux.die.net/man/5/nfs




https://tools.ietf.org/html/rfc7530#section-3.1




https://stackoverflow.com/questions/584112/why-does-nfs-use-udp-by-default




https://www.centos.org/docs/5/html/Deployment_Guide-en-US/s1-nfs-tcp.html






java 发表于 2017-11-29 15:10:47

https://docs.oracle.com/cd/E56344_01/html/E53868/rfsrefer-56.html

java 发表于 2017-11-29 15:14:06

本帖最后由 java 于 2017-11-30 09:29 编辑

https://docs.oracle.com/cd/E19455-01/806-1067/6jacl3e6c/index.html
https://docs.oracle.com/cd/E19455-01/806-1067/index.html
Documentation Home> WebNFS Developer's Guide

WebNFS Developer's Guide






[*]Book Information
[*]Preface
[*]Chapter 1 Introduction to the WebNFS Software Development Kit
[*]http://download.oracle.com/docs/dcommon/dsc/im/a.gifChapter 2 Extended Filesystem API
[*]http://download.oracle.com/docs/dcommon/dsc/im/a.gifChapter 3 NFS Classes for the Extended Filesystem
[*]http://download.oracle.com/docs/dcommon/dsc/im/a.gifChapter 4 The XFileAccessor Interface Class and Methods
[*]http://download.oracle.com/docs/dcommon/dsc/im/a.gifChapter 5 XFileChooser
[*]http://download.oracle.com/docs/dcommon/dsc/im/a.gifAppendix A Frequently Asked Questions
[*]Appendix B Simple XFile Sample Programs
[*]Appendix C The DemoEditor Sample Program
[*]Appendix D The XFileChooser Sample Program
[*]



WebNFS SDK

网盘下载:
https://pan.baidu.com/s/1jIu0I70

页: [1]
查看完整版本: centos 7 安装 NFS