阿里云-云小站(无限量代金券发放中)
【腾讯云】云服务器、云数据库、COS、CDN、短信等热卖云产品特惠抢购

在Ubuntu 64位OS上运行Hadoop2.2.0[重新编译Hadoop]

152次阅读
没有评论

共计 7206 个字符,预计需要花费 19 分钟才能阅读完成。

最近在学习搭建 Hadoop,我们从 Apache 官方网站直接下载最新版本 Hadoop2.2。官方目前是提供了 linux32 位系统可执行文件,结果运行时发现提示“libhadoop.so.1.0.0 which might have disabled stack guard”的警告。Google 了一下发现是因为 hadoop 2.2.0 提供的是 libhadoop.so 库是 32 位的,而我们的机器是 64 位。解决的办法就是重新在 64 位的机器上编译 hadoop。

编译环境
OS: Ubuntu 12.04 64-bit

hadoop version: 2.2.0

Java: Jdk1.7.0_45

java 环境配置
参考这篇文章:Ubuntu 下安装 jdk1.7.0_45  http://www.linuxidc.com/Linux/2014-01/95727.htm

安装依赖包
这些库啊包啊基本都会在编译过程中用到,缺少的话会影响编译,看到 error 了再找 solution 非常麻烦,提前装好一劳永逸。

$ sudo apt-get install g++ autoconf automake libtool make cmake zlib1g-dev pkg-config libssl-dev 因为还要用到 ssh,所以如果机器上没有的话,装个 openssh 的客户端就好啦 (ubuntu 12.04 应该预装了)

$ sudo apt-get install openssh-client 当然想装 server 的话就

$ sudo apt-get install openssh-server 编译过程中还会用到 protobuf 貌似需要最新的 2.5.0,因此有低版本的也重新安装一下

安装配置 protobuf
下载最新的 protobuf-2.5.0.tar.gz:https://code.google.com/p/protobuf/downloads/list
解压,依次运行

$ ./configure –prefix=/usr
$ sudo make
$ sudo make check
$ sudo make install 检查一下版本

$ protoc –version
libprotoc 2.5.0 安装配置 maven
ubuntu 下用 apt-get 安装 maven

$ sudo apt-get install maven

创建新用户及用户组
我们为 hadoop 创建一个新组叫“hadoop”,创建一个新用户叫“hduser”属于“hadoop”组(网上都这么起名字,我们也跟风好了)

$ sudo addgroup hadoop
$ sudo adduser –ingroup hadoop hduser 有了新用户以后,我们下面的操作就都要在新用户下完成了

$ su hduser 建立 ssh 信任
hadoop 启动的时候要 ssh 访问 localhost,建立信任关系省得老输密码

$ cd /home/hduser
$ ssh-keygen -t rsa -P “”
$ cat .ssh/id_rsa.pub >> .ssh/authorized_keys 用命令验证一下是否可以免密码链接 localhost

$ ssh localhost 这是没有给 rsa 密钥设密码的情况,但是我觉得吧,一般还是给个密码好,可以用 ssh-agent 管理,以后也不许要每次都输入

$ ssh-add ~/.ssh/id_rsa.pub  # 参数写成公钥了,应该传私钥进去,感谢 twlkyao 提醒
$ ssh-add ~/.ssh/id_rsa 编译 hadoop 2.2.0
下载 hadoop 2.2.0  http://www.apache.org/dyn/closer.cgi/hadoop/common/

解压到用户目录 /home/hduser/. 进入 hadoop-2.2.0-src 目录

因为已经安装了 maven, protobuf, java 环境也有了,compiler 也有了所以直接运行

$ mvn package -Pdist,native -DskipTests -Dtar 正常应该不会有什么错误了,参数和其他编译选择请看 hadoop 目录下的 BUILDING.txt 文件

如果在编译时出现如下的错误:

[INFO] ————————————————————————
[INFO] BUILD FAILURE
[INFO] ————————————————————————
[INFO] Total time: 1:29.469s
[INFO] Finished at: Mon Nov 18 12:30:36 PST 2013
[INFO] Final Memory: 37M/120M
[INFO] ————————————————————————
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.5.1:testCompile (default-testCompile) on project hadoop-auth: Compilation failure: Compilation failure:
[ERROR] /home/chuan/trunk/hadoop-common-project/hadoop-auth/src/test/java/org/apache/hadoop/security/authentication/client/AuthenticatorTestCase.java:[84,13] cannot access org.mortbay.component.AbstractLifeCycle
[ERROR] class file for org.mortbay.component.AbstractLifeCycle not found
[ERROR] server = new Server(0);
[ERROR] /home/chuan/trunk/hadoop-common-project/hadoop-auth/src/test/java/org/apache/hadoop/security/authentication/client/AuthenticatorTestCase.java:[94,29] cannot access org.mortbay.component.LifeCycle
[ERROR] class file for org.mortbay.component.LifeCycle not found
[ERROR] server.getConnectors()[0].setHost(host);
[ERROR] /home/chuan/trunk/hadoop-common-project/hadoop-auth/src/test/java/org/apache/hadoop/security/authentication/client/AuthenticatorTestCase.java:[96,10] cannot find symbol
[ERROR] symbol  : method start()
[ERROR] location: class org.mortbay.jetty.Server
[ERROR] /home/chuan/trunk/hadoop-common-project/hadoop-auth/src/test/java/org/apache/hadoop/security/authentication/client/AuthenticatorTestCase.java:[102,12] cannot find symbol
[ERROR] symbol  : method stop()

目前的 2.2.0 的 Source Code 压缩包解压出来的 code 有个 bug 需要 patch 后才能编译。否则编译 Hadoop-auth 会提示上面错误。

解决办法如下:

修改下面的 pom 文件。该文件在 hadoop 源码包下寻找:

hadoop-common-project/hadoop-auth/pom.xml 打开上面的的 pom 文件,在 54 行加入如下的依赖:

    <dependency>
      <groupId>org.mortbay.jetty</groupId>
      <artifactId>jetty-util</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.mortbay.jetty</groupId>
      <artifactId>jetty</artifactId>
      <scope>test</scope>
    </dependency>

然后重新运行编译指令即可。编译是一个缓慢的过程,耐心等待哦。

当看到下面的信息时,编译成功。

在 Ubuntu 64 位 OS 上运行 Hadoop2.2.0[重新编译 Hadoop]

安装配置 hadoop 2.2.0
此时编译好的文件位于 hadoop-2.2.0-src/hadoop-dist/target/hadoop-2.2.0/ 目录中

具体如何配置,参考 http://www.linuxidc.com/Linux/2014-01/95729.htm。

更多 Ubuntu 相关信息见Ubuntu 专题页面 http://www.linuxidc.com/topicnews.aspx?tid=2

 

更多 Hadoop 相关信息见Hadoop 专题页面 http://www.linuxidc.com/topicnews.aspx?tid=13

 

最近在学习搭建 Hadoop,我们从 Apache 官方网站直接下载最新版本 Hadoop2.2。官方目前是提供了 linux32 位系统可执行文件,结果运行时发现提示“libhadoop.so.1.0.0 which might have disabled stack guard”的警告。Google 了一下发现是因为 hadoop 2.2.0 提供的是 libhadoop.so 库是 32 位的,而我们的机器是 64 位。解决的办法就是重新在 64 位的机器上编译 hadoop。

编译环境
OS: Ubuntu 12.04 64-bit

hadoop version: 2.2.0

Java: Jdk1.7.0_45

java 环境配置
参考这篇文章:Ubuntu 下安装 jdk1.7.0_45  http://www.linuxidc.com/Linux/2014-01/95727.htm

安装依赖包
这些库啊包啊基本都会在编译过程中用到,缺少的话会影响编译,看到 error 了再找 solution 非常麻烦,提前装好一劳永逸。

$ sudo apt-get install g++ autoconf automake libtool make cmake zlib1g-dev pkg-config libssl-dev 因为还要用到 ssh,所以如果机器上没有的话,装个 openssh 的客户端就好啦 (ubuntu 12.04 应该预装了)

$ sudo apt-get install openssh-client 当然想装 server 的话就

$ sudo apt-get install openssh-server 编译过程中还会用到 protobuf 貌似需要最新的 2.5.0,因此有低版本的也重新安装一下

安装配置 protobuf
下载最新的 protobuf-2.5.0.tar.gz:https://code.google.com/p/protobuf/downloads/list
解压,依次运行

$ ./configure –prefix=/usr
$ sudo make
$ sudo make check
$ sudo make install 检查一下版本

$ protoc –version
libprotoc 2.5.0 安装配置 maven
ubuntu 下用 apt-get 安装 maven

$ sudo apt-get install maven

创建新用户及用户组
我们为 hadoop 创建一个新组叫“hadoop”,创建一个新用户叫“hduser”属于“hadoop”组(网上都这么起名字,我们也跟风好了)

$ sudo addgroup hadoop
$ sudo adduser –ingroup hadoop hduser 有了新用户以后,我们下面的操作就都要在新用户下完成了

$ su hduser 建立 ssh 信任
hadoop 启动的时候要 ssh 访问 localhost,建立信任关系省得老输密码

$ cd /home/hduser
$ ssh-keygen -t rsa -P “”
$ cat .ssh/id_rsa.pub >> .ssh/authorized_keys 用命令验证一下是否可以免密码链接 localhost

$ ssh localhost 这是没有给 rsa 密钥设密码的情况,但是我觉得吧,一般还是给个密码好,可以用 ssh-agent 管理,以后也不许要每次都输入

$ ssh-add ~/.ssh/id_rsa.pub  # 参数写成公钥了,应该传私钥进去,感谢 twlkyao 提醒
$ ssh-add ~/.ssh/id_rsa 编译 hadoop 2.2.0
下载 hadoop 2.2.0  http://www.apache.org/dyn/closer.cgi/hadoop/common/

解压到用户目录 /home/hduser/. 进入 hadoop-2.2.0-src 目录

因为已经安装了 maven, protobuf, java 环境也有了,compiler 也有了所以直接运行

$ mvn package -Pdist,native -DskipTests -Dtar 正常应该不会有什么错误了,参数和其他编译选择请看 hadoop 目录下的 BUILDING.txt 文件

如果在编译时出现如下的错误:

[INFO] ————————————————————————
[INFO] BUILD FAILURE
[INFO] ————————————————————————
[INFO] Total time: 1:29.469s
[INFO] Finished at: Mon Nov 18 12:30:36 PST 2013
[INFO] Final Memory: 37M/120M
[INFO] ————————————————————————
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.5.1:testCompile (default-testCompile) on project hadoop-auth: Compilation failure: Compilation failure:
[ERROR] /home/chuan/trunk/hadoop-common-project/hadoop-auth/src/test/java/org/apache/hadoop/security/authentication/client/AuthenticatorTestCase.java:[84,13] cannot access org.mortbay.component.AbstractLifeCycle
[ERROR] class file for org.mortbay.component.AbstractLifeCycle not found
[ERROR] server = new Server(0);
[ERROR] /home/chuan/trunk/hadoop-common-project/hadoop-auth/src/test/java/org/apache/hadoop/security/authentication/client/AuthenticatorTestCase.java:[94,29] cannot access org.mortbay.component.LifeCycle
[ERROR] class file for org.mortbay.component.LifeCycle not found
[ERROR] server.getConnectors()[0].setHost(host);
[ERROR] /home/chuan/trunk/hadoop-common-project/hadoop-auth/src/test/java/org/apache/hadoop/security/authentication/client/AuthenticatorTestCase.java:[96,10] cannot find symbol
[ERROR] symbol  : method start()
[ERROR] location: class org.mortbay.jetty.Server
[ERROR] /home/chuan/trunk/hadoop-common-project/hadoop-auth/src/test/java/org/apache/hadoop/security/authentication/client/AuthenticatorTestCase.java:[102,12] cannot find symbol
[ERROR] symbol  : method stop()

正文完
星哥说事-微信公众号
post-qrcode
 
星锅
版权声明:本站原创文章,由 星锅 2022-01-20发表,共计7206字。
转载说明:除特殊说明外本站文章皆由CC-4.0协议发布,转载请注明出处。
【腾讯云】推广者专属福利,新客户无门槛领取总价值高达2860元代金券,每种代金券限量500张,先到先得。
阿里云-最新活动爆款每日限量供应
评论(没有评论)
验证码
【腾讯云】云服务器、云数据库、COS、CDN、短信等云产品特惠热卖中