Federation.apt.vm 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342
  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} - Federation
  14. ---
  15. ---
  16. ${maven.build.timestamp}
  17. HDFS Federation
  18. \[ {{{./index.html}Go Back}} \]
  19. %{toc|section=1|fromDepth=0}
  20. This guide provides an overview of the HDFS Federation feature and
  21. how to configure and manage the federated cluster.
  22. * {Background}
  23. [./federation-background.gif] HDFS Layers
  24. HDFS has two main layers:
  25. * <<Namespace>>
  26. * Consists of directories, files and blocks
  27. * It supports all the namespace related file system operations such as
  28. create, delete, modify and list files and directories.
  29. * <<Block Storage Service>> has two parts
  30. * Block Management (which is done in Namenode)
  31. * Provides datanode cluster membership by handling registrations, and
  32. periodic heart beats.
  33. * Processes block reports and maintains location of blocks.
  34. * Supports block related operations such as create, delete, modify and
  35. get block location.
  36. * Manages replica placement and replication of a block for under
  37. replicated blocks and deletes blocks that are over replicated.
  38. * Storage - is provided by datanodes by storing blocks on the local file
  39. system and allows read/write access.
  40. The prior HDFS architecture allows only a single namespace for the
  41. entire cluster. A single Namenode manages this namespace. HDFS
  42. Federation addresses limitation of the prior architecture by adding
  43. support multiple Namenodes/namespaces to HDFS file system.
  44. * {Multiple Namenodes/Namespaces}
  45. In order to scale the name service horizontally, federation uses multiple
  46. independent Namenodes/namespaces. The Namenodes are federated, that is, the
  47. Namenodes are independent and don’t require coordination with each other.
  48. The datanodes are used as common storage for blocks by all the Namenodes.
  49. Each datanode registers with all the Namenodes in the cluster. Datanodes
  50. send periodic heartbeats and block reports and handles commands from the
  51. Namenodes.
  52. [./federation.gif] HDFS Federation Architecture
  53. <<Block Pool>>
  54. A Block Pool is a set of blocks that belong to a single namespace.
  55. Datanodes store blocks for all the block pools in the cluster.
  56. It is managed independently of other block pools. This allows a namespace
  57. to generate Block IDs for new blocks without the need for coordination
  58. with the other namespaces. The failure of a Namenode does not prevent
  59. the datanode from serving other Namenodes in the cluster.
  60. A Namespace and its block pool together are called Namespace Volume.
  61. It is a self-contained unit of management. When a Namenode/namespace
  62. is deleted, the corresponding block pool at the datanodes is deleted.
  63. Each namespace volume is upgraded as a unit, during cluster upgrade.
  64. <<ClusterID>>
  65. A new identifier <<ClusterID>> is added to identify all the nodes in
  66. the cluster. When a Namenode is formatted, this identifier is provided
  67. or auto generated. This ID should be used for formatting the other
  68. Namenodes into the cluster.
  69. ** Key Benefits
  70. * Namespace Scalability - HDFS cluster storage scales horizontally but
  71. the namespace does not. Large deployments or deployments using lot
  72. of small files benefit from scaling the namespace by adding more
  73. Namenodes to the cluster
  74. * Performance - File system operation throughput is limited by a single
  75. Namenode in the prior architecture. Adding more Namenodes to the cluster
  76. scales the file system read/write operations throughput.
  77. * Isolation - A single Namenode offers no isolation in multi user
  78. environment. An experimental application can overload the Namenode
  79. and slow down production critical applications. With multiple Namenodes,
  80. different categories of applications and users can be isolated to
  81. different namespaces.
  82. * {Federation Configuration}
  83. Federation configuration is <<backward compatible>> and allows existing
  84. single Namenode configuration to work without any change. The new
  85. configuration is designed such that all the nodes in the cluster have
  86. same configuration without the need for deploying different configuration
  87. based on the type of the node in the cluster.
  88. A new abstraction called <<<NameServiceID>>> is added with
  89. federation. The Namenode and its corresponding secondary/backup/checkpointer
  90. nodes belong to this. To support single configuration file, the Namenode and
  91. secondary/backup/checkpointer configuration parameters are suffixed with
  92. <<<NameServiceID>>> and are added to the same configuration file.
  93. ** Configuration:
  94. <<Step 1>>: Add the following parameters to your configuration:
  95. <<<dfs.nameservices>>>: Configure with list of comma separated
  96. NameServiceIDs. This will be used by Datanodes to determine all the
  97. Namenodes in the cluster.
  98. <<Step 2>>: For each Namenode and Secondary Namenode/BackupNode/Checkpointer
  99. add the following configuration suffixed with the corresponding
  100. <<<NameServiceID>>> into the common configuration file.
  101. *---------------------+--------------------------------------------+
  102. || Daemon || Configuration Parameter |
  103. *---------------------+--------------------------------------------+
  104. | Namenode | <<<dfs.namenode.rpc-address>>> |
  105. | | <<<dfs.namenode.servicerpc-address>>> |
  106. | | <<<dfs.namenode.http-address>>> |
  107. | | <<<dfs.namenode.https-address>>> |
  108. | | <<<dfs.namenode.keytab.file>>> |
  109. | | <<<dfs.namenode.name.dir>>> |
  110. | | <<<dfs.namenode.edits.dir>>> |
  111. | | <<<dfs.namenode.checkpoint.dir>>> |
  112. | | <<<dfs.namenode.checkpoint.edits.dir>>> |
  113. *---------------------+--------------------------------------------+
  114. | Secondary Namenode | <<<dfs.namenode.secondary.http-address>>> |
  115. | | <<<dfs.secondary.namenode.keytab.file>>> |
  116. *---------------------+--------------------------------------------+
  117. | BackupNode | <<<dfs.namenode.backup.address>>> |
  118. | | <<<dfs.secondary.namenode.keytab.file>>> |
  119. *---------------------+--------------------------------------------+
  120. Here is an example configuration with two namenodes:
  121. ----
  122. <configuration>
  123. <property>
  124. <name>dfs.nameservices</name>
  125. <value>ns1,ns2</value>
  126. </property>
  127. <property>
  128. <name>dfs.namenode.rpc-address.ns1</name>
  129. <value>nn-host1:rpc-port</value>
  130. </property>
  131. <property>
  132. <name>dfs.namenode.http-address.ns1</name>
  133. <value>nn-host1:http-port</value>
  134. </property>
  135. <property>
  136. <name>dfs.namenode.secondaryhttp-address.ns1</name>
  137. <value>snn-host1:http-port</value>
  138. </property>
  139. <property>
  140. <name>dfs.namenode.rpc-address.ns2</name>
  141. <value>nn-host2:rpc-port</value>
  142. </property>
  143. <property>
  144. <name>dfs.namenode.http-address.ns2</name>
  145. <value>nn-host2:http-port</value>
  146. </property>
  147. <property>
  148. <name>dfs.namenode.secondaryhttp-address.ns2</name>
  149. <value>snn-host2:http-port</value>
  150. </property>
  151. .... Other common configuration ...
  152. </configuration>
  153. ----
  154. ** Formatting Namenodes
  155. <<Step 1>>: Format a namenode using the following command:
  156. ----
  157. > $HADOOP_PREFIX_HOME/bin/hdfs namenode -format [-clusterId <cluster_id>]
  158. ----
  159. Choose a unique cluster_id, which will not conflict other clusters in
  160. your environment. If it is not provided, then a unique ClusterID is
  161. auto generated.
  162. <<Step 2>>: Format additional namenode using the following command:
  163. ----
  164. > $HADOOP_PREFIX_HOME/bin/hdfs namenode -format -clusterId <cluster_id>
  165. ----
  166. Note that the cluster_id in step 2 must be same as that of the
  167. cluster_id in step 1. If they are different, the additional Namenodes
  168. will not be part of the federated cluster.
  169. ** Upgrading from older release to 0.23 and configuring federation
  170. Older releases supported a single Namenode. Here are the steps enable
  171. federation:
  172. Step 1: Upgrade the cluster to newer release. During upgrade you can
  173. provide a ClusterID as follows:
  174. ----
  175. > $HADOOP_PREFIX_HOME/bin/hdfs start namenode --config $HADOOP_CONF_DIR -upgrade -clusterId <cluster_ID>
  176. ----
  177. If ClusterID is not provided, it is auto generated.
  178. ** Adding a new Namenode to an existing HDFS cluster
  179. Follow the following steps:
  180. * Add configuration parameter <<<dfs.nameservices>>> to the configuration.
  181. * Update the configuration with NameServiceID suffix. Configuration
  182. key names have changed post release 0.20. You must use new configuration
  183. parameter names, for federation.
  184. * Add new Namenode related config to the configuration files.
  185. * Propagate the configuration file to the all the nodes in the cluster.
  186. * Start the new Namenode, Secondary/Backup.
  187. * Refresh the datanodes to pickup the newly added Namenode by running
  188. the following command:
  189. ----
  190. > $HADOOP_PREFIX_HOME/bin/hdfs dfadmin -refreshNameNode <datanode_host_name>:<datanode_rpc_port>
  191. ----
  192. * The above command must be run against all the datanodes in the cluster.
  193. * {Managing the cluster}
  194. ** Starting and stopping cluster
  195. To start the cluster run the following command:
  196. ----
  197. > $HADOOP_PREFIX_HOME/bin/start-dfs.sh
  198. ----
  199. To stop the cluster run the following command:
  200. ----
  201. > $HADOOP_PREFIX_HOME/bin/stop-dfs.sh
  202. ----
  203. These commands can be run from any node where the HDFS configuration is
  204. available. The command uses configuration to determine the Namenodes
  205. in the cluster and starts the Namenode process on those nodes. The
  206. datanodes are started on nodes specified in the <<<slaves>>> file. The
  207. script can be used as reference for building your own scripts for
  208. starting and stopping the cluster.
  209. ** Balancer
  210. Balancer has been changed to work with multiple Namenodes in the cluster to
  211. balance the cluster. Balancer can be run using the command:
  212. ----
  213. "$HADOOP_PREFIX"/bin/hadoop-daemon.sh --config $HADOOP_CONF_DIR --script "$bin"/hdfs start balancer [-policy <policy>]
  214. ----
  215. Policy could be:
  216. * <<<node>>> - this is the <default> policy. This balances the storage at
  217. the datanode level. This is similar to balancing policy from prior releases.
  218. * <<<blockpool>>> - this balances the storage at the block pool level.
  219. Balancing at block pool level balances storage at the datanode level also.
  220. Note that Balander only balances the data and does not balance the namespace.
  221. ** Decommissioning
  222. Decommissioning is similar to prior releases. The nodes that need to be
  223. decomissioned are added to the exclude file at all the Namenode. Each
  224. Namenode decommissions its Block Pool. When all the Namenodes finish
  225. decommissioning a datanode, the datanode is considered to be decommissioned.
  226. <<Step 1>>: To distributed an exclude file to all the Namenodes, use the
  227. following command:
  228. ----
  229. "$HADOOP_PREFIX"/bin/distributed-exclude.sh <exclude_file>
  230. ----
  231. <<Step 2>>: Refresh all the Namenodes to pick up the new exclude file.
  232. ----
  233. "$HADOOP_PREFIX"/bin/refresh-namenodes.sh
  234. ----
  235. The above command uses HDFS configuration to determine the Namenodes
  236. configured in the cluster and refreshes all the Namenodes to pick up
  237. the new exclude file.
  238. ** Cluster Web Console
  239. Similar to Namenode status web page, a Cluster Web Console is added in
  240. federation to monitor the federated cluster at
  241. <<<http://<any_nn_host:port>/dfsclusterhealth.jsp>>>.
  242. Any Namenode in the cluster can be used to access this web page.
  243. The web page provides the following information:
  244. * Cluster summary that shows number of files, number of blocks and
  245. total configured storage capacity, available and used storage information
  246. for the entire cluster.
  247. * Provides list of Namenodes and summary that includes number of files,
  248. blocks, missing blocks, number of live and dead data nodes for each
  249. Namenode. It also provides a link to conveniently access Namenode web UI.
  250. * It also provides decommissioning status of datanodes.