编译环境
- ubuntu 16.04 64bit
- jdk 1.7.0_79
- maven 3.3.9
- hadoop-2.7.3-src
必须的安装包
安装jdk
tar zxf jdk-7u79-linux-x64.tar.gz
sudo vim /etc/profile
export JAVA_HOME=/opt/jdk1.7.0_79
export PATH=$JAVA_HOME/bin:$PATH
source /etc/profile
java -version
安装mvn
tar zxf apache-maven-3.3.9-bin.tar.gz
sudo vim /etc/profile
export MAVEN_HOME=/opt/maven3.3.9
export PATH=$MAVEN_HOME/bin
source /etc/profilr
mvn -version
配置本地仓库路径
<localRepository>/opt/mava-3.3.9/repository</localRepository>
更换阿里云maven镜像(强烈推荐更换)
<mirrors>
<mirror>
<id>nexus-aliyun</id>
<mirrorOf>*</mirrorOf>
<name>Nexus aliyun</name>
<url>http://maven.aliyun.com/nexus/content/groups/public</url>
</mirror>
</mirrors>
Native libraries
sudo apt-get -y install build-essential autoconf automake libtool cmake zlib1g-dev pkg-config libssl-dev
ProtocolBuffer 2.5.0
sudo apt-get -y install libprotobuf-dev protobuf-compiler
这里有坑,安装的2.6.1的
安装好了以后可以查看下具体安装的版本
protoc --verison
如果输出的不是
libprotoc 2.5.0
可以看后面的ProtocolBuffer版本解决办法
可选的安装包
Snappy compression
sudo apt-get install snappy libsnappy-dev
Bzip2
sudo apt-get install bzip2 libbz2-dev
Jansson (C Library for JSON)
sudo apt-get install libjansson-dev
Linux FUSE
sudo apt-get install fuse libfuse-dev
编译eclipse plugin
切换到root,编译hadoop-maven-plugins
su root
>不切换会报错的(hadoop-maven-plugins/target/antrun/build-main.xml(No sucn file or directory))
cd HADOOP_SRC/hadoop-maven-plugins
mvn install
生成eclipse项目
cd ..
mvn eclipse:eclipse -DskipTests
ProtocolBuffer版本问题解决办法
如果安装的不是2.5.0版本的ProtocolBuffer,在编译的时候会报错
protoc version is 'libprotoc 2.6.1', expected version is '2.5.0'
先卸载libbprotoc
sudo apt-get purge libprotobuf-dev protobuf-compiler
下载protobuf-2.5.0.tar.gz
解压,安装
sudo tar zxf protobuf-2.5.0.tar.gz
./configure
make
make check
make install
查看版本
protoc --version
如果正确安装的话
报错
protoc: error while loading shared libraries: libprotoc.so.8:cannot open shared object file:No such file or directory
protobuf的默认安装路径是/usr/local/lib,而/usr/local/lib不在ubuntu体系默认的LD_LIBRARY_PATH里,所以就找不到lib
需要让系统找到protobuf
cd /etc/ld.so.conf.d/
sudo vim bprotobuf.conf
输入一下内容
/usr/local/lib
保存并退出,输入如下命令,重新加载配置文件
sudo ldconfig
再次输入
protoc --version
可以得到输出
libprotoc 2.5.0
编译好的源码(eclipse可直接导入)
下载链接:http://pan.baidu.com/s/1kVdk3tH,密码:9q7m
eclipse->import->Existing Maven Projects