Federation.apt.vm 12 KB

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