HdfsNfsGateway.apt.vm 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376
  1. ~~ Licensed under the Apache License, Version 2.0 (the "License");
  2. ~~ you may not use this file except in compliance with the License.
  3. ~~ You may obtain a copy of the License at
  4. ~~
  5. ~~ http://www.apache.org/licenses/LICENSE-2.0
  6. ~~
  7. ~~ Unless required by applicable law or agreed to in writing, software
  8. ~~ distributed under the License is distributed on an "AS IS" BASIS,
  9. ~~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. ~~ See the License for the specific language governing permissions and
  11. ~~ limitations under the License. See accompanying LICENSE file.
  12. ---
  13. Hadoop Distributed File System-${project.version} - HDFS NFS Gateway
  14. ---
  15. ---
  16. ${maven.build.timestamp}
  17. HDFS NFS Gateway
  18. %{toc|section=1|fromDepth=0}
  19. * {Overview}
  20. The NFS Gateway supports NFSv3 and allows HDFS to be mounted as part of the client's local file system.
  21. Currently NFS Gateway supports and enables the following usage patterns:
  22. * Users can browse the HDFS file system through their local file system
  23. on NFSv3 client compatible operating systems.
  24. * Users can download files from the the HDFS file system on to their
  25. local file system.
  26. * Users can upload files from their local file system directly to the
  27. HDFS file system.
  28. * Users can stream data directly to HDFS through the mount point. File
  29. append is supported but random write is not supported.
  30. The NFS gateway machine needs the same thing to run an HDFS client like Hadoop JAR files, HADOOP_CONF directory.
  31. The NFS gateway can be on the same host as DataNode, NameNode, or any HDFS client.
  32. * {Configuration}
  33. The NFS-gateway uses proxy user to proxy all the users accessing the NFS mounts.
  34. In non-secure mode, the user running the gateway is the proxy user, while in secure mode the
  35. user in Kerberos keytab is the proxy user. Suppose the proxy user is 'nfsserver'
  36. and users belonging to the groups 'users-group1'
  37. and 'users-group2' use the NFS mounts, then in core-site.xml of the NameNode, the following
  38. two properities must be set and only NameNode needs restart after the configuration change
  39. (NOTE: replace the string 'nfsserver' with the proxy user name in your cluster):
  40. ----
  41. <property>
  42. <name>hadoop.proxyuser.nfsserver.groups</name>
  43. <value>root,users-group1,users-group2</value>
  44. <description>
  45. The 'nfsserver' user is allowed to proxy all members of the 'users-group1' and
  46. 'users-group2' groups. Note that in most cases you will need to include the
  47. group "root" because the user "root" (which usually belonges to "root" group) will
  48. generally be the user that initially executes the mount on the NFS client system.
  49. Set this to '*' to allow nfsserver user to proxy any group.
  50. </description>
  51. </property>
  52. ----
  53. ----
  54. <property>
  55. <name>hadoop.proxyuser.nfsserver.hosts</name>
  56. <value>nfs-client-host1.com</value>
  57. <description>
  58. This is the host where the nfs gateway is running. Set this to '*' to allow
  59. requests from any hosts to be proxied.
  60. </description>
  61. </property>
  62. ----
  63. The above are the only required configuration for the NFS gateway in non-secure mode. For Kerberized
  64. hadoop clusters, the following configurations need to be added to hdfs-site.xml for the gateway (NOTE: replace
  65. string "nfsserver" with the proxy user name and ensure the user contained in the keytab is
  66. also the same proxy user):
  67. ----
  68. <property>
  69. <name>nfs.keytab.file</name>
  70. <value>/etc/hadoop/conf/nfsserver.keytab</value> <!-- path to the nfs gateway keytab -->
  71. </property>
  72. ----
  73. ----
  74. <property>
  75. <name>nfs.kerberos.principal</name>
  76. <value>nfsserver/_HOST@YOUR-REALM.COM</value>
  77. </property>
  78. ----
  79. The rest of the NFS gateway configurations are optional for both secure and non-secure mode.
  80. The AIX NFS client has a {{{https://issues.apache.org/jira/browse/HDFS-6549}few known issues}}
  81. that prevent it from working correctly by default with the HDFS NFS
  82. Gateway. If you want to be able to access the HDFS NFS Gateway from AIX, you
  83. should set the following configuration setting to enable work-arounds for these
  84. issues:
  85. ----
  86. <property>
  87. <name>nfs.aix.compatibility.mode.enabled</name>
  88. <value>true</value>
  89. </property>
  90. ----
  91. Note that regular, non-AIX clients should NOT enable AIX compatibility mode.
  92. The work-arounds implemented by AIX compatibility mode effectively disable
  93. safeguards to ensure that listing of directory contents via NFS returns
  94. consistent results, and that all data sent to the NFS server can be assured to
  95. have been committed.
  96. It's strongly recommended for the users to update a few configuration properties based on their use
  97. cases. All the following configuration properties can be added or updated in hdfs-site.xml.
  98. * If the client mounts the export with access time update allowed, make sure the following
  99. property is not disabled in the configuration file. Only NameNode needs to restart after
  100. this property is changed. On some Unix systems, the user can disable access time update
  101. by mounting the export with "noatime". If the export is mounted with "noatime", the user
  102. doesn't need to change the following property and thus no need to restart namenode.
  103. ----
  104. <property>
  105. <name>dfs.namenode.accesstime.precision</name>
  106. <value>3600000</value>
  107. <description>The access time for HDFS file is precise upto this value.
  108. The default value is 1 hour. Setting a value of 0 disables
  109. access times for HDFS.
  110. </description>
  111. </property>
  112. ----
  113. * Users are expected to update the file dump directory. NFS client often
  114. reorders writes. Sequential writes can arrive at the NFS gateway at random
  115. order. This directory is used to temporarily save out-of-order writes
  116. before writing to HDFS. For each file, the out-of-order writes are dumped after
  117. they are accumulated to exceed certain threshold (e.g., 1MB) in memory.
  118. One needs to make sure the directory has enough
  119. space. For example, if the application uploads 10 files with each having
  120. 100MB, it is recommended for this directory to have roughly 1GB space in case if a
  121. worst-case write reorder happens to every file. Only NFS gateway needs to restart after
  122. this property is updated.
  123. ----
  124. <property>
  125. <name>nfs.dump.dir</name>
  126. <value>/tmp/.hdfs-nfs</value>
  127. </property>
  128. ----
  129. * By default, the export can be mounted by any client. To better control the access,
  130. users can update the following property. The value string contains machine name and
  131. access privilege, separated by whitespace
  132. characters. The machine name format can be a single host, a Java regular expression, or an IPv4 address. The
  133. access privilege uses rw or ro to specify read/write or read-only access of the machines to exports. If the access
  134. privilege is not provided, the default is read-only. Entries are separated by ";".
  135. For example: "192.168.0.0/22 rw ; host.*\.example\.com ; host1.test.org ro;". Only the NFS gateway needs to restart after
  136. this property is updated.
  137. ----
  138. <property>
  139. <name>nfs.exports.allowed.hosts</name>
  140. <value>* rw</value>
  141. </property>
  142. ----
  143. * Customize log settings. To get NFS debug trace, users can edit the log4j.property file
  144. to add the following. Note, debug trace, especially for ONCRPC, can be very verbose.
  145. To change logging level:
  146. -----------------------------------------------
  147. log4j.logger.org.apache.hadoop.hdfs.nfs=DEBUG
  148. -----------------------------------------------
  149. To get more details of ONCRPC requests:
  150. -----------------------------------------------
  151. log4j.logger.org.apache.hadoop.oncrpc=DEBUG
  152. -----------------------------------------------
  153. * {Start and stop NFS gateway service}
  154. Three daemons are required to provide NFS service: rpcbind (or portmap), mountd and nfsd.
  155. The NFS gateway process has both nfsd and mountd. It shares the HDFS root "/" as the
  156. only export. It is recommended to use the portmap included in NFS gateway package. Even
  157. though NFS gateway works with portmap/rpcbind provide by most Linux distributions, the
  158. package included portmap is needed on some Linux systems such as REHL6.2 due to an
  159. {{{https://bugzilla.redhat.com/show_bug.cgi?id=731542}rpcbind bug}}. More detailed discussions can
  160. be found in {{{https://issues.apache.org/jira/browse/HDFS-4763}HDFS-4763}}.
  161. [[1]] Stop nfs/rpcbind/portmap services provided by the platform (commands can be different on various Unix platforms):
  162. -------------------------
  163. service nfs stop
  164. service rpcbind stop
  165. -------------------------
  166. [[2]] Start package included portmap (needs root privileges):
  167. -------------------------
  168. hdfs portmap
  169. OR
  170. hadoop-daemon.sh start portmap
  171. -------------------------
  172. [[3]] Start mountd and nfsd.
  173. No root privileges are required for this command. In non-secure mode, the NFS gateway
  174. should be started by the proxy user mentioned at the beginning of this user guide.
  175. While in secure mode, any user can start NFS gateway
  176. as long as the user has read access to the Kerberos keytab defined in "nfs.keytab.file".
  177. -------------------------
  178. hdfs nfs3
  179. OR
  180. hadoop-daemon.sh start nfs3
  181. -------------------------
  182. Note, if the hadoop-daemon.sh script starts the NFS gateway, its log can be found in the hadoop log folder.
  183. [[4]] Stop NFS gateway services.
  184. -------------------------
  185. hadoop-daemon.sh stop nfs3
  186. hadoop-daemon.sh stop portmap
  187. -------------------------
  188. Optionally, you can forgo running the Hadoop-provided portmap daemon and
  189. instead use the system portmap daemon on all operating systems if you start the
  190. NFS Gateway as root. This will allow the HDFS NFS Gateway to work around the
  191. aforementioned bug and still register using the system portmap daemon. To do
  192. so, just start the NFS gateway daemon as you normally would, but make sure to
  193. do so as the "root" user, and also set the "HADOOP_PRIVILEGED_NFS_USER"
  194. environment variable to an unprivileged user. In this mode the NFS Gateway will
  195. start as root to perform its initial registration with the system portmap, and
  196. then will drop privileges back to the user specified by the
  197. HADOOP_PRIVILEGED_NFS_USER afterward and for the rest of the duration of the
  198. lifetime of the NFS Gateway process. Note that if you choose this route, you
  199. should skip steps 1 and 2 above.
  200. * {Verify validity of NFS related services}
  201. [[1]] Execute the following command to verify if all the services are up and running:
  202. -------------------------
  203. rpcinfo -p $nfs_server_ip
  204. -------------------------
  205. You should see output similar to the following:
  206. -------------------------
  207. program vers proto port
  208. 100005 1 tcp 4242 mountd
  209. 100005 2 udp 4242 mountd
  210. 100005 2 tcp 4242 mountd
  211. 100000 2 tcp 111 portmapper
  212. 100000 2 udp 111 portmapper
  213. 100005 3 udp 4242 mountd
  214. 100005 1 udp 4242 mountd
  215. 100003 3 tcp 2049 nfs
  216. 100005 3 tcp 4242 mountd
  217. -------------------------
  218. [[2]] Verify if the HDFS namespace is exported and can be mounted.
  219. -------------------------
  220. showmount -e $nfs_server_ip
  221. -------------------------
  222. You should see output similar to the following:
  223. -------------------------
  224. Exports list on $nfs_server_ip :
  225. / (everyone)
  226. -------------------------
  227. * {Mount the export “/”}
  228. Currently NFS v3 only uses TCP as the transportation protocol.
  229. NLM is not supported so mount option "nolock" is needed. It's recommended to use
  230. hard mount. This is because, even after the client sends all data to
  231. NFS gateway, it may take NFS gateway some extra time to transfer data to HDFS
  232. when writes were reorderd by NFS client Kernel.
  233. If soft mount has to be used, the user should give it a relatively
  234. long timeout (at least no less than the default timeout on the host) .
  235. The users can mount the HDFS namespace as shown below:
  236. -------------------------------------------------------------------
  237. mount -t nfs -o vers=3,proto=tcp,nolock,noacl $server:/ $mount_point
  238. -------------------------------------------------------------------
  239. Then the users can access HDFS as part of the local file system except that,
  240. hard link and random write are not supported yet. To optimize the performance
  241. of large file I/O, one can increase the NFS transfer size(rsize and wsize) during mount.
  242. By default, NFS gateway supports 1MB as the maximum transfer size. For larger data
  243. transfer size, one needs to update "nfs.rtmax" and "nfs.rtmax" in hdfs-site.xml.
  244. * {Allow mounts from unprivileged clients}
  245. In environments where root access on client machines is not generally
  246. available, some measure of security can be obtained by ensuring that only NFS
  247. clients originating from privileged ports can connect to the NFS server. This
  248. feature is referred to as "port monitoring." This feature is not enabled by default
  249. in the HDFS NFS Gateway, but can be optionally enabled by setting the
  250. following config in hdfs-site.xml on the NFS Gateway machine:
  251. -------------------------------------------------------------------
  252. <property>
  253. <name>nfs.port.monitoring.disabled</name>
  254. <value>false</value>
  255. </property>
  256. -------------------------------------------------------------------
  257. * {User authentication and mapping}
  258. NFS gateway in this release uses AUTH_UNIX style authentication. When the user on NFS client
  259. accesses the mount point, NFS client passes the UID to NFS gateway.
  260. NFS gateway does a lookup to find user name from the UID, and then passes the
  261. username to the HDFS along with the HDFS requests.
  262. For example, if the NFS client has current user as "admin", when the user accesses
  263. the mounted directory, NFS gateway will access HDFS as user "admin". To access HDFS
  264. as the user "hdfs", one needs to switch the current user to "hdfs" on the client system
  265. when accessing the mounted directory.
  266. The system administrator must ensure that the user on NFS client host has the same
  267. name and UID as that on the NFS gateway host. This is usually not a problem if
  268. the same user management system (e.g., LDAP/NIS) is used to create and deploy users on
  269. HDFS nodes and NFS client node. In case the user account is created manually on different hosts, one might need to
  270. modify UID (e.g., do "usermod -u 123 myusername") on either NFS client or NFS gateway host
  271. in order to make it the same on both sides. More technical details of RPC AUTH_UNIX can be found
  272. in {{{http://tools.ietf.org/html/rfc1057}RPC specification}}.
  273. Optionally, the system administrator can configure a custom static mapping
  274. file in the event one wishes to access the HDFS NFS Gateway from a system with
  275. a completely disparate set of UIDs/GIDs. By default this file is located at
  276. "/etc/nfs.map", but a custom location can be configured by setting the
  277. "nfs.static.mapping.file" property to the path of the static mapping file.
  278. The format of the static mapping file is similar to what is described in the
  279. exports(5) manual page, but roughly it is:
  280. -------------------------
  281. # Mapping for clients accessing the NFS gateway
  282. uid 10 100 # Map the remote UID 10 the local UID 100
  283. gid 11 101 # Map the remote GID 11 to the local GID 101
  284. -------------------------