在MacOSX上接触过rsync方式文件共享和NFS方式文件共享,两种方式的基本使用方式如下:

1. rsync方式:

这种方式和scp用法很像

rsync file1 user@host:/xx/file2

如果传输目录,需要加一个-a参数。如果传输目录过程担心传递发生意外问题,可以空跑一次,就是模拟一次传输,并不是真的传过去。-n是模拟,-v是看到详情。这样执行

  rsync -nva dir user@host:/xx/

2. NFS方式:

这种方式主要是配置/etc/exports文件,如果exports文件不存在,则创建该文件,并根据MacOSX_NFS_exports.txt格式,编写导出目录。

sudo nfsd enable #确认NFSD服务开启。

sudo nfsd restart #如果nfsd已经启动,需要重启才会生效。

sudo nfsd update #刷新NFSD共享资源。

showmount -e #显示当前共享的资源

客户端进行对导出的目录进行挂载:sudo mount -t nfs 192.168.100.222:/Users/nfs

以前在Linux上设置NFS文件共享感觉很顺利,网上的资料和例子也一大堆,根据配置,就可以顺利的实现文件共享,可是在MacOSX上,NFS的共享方式貌似跟Linux有些差异,其主要差别在与exports文件的编写上,以至于上次在项目中由于NFS在MacOSX上挂载不上,导致不得不另想其他办法,因此有了rsync方式在MacOSX上的实验。后来,经过不懈的努力,终于在MacOSX上搞好了NFS共享。其exports文件的书写方式,可以在MacOSX终端上查询帮助:man exports,即可找出其书写格式和各个参数的意义,其解释如下:


NAME

exports -- define remote mount points for NFS mount requests

SYNOPSIS

exports

DESCRIPTION

The exports file specifies remote mount points for the NFS mount protocol

per the NFS server specification; see Network File System Protocol

Specification RFC 1094, Appendix A and NFS: Network File System Version 3

Specification, Appendix I.

Fields are separated by space or tab characters.  Lines that begin with a

# are considered comments and are ignored.

Each line in the file specifies one or more exported directories, any

additional mountable sub-directories within those directories, export

flags, and one or more hosts (if access to the export is to be

restricted).  All directories on the line must exist within the same

local file system.

Within a file system there may be several exported sub-directories with

different export options.  However, none of those exported directories

may lie within another.

A host may be specified only once for each exported directory and there

may be only one default entry for each exported directory that applies to

all other hosts.  The latter exports the file system to the ``world'' and

should be used only when the file system contains public information.

Any attempt to export the same directory to a host with different export

options will cause the conflicting export entry to be rejected.

The first field(s) of an export entry is a list of directories on a local

file system to export.  At least one pathname must be to an exported

directory.  Other pathnames may refer to sub-directories of the exported

directory to indicate that hosts are also allowed to explicitly mount

those sub-directories of the exported directory.  (Note that the -alldirs

flag can be used to allow mounting any sub-directories of the pathnames

specified.)

Mount points for a file system may appear on multiple lines, each with

different sets of hosts and export options.

The pathnames must not have any symbolic links in them and should not

have any "." or ".." components.  Single and double quote characters

occuring in a pathname must be escaped with \' and \", respectively.

Space characters occuring in a pathname must be escaped, or alterna-

tively, the pathname can be enclosed in single or double quotes.

Note that because an export entry only lists a set of pathnames, it is up

to the NFS server to correctly determine what file system is meant to be

exported by that entry.  To that end, the server will attempt to intelli-

gently decide which file system best matches the entry by comparing all

the pathnames with both the current list of mounted file systems and the

list of previously-exported file systems.  If the server determines that

the intended file system is not available, it will automatically mark

that export as offline until the file system becomes available (see the

-offline export option below for more info).  To avoid any ambiguity, use

of the -fs export option is recommended (see below).

The second component of a line specifies how the file system is to be

exported to the host set.  The option flags specify whether the file sys-

tem is exported read-only or read-write and how the client uid is mapped

to user credentials on the server.

Export options are specified as follows:

-maproot=user The credential of the specified user is used for remote

access by root.  The credential includes all the groups to which the user

is a member on the local machine ( see id(1) ). The user may be specified

by name or number.

-maproot=user:group1:group2:... The colon separated list is used to spec-

ify the precise credential to be used for remote access by root.  The

elements of the list may be either names or numbers.  Note that ``user:''

should be used to distinguish a credential containing no groups from a

complete credential for that user.

-mapall=user or -mapall=user:group1:group2:... specifies a mapping for

all client uids (including root) using the same semantics as -maproot.

The option -r is a synonym for -maproot in an effort to be backward com-

patible with older export file formats.

In the absence of -maproot and -mapall options, remote accesses by root

will result in using a credential of -2:-2.  All other users will be

mapped to their remote credential.  If a -maproot option is given, remote

access by root will be mapped to that credential instead of -2:-2.  If a

-mapall option is given, all users (including root) will be mapped to

that credential in place of their own.

The -alldirs flag allows the host(s) to mount at any point within the

file system, including regular files if the -R option is used on nfsd.

The -ro option specifies that the file system should be exported read-

only (default read/write).  The option -o is a synonym for -ro in an

effort to be backward compatible with older export file formats.

The -32bitclients option causes the NFS server to guarantee that direc-

tory cookies will fit within 32 bits even though directory cookies are 64

bits in NFSv3.  This option may be required with NFS clients that do not

properly support 64 bit directory cookies.  Use of this option may result

in sub-optimal performance of the exported file system.

The -manglednames option causes the NFS server to guarantee that file-

names will fit into 255 bytes. For NFSv2 this is always the case. For

NFSv3 specifying this option on an export will cause filenames greater

than 255 characters from that export be mangled in such a way that when

the client presents a received mangled name it will refer to the same

name as the original name on the server.

-sec=mechanism1:mechanism2... This option specifies one or more security

mechanisms required for access to the exported directory.  The security

mechanisms currently supported are krb5p, krb5i, krb5, and sys.  Multiple

security mechanisms can be specified as a colon separated list, and

should be in the order of most preferred to least preferred.  In the

absence of this option, the security mechanism defaults to sys.

-offline This option specifies that the given export should be treated as

if the exported file system is not available.  For NFSv3, this will cause

clients to receive "jukebox" errors directing them to try the request

later.  For NFSv2 (which does not support this error value), the export

will be treated as non-existent and clients will receive stale file han-

dle errors.

-fspath=/path and/or -fsuuid=UUID These options can be used to specify

the pathname to and/or the UUID of the file system that is intended to be

exported.  This can be useful to disambiguate the export entry.  Since

the export syntax only specifies the path to the directory to be

exported, it can be ambiguous as to what file system is expected to be

exported.  Specifying "/Volumes/XRAID" can be interpreted as exporting

either a file system mounted on that directory or the "Volumes/XRAID"

subdirectory of the root file system.  Specifying -fspath=/Volumes/XRAID

can prevent exporting the wrong file system - for example, if the exports

are evaluated at a point when the directory exists but the volume has not

yet been mounted on it.  The export will fail if the file system referred

to in an export entry either (1) is not mounted at the same path as the

given -fspath=/path.  or (2) does not have a UUID that matches the given

-fsuuid=UUID.

The third component of a line specifies the host set to which the line

applies.  The set may be specified in three ways.  The first way is to

list the host name(s) separated by white space.  (Standard internet IPv4

``dot'' addresses or IPv6 colon addresses may be used in place of names.)

The second way is to specify a ``netgroup'' as defined in the netgroup

file (see netgroup(5) ). The third way is to specify an internet sub-net-

work using a network and network mask that is defined as the set of all

hosts with addresses within the sub-network.  This latter approach

requires less overhead within the kernel and is recommended for cases

where the export line refers to a large number of clients within an

administrative sub-net.

The first two cases are specified by simply listing the name(s) separated

by whitespace.  All names are checked to see if they are ``netgroup''

names first and are assumed to be hostnames otherwise.  Using the full

domain specification for a hostname can normally circumvent the problem

of a host that has the same name as a netgroup.  The third case is speci-

fied by the flag -network=netname and optionally -mask=netmask.  If the

mask is not specified, it will default to the mask for that network class

(A, B or C; see inet(5) ).

EXAMPLES

/usr /usr/local -maproot=0:10 friends

/usr -maproot=daemon grumpy.cis.uoguelph.ca 131.104.48.16

/usr -ro -mapall=nobody

/u -maproot=bin: -network 131.104.48 -mask 255.255.255.0

/u1 -alldirs -network 2001:DB8:: -mask ffff:ffff::

/u2 -maproot=root friends

/u2 -alldirs -network cis-net -mask cis-mask

/Users -alldirs -network 2.29.96.0 -mask 255.255.255.0

/Applications -ro -network 2.29.96.0 -mask 255.255.255.0

Given that /usr, /u, /u1, /u2, and / are local file system mount points,

the above example specifies the following:

/usr is exported to hosts friends, where friends is specified in the net-

group file with users mapped to their remote credentials and root mapped

to uid 0 and group 10.  It is exported read-write and the hosts in

friends can mount either /usr or /usr/local.  It is exported to

131.104.48.16 and grumpy.cis.uoguelph.ca with users mapped to their

remote credentials and root mapped to the user and groups associated with

``daemon''; it is exported to the rest of the world as read-only with all

users mapped to the user and groups associated with ``nobody''.

/u is exported to all hosts on the sub-network 131.104.48 with root

mapped to the uid for ``bin'' and with no group access.

/u1 is exported to all hosts on the IPv6 sub-network 2001:DB8::

/u2 is exported to the hosts in ``friends'' with root mapped to uid and

groups associated with ``root''; it is exported to all hosts on network

``cis-net'' allowing mounts at any directory within /u2.

The /Users and /Applications sub-directories of / are exported to all

hosts on the sub-network 2.29.96.  Any directory within /Users can be

mounted.  /Users is exported read-write and /Applications is exported

read-only.

FILES

/etc/exports  The default remote mount-point file.

SEE ALSO

netgroup(5), nfsd(8), showmount(8) portmap(8)

BUGS

It is recommended that all exported directories within the same server

file system be specified on adjacent lines going down the tree.  You can-

not specify a hostname that is also the name of a netgroup.  Specifying

the full domain specification for a hostname can normally circumvent the

problem.


读不懂英文的朋友,只需关注其中的例子就可以了,按照例子就能成功在MacOSX上配置成NFS文件共享。

MacOSX上的NFS文件共享相关推荐

  1. Linux上(Redhat7)实现NFS文件共享服务

    NFS(Network File System)网络文件系统基于TCP/IP 主要功能:通过网络(局域网)让不同的主机系统之间可以共享文件或目录,可以像使用本地主机资源那样远程读写文件夹 主要用途:N ...

  2. 如何在Windows上搭建NFS服务器实现开发板与Windows之间的文件共享

    由于通过USB烧录方式比较繁琐,且每次编译好可执行文件,都需要制作文件系统烧录到开发板,这里介绍一种比较简单的方式,通过nfs服务,将Windows的共享目录挂载到开发板的共享目录下,直接就可以通过n ...

  3. NFS 文件共享的创建过程

    nfs 文件共享的服务器 nfs服务需要两个软件包nfs-utils和portmap 启动nfs服务 # service portmap start # service nfs start # chk ...

  4. linux nfs文件共享

    linux nfs文件共享 ◆一.概念 NFS是网络文件系统(Network File System)的简称,是分布式计算机系统的一个组成部分,可实现在异构网络上共享和装配远程文件系统. NFS由SU ...

  5. Linux配置NFS文件共享存储

    一.NFS简介 NFS是一种基于TCP/IP传输的网络文件系统协议.通过使用NFS协议,客户机可以像访问本地目录一样访问远程服务器中的共享资源. 对于大多数负载均衡群集来说,使用NFS协议来共享数据存 ...

  6. CentOS8上部署NFS服务端和客户端

    centos8上部署nfs服务端和客户端 文章目录 背景 服务端与客户端信息 配置服务端 安装软件包 编辑配置文件 验证并使配置生效 启动服务端服务 查看服务端状态: 配置客户端: 安装软件包 启动客 ...

  7. linux nfs如何配置,Linux上的NFS如何配置?

    Linux上的NFS的配置方法如下: 1.安装NFS服务nfs和portmap.2.注意防火墙以及SElinux1)查看防火墙状态的方法[root@secDB1 ~]# service iptable ...

  8. Linux运维笔记-文档总结-NFS文件共享(网络文件系统)

    转自:http://m.blog.csdn.net/blog/index?username=Ningdaxing1994 觉得这个写得不错哈哈~ 以下所有操作都是在Red-hat 7.0上 1.NFS ...

  9. 在Ubuntu Server上添加NFS共享文件夹

    Synology NAS已搭建好NFS服务 Ubuntu上安装NFS命令支持 sudo apt install nfs-common Ubuntu上先创建要映射的文件夹 sudo mkdir /tes ...

  10. nfs文件共享+netstat相关 记录

    经常要创建nfs文件共享,每次都要重新找一下笔记,特记录下来方便查找: 一般linux自带有nfs应用,所以要使用时,只要启用即可,启动过程如下: 服务端: 在/etc/exports 里面加入要nf ...

最新文章

  1. 行为翻译模型是人脑的核心
  2. XSS漏洞自动化攻击工具XSSer
  3. oracle 查看表所占用的空间大小
  4. java element 属性_属性'value'在'HTMLElement'类型的值上不存在
  5. java 泛型嵌套泛型_Java泛型嵌套
  6. 英伟达代码签名证书遭窃取?三星也未能幸免,泄露多达190GB文件
  7. OSPF LSA详解
  8. idea关于mybatis去除黄色背景色与绿色背景
  9. zbb20180815 网盘搜索引擎
  10. scrt设置右键粘贴,选中复制
  11. [现代控制理论]6_稳定性_李雅普诺夫_Lyapunov
  12. ae效果英文版翻译对照表_AE特效中英名字对照表
  13. python特殊回文数
  14. 乘法鉴相器的matlab仿真,Matlab仿真costas环代码问题。
  15. STM32学习记录0010——TFTLCD液晶显示屏
  16. wirehark数据分析与取证flag.pcap
  17. 人工智能(机器学习)学习路线
  18. 【简介】请使用中国原子能科学研究院学位论文Latex模板
  19. TortoiseGit小乌龟安装配置及使用
  20. TikTok抖音国际版留存背后的数据和算法推演

热门文章

  1. 透过海信、海尔年中财报:看家电行业“下半场”之变
  2. 当前建筑师职业的发展趋势
  3. unity 启动相机_Unity中常用的几种相机
  4. 庭审公开网分享(如有违规通知博主,立马下架)
  5. Linux系统休眠问题解决
  6. 用计算机算卷积的规则,信号卷积计算公式与在线计算器_三贝计算网_23bei.com
  7. hive表 合并字段_hive数仓中两个维度表如果想合并纬度产生新自增ID方法
  8. 2022年氧化工艺考试试题及答案
  9. 百度/hao123团购收录API格式
  10. mysql 读取分离