BUILDING.txt 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308
  1. Build instructions for Hadoop
  2. ----------------------------------------------------------------------------------
  3. Requirements:
  4. * Unix System
  5. * JDK 1.7+
  6. * Maven 3.0 or later
  7. * Findbugs 1.3.9 (if running findbugs)
  8. * ProtocolBuffer 2.5.0
  9. * CMake 2.6 or newer (if compiling native code), must be 3.0 or newer on Mac
  10. * Zlib devel (if compiling native code)
  11. * openssl devel ( if compiling native hadoop-pipes and to get the best HDFS encryption performance )
  12. * Linux FUSE (Filesystem in Userspace) version 2.6 or above ( if compiling fuse_dfs )
  13. * Internet connection for first build (to fetch all Maven and Hadoop dependencies)
  14. ----------------------------------------------------------------------------------
  15. Installing required packages for clean install of Ubuntu 14.04 LTS Desktop:
  16. * Oracle JDK 1.7 (preferred)
  17. $ sudo apt-get purge openjdk*
  18. $ sudo apt-get install software-properties-common
  19. $ sudo add-apt-repository ppa:webupd8team/java
  20. $ sudo apt-get update
  21. $ sudo apt-get install oracle-java7-installer
  22. * Maven
  23. $ sudo apt-get -y install maven
  24. * Native libraries
  25. $ sudo apt-get -y install build-essential autoconf automake libtool cmake zlib1g-dev pkg-config libssl-dev
  26. * ProtocolBuffer 2.5.0 (required)
  27. $ sudo apt-get -y install libprotobuf-dev protobuf-compiler
  28. Optional packages:
  29. * Snappy compression
  30. $ sudo apt-get install snappy libsnappy-dev
  31. * Bzip2
  32. $ sudo apt-get install bzip2 libbz2-dev
  33. * Jansson (C Library for JSON)
  34. $ sudo apt-get install libjansson-dev
  35. * Linux FUSE
  36. $ sudo apt-get install fuse libfuse-dev
  37. ----------------------------------------------------------------------------------
  38. Maven main modules:
  39. hadoop (Main Hadoop project)
  40. - hadoop-project (Parent POM for all Hadoop Maven modules. )
  41. (All plugins & dependencies versions are defined here.)
  42. - hadoop-project-dist (Parent POM for modules that generate distributions.)
  43. - hadoop-annotations (Generates the Hadoop doclet used to generated the Javadocs)
  44. - hadoop-assemblies (Maven assemblies used by the different modules)
  45. - hadoop-common-project (Hadoop Common)
  46. - hadoop-hdfs-project (Hadoop HDFS)
  47. - hadoop-mapreduce-project (Hadoop MapReduce)
  48. - hadoop-tools (Hadoop tools like Streaming, Distcp, etc.)
  49. - hadoop-dist (Hadoop distribution assembler)
  50. ----------------------------------------------------------------------------------
  51. Where to run Maven from?
  52. It can be run from any module. The only catch is that if not run from utrunk
  53. all modules that are not part of the build run must be installed in the local
  54. Maven cache or available in a Maven repository.
  55. ----------------------------------------------------------------------------------
  56. Maven build goals:
  57. * Clean : mvn clean
  58. * Compile : mvn compile [-Pnative]
  59. * Run tests : mvn test [-Pnative]
  60. * Create JAR : mvn package
  61. * Run findbugs : mvn compile findbugs:findbugs
  62. * Run checkstyle : mvn compile checkstyle:checkstyle
  63. * Install JAR in M2 cache : mvn install
  64. * Deploy JAR to Maven repo : mvn deploy
  65. * Run clover : mvn test -Pclover [-DcloverLicenseLocation=${user.name}/.clover.license]
  66. * Run Rat : mvn apache-rat:check
  67. * Build javadocs : mvn javadoc:javadoc
  68. * Build distribution : mvn package [-Pdist][-Pdocs][-Psrc][-Pnative][-Dtar]
  69. * Change Hadoop version : mvn versions:set -DnewVersion=NEWVERSION
  70. Build options:
  71. * Use -Pnative to compile/bundle native code
  72. * Use -Pdocs to generate & bundle the documentation in the distribution (using -Pdist)
  73. * Use -Psrc to create a project source TAR.GZ
  74. * Use -Dtar to create a TAR with the distribution (using -Pdist)
  75. Snappy build options:
  76. Snappy is a compression library that can be utilized by the native code.
  77. It is currently an optional component, meaning that Hadoop can be built with
  78. or without this dependency.
  79. * Use -Drequire.snappy to fail the build if libsnappy.so is not found.
  80. If this option is not specified and the snappy library is missing,
  81. we silently build a version of libhadoop.so that cannot make use of snappy.
  82. This option is recommended if you plan on making use of snappy and want
  83. to get more repeatable builds.
  84. * Use -Dsnappy.prefix to specify a nonstandard location for the libsnappy
  85. header files and library files. You do not need this option if you have
  86. installed snappy using a package manager.
  87. * Use -Dsnappy.lib to specify a nonstandard location for the libsnappy library
  88. files. Similarly to snappy.prefix, you do not need this option if you have
  89. installed snappy using a package manager.
  90. * Use -Dbundle.snappy to copy the contents of the snappy.lib directory into
  91. the final tar file. This option requires that -Dsnappy.lib is also given,
  92. and it ignores the -Dsnappy.prefix option.
  93. OpenSSL build options:
  94. OpenSSL includes a crypto library that can be utilized by the native code.
  95. It is currently an optional component, meaning that Hadoop can be built with
  96. or without this dependency.
  97. * Use -Drequire.openssl to fail the build if libcrypto.so is not found.
  98. If this option is not specified and the openssl library is missing,
  99. we silently build a version of libhadoop.so that cannot make use of
  100. openssl. This option is recommended if you plan on making use of openssl
  101. and want to get more repeatable builds.
  102. * Use -Dopenssl.prefix to specify a nonstandard location for the libcrypto
  103. header files and library files. You do not need this option if you have
  104. installed openssl using a package manager.
  105. * Use -Dopenssl.lib to specify a nonstandard location for the libcrypto library
  106. files. Similarly to openssl.prefix, you do not need this option if you have
  107. installed openssl using a package manager.
  108. * Use -Dbundle.openssl to copy the contents of the openssl.lib directory into
  109. the final tar file. This option requires that -Dopenssl.lib is also given,
  110. and it ignores the -Dopenssl.prefix option.
  111. Tests options:
  112. * Use -DskipTests to skip tests when running the following Maven goals:
  113. 'package', 'install', 'deploy' or 'verify'
  114. * -Dtest=<TESTCLASSNAME>,<TESTCLASSNAME#METHODNAME>,....
  115. * -Dtest.exclude=<TESTCLASSNAME>
  116. * -Dtest.exclude.pattern=**/<TESTCLASSNAME1>.java,**/<TESTCLASSNAME2>.java
  117. ----------------------------------------------------------------------------------
  118. Building components separately
  119. If you are building a submodule directory, all the hadoop dependencies this
  120. submodule has will be resolved as all other 3rd party dependencies. This is,
  121. from the Maven cache or from a Maven repository (if not available in the cache
  122. or the SNAPSHOT 'timed out').
  123. An alternative is to run 'mvn install -DskipTests' from Hadoop source top
  124. level once; and then work from the submodule. Keep in mind that SNAPSHOTs
  125. time out after a while, using the Maven '-nsu' will stop Maven from trying
  126. to update SNAPSHOTs from external repos.
  127. ----------------------------------------------------------------------------------
  128. Protocol Buffer compiler
  129. The version of Protocol Buffer compiler, protoc, must match the version of the
  130. protobuf JAR.
  131. If you have multiple versions of protoc in your system, you can set in your
  132. build shell the HADOOP_PROTOC_PATH environment variable to point to the one you
  133. want to use for the Hadoop build. If you don't define this environment variable,
  134. protoc is looked up in the PATH.
  135. ----------------------------------------------------------------------------------
  136. Importing projects to eclipse
  137. When you import the project to eclipse, install hadoop-maven-plugins at first.
  138. $ cd hadoop-maven-plugins
  139. $ mvn install
  140. Then, generate eclipse project files.
  141. $ mvn eclipse:eclipse -DskipTests
  142. At last, import to eclipse by specifying the root directory of the project via
  143. [File] > [Import] > [Existing Projects into Workspace].
  144. ----------------------------------------------------------------------------------
  145. Building distributions:
  146. Create binary distribution without native code and without documentation:
  147. $ mvn package -Pdist -DskipTests -Dtar
  148. Create binary distribution with native code and with documentation:
  149. $ mvn package -Pdist,native,docs -DskipTests -Dtar
  150. Create source distribution:
  151. $ mvn package -Psrc -DskipTests
  152. Create source and binary distributions with native code and documentation:
  153. $ mvn package -Pdist,native,docs,src -DskipTests -Dtar
  154. Create a local staging version of the website (in /tmp/hadoop-site)
  155. $ mvn clean site; mvn site:stage -DstagingDirectory=/tmp/hadoop-site
  156. ----------------------------------------------------------------------------------
  157. Installing Hadoop
  158. Look for these HTML files after you build the document by the above commands.
  159. * Single Node Setup:
  160. hadoop-project-dist/hadoop-common/SingleCluster.html
  161. * Cluster Setup:
  162. hadoop-project-dist/hadoop-common/ClusterSetup.html
  163. ----------------------------------------------------------------------------------
  164. Handling out of memory errors in builds
  165. ----------------------------------------------------------------------------------
  166. If the build process fails with an out of memory error, you should be able to fix
  167. it by increasing the memory used by maven -which can be done via the environment
  168. variable MAVEN_OPTS.
  169. Here is an example setting to allocate between 256 MB and 1.5 GB of heap space to
  170. Maven
  171. export MAVEN_OPTS="-Xms256m -Xmx1536m"
  172. ----------------------------------------------------------------------------------
  173. Building on Windows
  174. ----------------------------------------------------------------------------------
  175. Requirements:
  176. * Windows System
  177. * JDK 1.7+
  178. * Maven 3.0 or later
  179. * Findbugs 1.3.9 (if running findbugs)
  180. * ProtocolBuffer 2.5.0
  181. * CMake 2.6 or newer
  182. * Windows SDK 7.1 or Visual Studio 2010 Professional
  183. * Windows SDK 8.1 (if building CPU rate control for the container executor)
  184. * zlib headers (if building native code bindings for zlib)
  185. * Internet connection for first build (to fetch all Maven and Hadoop dependencies)
  186. * Unix command-line tools from GnuWin32: sh, mkdir, rm, cp, tar, gzip. These
  187. tools must be present on your PATH.
  188. Unix command-line tools are also included with the Windows Git package which
  189. can be downloaded from http://git-scm.com/download/win.
  190. If using Visual Studio, it must be Visual Studio 2010 Professional (not 2012).
  191. Do not use Visual Studio Express. It does not support compiling for 64-bit,
  192. which is problematic if running a 64-bit system. The Windows SDK 7.1 is free to
  193. download here:
  194. http://www.microsoft.com/en-us/download/details.aspx?id=8279
  195. The Windows SDK 8.1 is available to download at:
  196. http://msdn.microsoft.com/en-us/windows/bg162891.aspx
  197. Cygwin is neither required nor supported.
  198. ----------------------------------------------------------------------------------
  199. Building:
  200. Keep the source code tree in a short path to avoid running into problems related
  201. to Windows maximum path length limitation. (For example, C:\hdc).
  202. Run builds from a Windows SDK Command Prompt. (Start, All Programs,
  203. Microsoft Windows SDK v7.1, Windows SDK 7.1 Command Prompt.)
  204. JAVA_HOME must be set, and the path must not contain spaces. If the full path
  205. would contain spaces, then use the Windows short path instead.
  206. You must set the Platform environment variable to either x64 or Win32 depending
  207. on whether you're running a 64-bit or 32-bit system. Note that this is
  208. case-sensitive. It must be "Platform", not "PLATFORM" or "platform".
  209. Environment variables on Windows are usually case-insensitive, but Maven treats
  210. them as case-sensitive. Failure to set this environment variable correctly will
  211. cause msbuild to fail while building the native code in hadoop-common.
  212. set Platform=x64 (when building on a 64-bit system)
  213. set Platform=Win32 (when building on a 32-bit system)
  214. Several tests require that the user must have the Create Symbolic Links
  215. privilege.
  216. All Maven goals are the same as described above with the exception that
  217. native code is built by enabling the 'native-win' Maven profile. -Pnative-win
  218. is enabled by default when building on Windows since the native components
  219. are required (not optional) on Windows.
  220. If native code bindings for zlib are required, then the zlib headers must be
  221. deployed on the build machine. Set the ZLIB_HOME environment variable to the
  222. directory containing the headers.
  223. set ZLIB_HOME=C:\zlib-1.2.7
  224. At runtime, zlib1.dll must be accessible on the PATH. Hadoop has been tested
  225. with zlib 1.2.7, built using Visual Studio 2010 out of contrib\vstudio\vc10 in
  226. the zlib 1.2.7 source tree.
  227. http://www.zlib.net/
  228. ----------------------------------------------------------------------------------
  229. Building distributions:
  230. * Build distribution with native code : mvn package [-Pdist][-Pdocs][-Psrc][-Dtar]