HdfsRollingUpgrade.xml 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!--
  3. Licensed to the Apache Software Foundation (ASF) under one or more
  4. contributor license agreements. See the NOTICE file distributed with
  5. this work for additional information regarding copyright ownership.
  6. The ASF licenses this file to You under the Apache License, Version 2.0
  7. (the "License"); you may not use this file except in compliance with
  8. the License. You may obtain a copy of the License at
  9. http://www.apache.org/licenses/LICENSE-2.0
  10. Unless required by applicable law or agreed to in writing, software
  11. distributed under the License is distributed on an "AS IS" BASIS,
  12. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. See the License for the specific language governing permissions and
  14. limitations under the License.
  15. -->
  16. <document xmlns="http://maven.apache.org/XDOC/2.0"
  17. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  18. xsi:schemaLocation="http://maven.apache.org/XDOC/2.0 http://maven.apache.org/xsd/xdoc-2.0.xsd">
  19. <properties>
  20. <title>HDFS Rolling Upgrade</title>
  21. </properties>
  22. <body>
  23. <h1>HDFS Rolling Upgrade</h1>
  24. <macro name="toc">
  25. <param name="section" value="0"/>
  26. <param name="fromDepth" value="0"/>
  27. <param name="toDepth" value="4"/>
  28. </macro>
  29. <section name="Introduction" id="Introduction">
  30. <p>
  31. <em>HDFS rolling upgrade</em> allows upgrading individual HDFS daemons.
  32. For examples, the datanodes can be upgraded independent of the namenodes.
  33. A namenode can be upgraded independent of the other namenodes.
  34. The namenodes can be upgraded independent of datanods and journal nodes.
  35. </p>
  36. </section>
  37. <section name="Upgrade" id="Upgrade">
  38. <p>
  39. In Hadoop v2, HDFS supports highly-available (HA) namenode services and wire compatibility.
  40. These two capabilities make it feasible to upgrade HDFS without incurring HDFS downtime.
  41. In order to upgrade a HDFS cluster without downtime, the cluster must be setup with HA.
  42. </p>
  43. <p>
  44. If there is any new feature which is enabled in new software release, may not work with old software release after upgrade.
  45. In such cases upgrade should be done by following steps.
  46. </p>
  47. <ol>
  48. <li>Disable new feature.</li>
  49. <li>Upgrade the cluster.</li>
  50. <li>Enable the new feature.</li>
  51. </ol>
  52. <p>
  53. Note that rolling upgrade is supported only from Hadoop-2.4.0 onwards.
  54. </p>
  55. <subsection name="Upgrade without Downtime" id="UpgradeWithoutDowntime">
  56. <p>
  57. In a HA cluster, there are two or more <em>NameNodes (NNs)</em>, many <em>DataNodes (DNs)</em>,
  58. a few <em>JournalNodes (JNs)</em> and a few <em>ZooKeeperNodes (ZKNs)</em>.
  59. <em>JNs</em> is relatively stable and does not require upgrade when upgrading HDFS in most of the cases.
  60. In the rolling upgrade procedure described here,
  61. only <em>NNs</em> and <em>DNs</em> are considered but <em>JNs</em> and <em>ZKNs</em> are not.
  62. Upgrading <em>JNs</em> and <em>ZKNs</em> may incur cluster downtime.
  63. </p>
  64. <h4>Upgrading Non-Federated Clusters</h4>
  65. <p>
  66. Suppose there are two namenodes <em>NN1</em> and <em>NN2</em>,
  67. where <em>NN1</em> and <em>NN2</em> are respectively in active and standby states.
  68. The following are the steps for upgrading a HA cluster:
  69. </p>
  70. <ol>
  71. <li>Prepare Rolling Upgrade<ol>
  72. <li>Run "<code><a href="#dfsadmin_-rollingUpgrade">hdfs dfsadmin -rollingUpgrade prepare</a></code>"
  73. to create a fsimage for rollback.
  74. </li>
  75. <li>Run "<code><a href="#dfsadmin_-rollingUpgrade">hdfs dfsadmin -rollingUpgrade query</a></code>"
  76. to check the status of the rollback image.
  77. Wait and re-run the command until
  78. the "<tt>Proceed with rolling upgrade</tt>" message is shown.
  79. </li>
  80. </ol></li>
  81. <li>Upgrade Active and Standby <em>NNs</em><ol>
  82. <li>Shutdown and upgrade <em>NN2</em>.</li>
  83. <li>Start <em>NN2</em> as standby with the
  84. "<a href="#namenode_-rollingUpgrade"><code>-rollingUpgrade started</code></a>" option.</li>
  85. <li>Failover from <em>NN1</em> to <em>NN2</em>
  86. so that <em>NN2</em> becomes active and <em>NN1</em> becomes standby.</li>
  87. <li>Shutdown and upgrade <em>NN1</em>.</li>
  88. <li>Start <em>NN1</em> as standby with the
  89. "<a href="#namenode_-rollingUpgrade"><code>-rollingUpgrade started</code></a>" option.</li>
  90. </ol></li>
  91. <li>Upgrade <em>DNs</em><ol>
  92. <li>Choose a small subset of datanodes (e.g. all datanodes under a particular rack).</li>
  93. <ol>
  94. <li>Run "<code><a href="#dfsadmin_-shutdownDatanode">hdfs dfsadmin -shutdownDatanode &lt;DATANODE_HOST:IPC_PORT&gt; upgrade</a></code>"
  95. to shutdown one of the chosen datanodes.</li>
  96. <li>Run "<code><a href="#dfsadmin_-getDatanodeInfo">hdfs dfsadmin -getDatanodeInfo &lt;DATANODE_HOST:IPC_PORT&gt;</a></code>"
  97. to check and wait for the datanode to shutdown.</li>
  98. <li>Upgrade and restart the datanode.</li>
  99. <li>Perform the above steps for all the chosen datanodes in the subset in parallel.</li>
  100. </ol>
  101. <li>Repeat the above steps until all datanodes in the cluster are upgraded.</li>
  102. </ol></li>
  103. <li>Finalize Rolling Upgrade<ul>
  104. <li>Run "<code><a href="#dfsadmin_-rollingUpgrade">hdfs dfsadmin -rollingUpgrade finalize</a></code>"
  105. to finalize the rolling upgrade.</li>
  106. </ul></li>
  107. </ol>
  108. <h4>Upgrading Federated Clusters</h4>
  109. <p>
  110. In a federated cluster, there are multiple namespaces
  111. and a pair of active and standby <em>NNs</em> for each namespace.
  112. The procedure for upgrading a federated cluster is similar to upgrading a non-federated cluster
  113. except that Step 1 and Step 4 are performed on each namespace
  114. and Step 2 is performed on each pair of active and standby <em>NNs</em>, i.e.
  115. </p>
  116. <ol>
  117. <li>Prepare Rolling Upgrade for Each Namespace</li>
  118. <li>Upgrade Active and Standby <em>NN</em> pairs for Each Namespace</li>
  119. <li>Upgrade <em>DNs</em></li>
  120. <li>Finalize Rolling Upgrade for Each Namespace</li>
  121. </ol>
  122. </subsection>
  123. <subsection name="Upgrade with Downtime" id="UpgradeWithDowntime">
  124. <p>
  125. For non-HA clusters,
  126. it is impossible to upgrade HDFS without downtime since it requires restarting the namenodes.
  127. However, datanodes can still be upgraded in a rolling manner.
  128. </p>
  129. <h4>Upgrading Non-HA Clusters</h4>
  130. <p>
  131. In a non-HA cluster, there are a <em>NameNode (NN)</em>, a <em>SecondaryNameNode (SNN)</em>
  132. and many <em>DataNodes (DNs)</em>.
  133. The procedure for upgrading a non-HA cluster is similar to upgrading a HA cluster
  134. except that Step 2 "Upgrade Active and Standby <em>NNs</em>" is changed to below:
  135. </p>
  136. <ul>
  137. <li>Upgrade <em>NN</em> and <em>SNN</em><ol>
  138. <li>Shutdown <em>SNN</em></li>
  139. <li>Shutdown and upgrade <em>NN</em>.</li>
  140. <li>Start <em>NN</em> with the
  141. "<a href="#namenode_-rollingUpgrade"><code>-rollingUpgrade started</code></a>" option.</li>
  142. <li>Upgrade and restart <em>SNN</em></li>
  143. </ol></li>
  144. </ul>
  145. </subsection>
  146. </section>
  147. <section name="Downgrade and Rollback" id="DowngradeAndRollback">
  148. <p>
  149. When the upgraded release is undesirable
  150. or, in some unlikely case, the upgrade fails (due to bugs in the newer release),
  151. administrators may choose to downgrade HDFS back to the pre-upgrade release,
  152. or rollback HDFS to the pre-upgrade release and the pre-upgrade state.
  153. </p>
  154. <p>
  155. Note that downgrade can be done in a rolling fashion but rollback cannot.
  156. Rollback requires cluster downtime.
  157. </p>
  158. <p>
  159. Note also that downgrade and rollback are possible only after a rolling upgrade is started and
  160. before the upgrade is terminated.
  161. An upgrade can be terminated by either finalize, downgrade or rollback.
  162. Therefore, it may not be possible to perform rollback after finalize or downgrade,
  163. or to perform downgrade after finalize.
  164. </p>
  165. </section>
  166. <section name="Downgrade" id="Downgrade">
  167. <p>
  168. <em>Downgrade</em> restores the software back to the pre-upgrade release
  169. and preserves the user data.
  170. Suppose time <em>T</em> is the rolling upgrade start time and the upgrade is terminated by downgrade.
  171. Then, the files created before or after <em>T</em> remain available in HDFS.
  172. The files deleted before or after <em>T</em> remain deleted in HDFS.
  173. </p>
  174. <p>
  175. A newer release is downgradable to the pre-upgrade release
  176. only if both the namenode layout version and the datenode layout version
  177. are not changed between these two releases.
  178. </p>
  179. <subsection name="Downgrade without Downtime" id="DowngradeWithoutDowntime">
  180. <p>
  181. In a HA cluster,
  182. when a rolling upgrade from an old software release to a new software release is in progress,
  183. it is possible to downgrade, in a rolling fashion, the upgraded machines back to the old software release.
  184. Same as before, suppose <em>NN1</em> and <em>NN2</em> are respectively in active and standby states.
  185. Below are the steps for rolling downgrade:
  186. </p>
  187. <ol>
  188. <li>Downgrade <em>DNs</em><ol>
  189. <li>Choose a small subset of datanodes (e.g. all datanodes under a particular rack).</li>
  190. <ol>
  191. <li>Run "<code><a href="#dfsadmin_-shutdownDatanode">hdfs dfsadmin -shutdownDatanode &lt;DATANODE_HOST:IPC_PORT&gt; upgrade</a></code>"
  192. to shutdown one of the chosen datanodes.</li>
  193. <li>Run "<code><a href="#dfsadmin_-getDatanodeInfo">hdfs dfsadmin -getDatanodeInfo &lt;DATANODE_HOST:IPC_PORT&gt;</a></code>"
  194. to check and wait for the datanode to shutdown.</li>
  195. <li>Downgrade and restart the datanode.</li>
  196. <li>Perform the above steps for all the chosen datanodes in the subset in parallel.</li>
  197. </ol>
  198. <li>Repeat the above steps until all upgraded datanodes in the cluster are downgraded.</li>
  199. </ol></li>
  200. <li>Downgrade Active and Standby <em>NNs</em><ol>
  201. <li>Shutdown and downgrade <em>NN2</em>.</li>
  202. <li>Start <em>NN2</em> as standby normally. (Note that it is incorrect to use the
  203. "<a href="#namenode_-rollingUpgrade"><code>-rollingUpgrade downgrade</code></a>"
  204. option here.)
  205. </li>
  206. <li>Failover from <em>NN1</em> to <em>NN2</em>
  207. so that <em>NN2</em> becomes active and <em>NN1</em> becomes standby.</li>
  208. <li>Shutdown and upgrade <em>NN1</em>.</li>
  209. <li>Start <em>NN1</em> as standby normally. (Note that it is incorrect to use the
  210. "<a href="#namenode_-rollingUpgrade"><code>-rollingUpgrade downgrade</code></a>"
  211. option here.)
  212. </li>
  213. </ol></li>
  214. <li>Finalize Rolling Downgrade<ul>
  215. <li>Run "<code><a href="#dfsadmin_-rollingUpgrade">hdfs dfsadmin -rollingUpgrade finalize</a></code>"
  216. to finalize the rolling downgrade.</li>
  217. </ul></li>
  218. </ol>
  219. <p>
  220. Note that the datanodes must be downgraded before downgrading the namenodes
  221. since protocols may be changed in a backward compatible manner but not forward compatible,
  222. i.e. old datanodes can talk to the new namenodes but not vice versa.
  223. </p>
  224. </subsection>
  225. <subsection name="Downgrade with Downtime" id="DowngradeWithDowntime">
  226. <p>
  227. Administrator may choose to first shutdown the cluster and then downgrade it.
  228. The following are the steps:
  229. </p>
  230. <ol>
  231. <li>Shutdown all <em>NNs</em> and <em>DNs</em>.</li>
  232. <li>Restore the pre-upgrade release in all machines.</li>
  233. <li>Start <em>NNs</em> with the
  234. "<a href="#namenode_-rollingUpgrade"><code>-rollingUpgrade downgrade</code></a>" option.</li>
  235. <li>Start <em>DNs</em> normally.</li>
  236. </ol>
  237. </subsection>
  238. </section>
  239. <section name="Rollback" id="Rollback">
  240. <p>
  241. <em>Rollback</em> restores the software back to the pre-upgrade release
  242. but also reverts the user data back to the pre-upgrade state.
  243. Suppose time <em>T</em> is the rolling upgrade start time and the upgrade is terminated by rollback.
  244. The files created before <em>T</em> remain available in HDFS but the files created after <em>T</em> become unavailable.
  245. The files deleted before <em>T</em> remain deleted in HDFS but the files deleted after <em>T</em> are restored.
  246. </p>
  247. <p>
  248. Rollback from a newer release to the pre-upgrade release is always supported.
  249. However, it cannot be done in a rolling fashion. It requires cluster downtime.
  250. Suppose <em>NN1</em> and <em>NN2</em> are respectively in active and standby states.
  251. Below are the steps for rollback:
  252. </p>
  253. <ul>
  254. <li>Rollback HDFS<ol>
  255. <li>Shutdown all <em>NNs</em> and <em>DNs</em>.</li>
  256. <li>Restore the pre-upgrade release in all machines.</li>
  257. <li>Start <em>NN1</em> as Active with the
  258. "<a href="#namenode_-rollingUpgrade"><code>-rollingUpgrade rollback</code></a>" option.</li>
  259. <li>Run `-bootstrapStandby' on NN2 and start it normally as standby.</li>
  260. <li>Start <em>DNs</em> with the "<code>-rollback</code>" option.</li>
  261. </ol></li>
  262. </ul>
  263. </section>
  264. <section name="Commands and Startup Options for Rolling Upgrade" id="dfsadminCommands">
  265. <subsection name="DFSAdmin Commands" id="dfsadminCommands">
  266. <h4><code>dfsadmin -rollingUpgrade</code></h4>
  267. <source>hdfs dfsadmin -rollingUpgrade &lt;query|prepare|finalize&gt;</source>
  268. <p>
  269. Execute a rolling upgrade action.
  270. <ul><li>Options:<table>
  271. <tr><td><code>query</code></td><td>Query the current rolling upgrade status.</td></tr>
  272. <tr><td><code>prepare</code></td><td>Prepare a new rolling upgrade.</td></tr>
  273. <tr><td><code>finalize</code></td><td>Finalize the current rolling upgrade.</td></tr>
  274. </table></li></ul>
  275. </p>
  276. <h4><code>dfsadmin -getDatanodeInfo</code></h4>
  277. <source>hdfs dfsadmin -getDatanodeInfo &lt;DATANODE_HOST:IPC_PORT&gt;</source>
  278. <p>
  279. Get the information about the given datanode.
  280. This command can be used for checking if a datanode is alive
  281. like the Unix <code>ping</code> command.
  282. </p>
  283. <h4><code>dfsadmin -shutdownDatanode</code></h4>
  284. <source>hdfs dfsadmin -shutdownDatanode &lt;DATANODE_HOST:IPC_PORT&gt; [upgrade]</source>
  285. <p>
  286. Submit a shutdown request for the given datanode.
  287. If the optional <code>upgrade</code> argument is specified,
  288. clients accessing the datanode will be advised to wait for it to restart
  289. and the fast start-up mode will be enabled.
  290. When the restart does not happen in time, clients will timeout and ignore the datanode.
  291. In such case, the fast start-up mode will also be disabled.
  292. </p>
  293. <p>
  294. Note that the command does not wait for the datanode shutdown to complete.
  295. The "<a href="#dfsadmin_-getDatanodeInfo">dfsadmin -getDatanodeInfo</a>"
  296. command can be used for checking if the datanode shutdown is completed.
  297. </p>
  298. </subsection>
  299. <subsection name="NameNode Startup Options" id="dfsadminCommands">
  300. <h4><code>namenode -rollingUpgrade</code></h4>
  301. <source>hdfs namenode -rollingUpgrade &lt;downgrade|rollback|started&gt;</source>
  302. <p>
  303. When a rolling upgrade is in progress,
  304. the <code>-rollingUpgrade</code> namenode startup option is used to specify
  305. various rolling upgrade options.
  306. </p>
  307. <ul><li>Options:<table>
  308. <tr><td><code>downgrade</code></td>
  309. <td>Restores the namenode back to the pre-upgrade release
  310. and preserves the user data.</td>
  311. </tr>
  312. <tr><td><code>rollback</code></td>
  313. <td>Restores the namenode back to the pre-upgrade release
  314. but also reverts the user data back to the pre-upgrade state.</td>
  315. </tr>
  316. <tr><td><code>started</code></td>
  317. <td>Specifies a rolling upgrade already started
  318. so that the namenode should allow image directories
  319. with different layout versions during startup.</td>
  320. </tr>
  321. </table></li></ul>
  322. </subsection>
  323. </section>
  324. </body>
  325. </document>