Ubuntu上使用Hadoop 2.x 三 编译2.2.0 64bit版本

来源:互联网 发布:sql insert into 日期 编辑:程序博客网 时间:2024/06/08 01:56

下载源代码:

[plain] view plaincopyprint?在CODE上查看代码片派生到我的代码片
  1. wget http://mirror.esocc.com/apache/hadoop/common/hadoop-2.2.0/hadoop-2.2.0-src.tar.gz  

然后解压:
[plain] view plaincopyprint?在CODE上查看代码片派生到我的代码片
  1. tar zxvf hadoop-2.2.0-src.tar.gz  
  2. cd hadoop-2.2.0-src  

运行下面的命令开始编译:
[plain] view plaincopyprint?在CODE上查看代码片派生到我的代码片
  1. ~/code/hadoop-2.2.0-src$ mvn package -Pdist,native -DskipTests -Dtar  
下载了很多maven的东东后,编译报错:
[plain] view plaincopyprint?在CODE上查看代码片派生到我的代码片
  1. [ERROR] COMPILATION ERROR :   
  2. [INFO] -------------------------------------------------------------  
  3. [ERROR] /home/hduser/code/hadoop-2.2.0-src/hadoop-common-project/hadoop-auth/src/test/java/org/apache/hadoop/security/authentication/client/AuthenticatorTestCase.java:[88,11] error: cannot access AbstractLifeCycle  
  4. [ERROR]   class file for org.mortbay.component.AbstractLifeCycle not found  
  5. /home/hduser/code/hadoop-2.2.0-src/hadoop-common-project/hadoop-auth/src/test/java/org/apache/hadoop/security/authentication/client/AuthenticatorTestCase.java:[96,29] error: cannot access LifeCycle  
  6. [ERROR]   class file for org.mortbay.component.LifeCycle not found  

编辑hadoop-common-project/hadoop-auth/pom.xml文件,添加依赖:
[html] view plaincopyprint?在CODE上查看代码片派生到我的代码片
  1. <dependency>  
  2.   <groupId>org.mortbay.jetty</groupId>  
  3.   <artifactId>jetty-util</artifactId>  
  4.   <scope>test</scope>  
  5. </dependency>  

再次编译,这个错误解决了。注意,2.3.0之后不需要修改pom.xml,这个问题已经解决。

之后遇到了没有安装protocol buffer库的错误,安装一下:

[html] view plaincopyprint?在CODE上查看代码片派生到我的代码片
  1. [INFO] --- hadoop-maven-plugins:2.2.0:protoc (compile-protoc) @ hadoop-common ---  
  2. [WARNING] [protoc, --version] failed: java.io.IOException: Cannot run program "protoc": error=2, No such file or directory  

[html] view plaincopyprint?在CODE上查看代码片派生到我的代码片
  1. sudo apt-get install libprotobuf-dev  


然后再次运行maven命令编译。发现新的错误,原来ubuntu的安装包里面没有带上protoc编译器。算了,下源代码自己编译。
[html] view plaincopyprint?在CODE上查看代码片派生到我的代码片
  1. hduser@hm1:/usr/src$ sudo wget https://protobuf.googlecode.com/files/protobuf-2.5.0.tar.gz  
  2. ...   
  3. $ sudo ./configure  
  4. $ sudo make  
  5. $ sudo make check  
  6. $ sudo make install  
  7. $ sudo ldconfig  
  8. $ protoc --version  
[html] view plaincopyprint?
  1. hduser@hm1:~$ start-dfs.sh   
  2. Starting namenodes on [localhost]  
  3. localhost: namenode running as process 983. Stop it first.  
  4. localhost: datanode running as process 1101. Stop it first.  
  5. Starting secondary namenodes [0.0.0.0]  
  6. 0.0.0.0: secondarynamenode running as process 1346. Stop it first.  


再来编译。等...., 说明hadoop不准备64bit的库浪费了大家多少时间。

还有错:

[html] view plaincopyprint?在CODE上查看代码片派生到我的代码片
  1. Could NOT find OpenSSL, try to set the path to OpenSSL root folder in the  
  2.      [exec]   system variable OPENSSL_ROOT_DIR (missing: OPENSSL_LIBRARIES  

安装openssl库
[html] view plaincopyprint?在CODE上查看代码片派生到我的代码片
  1. sudo apt-get install libssl-dev  

再来一次,编译成功了。在目录/home/hduser/code/hadoop-2.2.0-src/hadoop-dist/target 下有文件:

hadoop-2.2.0.tar.gz

解压后,进入目录,然后复制native 目录里的东西到制定位置,覆盖32bit文件

[html] view plaincopyprint?
  1. sudo cp -r ./hadoop-2.2.0/lib/native/* /usr/local/hadoop/lib/native/  

现在回到~目录,运行下面的命令,成功了。
[html] view plaincopyprint?
  1. hduser@hm1:~$ start-dfs.sh   
  2. Starting namenodes on [localhost]  
  3. localhost: namenode running as process 983. Stop it first.  
  4. localhost: datanode running as process 1101. Stop it first.  
  5. Starting secondary namenodes [0.0.0.0]  
  6. 0.0.0.0: secondarynamenode running as process 1346. Stop it first.  

[html] view plaincopyprint?
  1. hduser@hm1:~$ start-yarn.sh  
  2. starting yarn daemons  
  3. starting resourcemanager, logging to /usr/local/hadoop/logs/yarn-hduser-resourcemanager-hm1.out  
  4. localhost: starting nodemanager, logging to /usr/local/hadoop/logs/yarn-hduser-nodemanager-hm1.out  

[html] view plaincopyprint?
  1. hduser@hm1:~$ jps  
  2. 32417 Jps  
  3. 1101 DataNode  
  4. 1346 SecondaryNameNode  
  5. 983 NameNode  

现在运行例子程序, 注意/etc/hosts中我配置了 

[html] view plaincopyprint?
  1. 127.0.0.1 hm1  

[html] view plaincopyprint?
  1. hduser@hm1:~/code/hadoop-2.2.0-src$ cd /usr/local/hadoop/  
  2. hduser@hm1:/usr/local/hadoop$ hadoop jar ./share/hadoop/mapreduce/hadoop-mapreduce-examples-2.2.0.jar pi 2 5  
  3. Number of Maps  = 2  
  4. Samples per Map = 5  
  5. Wrote input for Map #0  
  6. Wrote input for Map #1  
  7. Starting Job  
  8. 14/02/21 18:07:29 INFO client.RMProxy: Connecting to ResourceManager at /0.0.0.0:8032  
  9. 14/02/21 18:07:30 INFO ipc.Client: Retrying connect to server: 0.0.0.0/0.0.0.0:8032. Already tried 0 time(s); retry policy is RetryUpToMaximumC\  
  10. fountWithFixedSleep(maxRetries=10sleepTime=1 SECONDS)  
  11. 14/02/21 18:07:31 INFO ipc.Client: Retrying connect to server: 0.0.0.0/0.0.0.0:8032. Already tried 1 time(s); retry policy is RetryUpToMaximumC\  
  12. ountWithFixedSleep(maxRetries=10sleepTime=1 SECONDS)  
  13. 14/02/21 18:07:32 INFO ipc.Client: Retrying connect to server: 0.0.0.0/0.0.0.0:8032. Already tried 2 time(s); retry policy is RetryUpToMaximumC\  
  14. ountWithFixedSleep(maxRetries=10sleepTime=1 SECONDS)  

需要在yarn-site.xml中添加写配置:

[html] view plaincopyprint?
  1. <property>  
  2.   <name>yarn.resourcemanager.address</name>  
  3.   <value>127.0.0.1:8032</value>  
  4. </property>  
  5. <property>  
  6.   <name>yarn.resourcemanager.scheduler.address</name>  
  7.   <value>127.0.0.1:8030</value>  
  8. </property>  
  9. <property>  
  10.   <name>yarn.resourcemanager.resource-tracker.address</name>  
  11.   <value>127.0.0.1:8031</value>  
  12. </property>  

重新启动虚拟机,再次启动服务,现在连接问题解决了。
[html] view plaincopyprint?
  1. hduser@hm1:/usr/local/hadoop$ hadoop jar ./share/hadoop/mapreduce/hadoop-mapreduce-examples-2.2.0.jar pi 2 5    
  2. Number of Maps  = 2  
  3. Samples per Map = 5  
  4. Wrote input for Map #0  
  5. Wrote input for Map #1  
  6. Starting Job  
  7. 14/02/21 18:15:53 INFO client.RMProxy: Connecting to ResourceManager at /127.0.0.1:8032  
  8. 14/02/21 18:15:54 INFO input.FileInputFormat: Total input paths to process : 2  
  9. 14/02/21 18:15:54 INFO mapreduce.JobSubmitter: number of splits:2  
  10. 14/02/21 18:15:54 INFO Configuration.deprecation: user.name is deprecated. Instead, use mapreduce.job.user.name  
  11. 14/02/21 18:15:54 INFO Configuration.deprecation: mapred.jar is deprecated. Instead, use mapreduce.job.jar  
  12. 14/02/21 18:15:54 INFO Configuration.deprecation: mapred.map.tasks.speculative.execution is deprecated. Instead, use mapreduce.map.speculative  
  13. 14/02/21 18:15:54 INFO Configuration.deprecation: mapred.reduce.tasks is deprecated. Instead, use mapreduce.job.reduces  
  14. 14/02/21 18:15:54 INFO Configuration.deprecation: mapred.output.value.class is deprecated. Instead, use mapreduce.job.output.value.class  
  15. 14/02/21 18:15:54 INFO Configuration.deprecation: mapred.reduce.tasks.speculative.execution is deprecated. Instead, use mapreduce.reduce.specul\  
  16. ative  
  17. 14/02/21 18:15:54 INFO Configuration.deprecation: mapreduce.map.class is deprecated. Instead, use mapreduce.job.map.class  
  18. 14/02/21 18:15:54 INFO Configuration.deprecation: mapred.job.name is deprecated. Instead, use mapreduce.job.name  
  19. 14/02/21 18:15:54 INFO Configuration.deprecation: mapreduce.reduce.class is deprecated. Instead, use mapreduce.job.reduce.class  
  20. 14/02/21 18:15:54 INFO Configuration.deprecation: mapreduce.inputformat.class is deprecated. Instead, use mapreduce.job.inputformat.class  
  21. 14/02/21 18:15:54 INFO Configuration.deprecation: mapred.input.dir is deprecated. Instead, use mapreduce.input.fileinputformat.inputdir  
  22. 14/02/21 18:15:54 INFO Configuration.deprecation: mapred.output.dir is deprecated. Instead, use mapreduce.output.fileoutputformat.outputdir  
  23. 14/02/21 18:15:54 INFO Configuration.deprecation: mapreduce.outputformat.class is deprecated. Instead, use mapreduce.job.outputformat.class  
  24. 14/02/21 18:15:54 INFO Configuration.deprecation: mapred.map.tasks is deprecated. Instead, use mapreduce.job.maps  
  25. 14/02/21 18:15:54 INFO Configuration.deprecation: mapred.output.key.class is deprecated. Instead, use mapreduce.job.output.key.class  
  26. 14/02/21 18:15:54 INFO Configuration.deprecation: mapred.working.dir is deprecated. Instead, use mapreduce.job.working.dir  
  27. 14/02/21 18:15:54 INFO mapreduce.JobSubmitter: Submitting tokens for job: job_1393006528872_0001  
  28. 14/02/21 18:15:54 INFO impl.YarnClientImpl: Submitted application application_1393006528872_0001 to ResourceManager at /127.0.0.1:8032  
  29. 14/02/21 18:15:55 INFO mapreduce.Job: The url to track the job: http://localhost:8088/proxy/application_1393006528872_0001/  
  30. 14/02/21 18:15:55 INFO mapreduce.Job: Running job: job_1393006528872_0001  


如果重来一次的话,顺序应该是先编译64bit版本,然后用这个版本进行配置安装。

0 0
原创粉丝点击