安装java8环境

之前已经安装好的话可跳过这一步

使用root用户操作
下载Java 8SE
jdk-8u241-linux-x64.tar.gz

安装Java 8SE
cd /root/Desktop/1 #该目录是介质所在目录
tar xvfz jdk-8u241-linux-x64.tar.gz -C /usr

ln -s /usr/jdk1.8.0_241 /usr/jdk
cat>> **/etc/profile**<<EOF

JAVA_HOME=/usr/jdk
export JAVA_HOME
CLASSPATH=.:\$JAVA_HOME/lib:\$CLASSPATH
export CLASSPATH
PATH=\$JAVA_HOME/bin:\$PATH
export PATH
EOF

使配置文件生效
source /etc/profile

查看java是否安装成功
java -version
image.png

下载Hadoop 2.7.7源代码并编译

编译hadoop2.7.7可参考之前的文档:https://www.yuque.com/duyanyao/bn83p9/cg72bi

以root用户执行如下:
cd /opt
mkdir hadoop-2.7.7
chown hadoop.hadoop hadoop-2.7.7/
ln -s /opt/hadoop-2.7.7 /opt/hadoop
chown hadoop.hadoop hadoop

以hadoop用户执行如下:
cd /home/hadoop/Desktop/1
tar xvfz hadoop-2.7.7.tar.gz -C /opt

下载hadoop2x-eclipse-plugin源代码:

下载地址是https://github.com/winghc/hadoop2x-eclipse-plugin

以hadoop用户执行
cd /home/hadoop/Desktop/1
unzip hadoop2x-eclipse-plugin-master.zip

下载并安装eclipse

eclipse-java-oxygen-3a-linux-gtk-x86_64.tar.gz

创建Eclipse安装目录

以root用户的身份执行如下:
mkdir /opt/eclipse
chown -R hadoop.hadoop /opt/eclipse

解压Eclipse软件

用hadoop用户执行如下:
cd /home/hadoop/Desktop/1 #该目录是介质所在目录
tar xvfz eclipse-java-oxygen-3a-linux-gtk-x86_64.tar.gz -C /opt

cat>> /etc/profile<<EOF

export ECLIPSE_HOME=/opt/eclipse
export PATH=\$ECLIPSE_HOME:\$PATH

EOF

下载并安装Ant

下载地址:https://ant.apache.org/bindownload.cgi
apache-ant-1.9.4-bin.tar.gz
以root用户执行如下:
cd /root/Desktop/1
tar xvfz apache-ant-1.9.4-bin.tar.gz -C /usr
mv /usr/apache-ant-1.9.4 /usr/ant

cat>> /etc/profile<<EOF

export ANT_HOME=/usr/ant
export PATH=\$ANT_HOME/bin:\$PATH

EOF

使配置文件生效
source /etc/profile
查看ant版本:
ant -version
image.png

修改依赖包版本文件libraries.properties

参考目录/opt/hadoop/share/hadoop/common/lib中的文件,来修改libraries.properties相应的版本号。
cd /opt/hadoop/share/hadoop/common/lib
ls
image.png
对 libraries.properties进行修改
cd /home/hadoop/Desktop/1/hadoop2x-eclipse-plugin-master/ivy
vi libraries.properties

编辑完成后查看该文件的内容
cat libraries.properties

  1. # Licensed under the Apache License, Version 2.0 (the "License");
  2. # you may not use this file except in compliance with the License.
  3. # You may obtain a copy of the License at
  4. #
  5. # http://www.apache.org/licenses/LICENSE-2.0
  6. #
  7. # Unless required by applicable law or agreed to in writing, software
  8. # distributed under the License is distributed on an "AS IS" BASIS,
  9. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. # See the License for the specific language governing permissions and
  11. # limitations under the License.
  12. #This properties file lists the versions of the various artifacts used by hadoop and components.
  13. #It drives ivy and the generation of a maven POM
  14. # This is the version of hadoop we are generating
  15. hadoop.version=2.7.7
  16. hadoop-gpl-compression.version=0.1.0
  17. #These are the versions of our dependencies (in alphabetical order)
  18. apacheant.version=1.9.4
  19. ant-task.version=2.0.10
  20. asm.version=3.2
  21. aspectj.version=1.6.5
  22. aspectj.version=1.6.11
  23. checkstyle.version=4.2
  24. commons-cli.version=1.2
  25. commons-codec.version=1.4
  26. commons-collections.version=3.2.2
  27. commons-configuration.version=1.6
  28. commons-daemon.version=1.0.13
  29. commons-httpclient.version=3.1
  30. commons-lang.version=2.6
  31. commons-logging.version=1.1.3
  32. commons-logging-api.version=1.1.3
  33. commons-math.version=3.1.1
  34. commons-el.version=1.0
  35. commons-fileupload.version=1.2
  36. commons-io.version=2.4
  37. commons-net.version=3.1
  38. core.version=3.1.1
  39. coreplugin.version=1.3.2
  40. hsqldb.version=1.8.0.10
  41. htrace.version=3.1.0
  42. ivy.version=2.1.0
  43. jasper.version=5.5.12
  44. jackson.version=1.9.13
  45. #not able to figureout the version of jsp & jsp-api version to get it resolved throught ivy
  46. # but still declared here as we are going to have a local copy from the lib folder
  47. jsp.version=2.1
  48. jsp-api.version=2.1
  49. jsp-api-2.1.version=6.1.14
  50. jsp-2.1.version=6.1.14
  51. jets3t.version=0.9.0
  52. jetty.version=6.1.26
  53. jetty-util.version=6.1.26
  54. jersey-core.version=1.8
  55. jersey-json.version=1.8
  56. jersey-server.version=1.8
  57. junit.version=4.11
  58. jdeb.version=0.8
  59. jdiff.version=1.0.9
  60. json.version=1.0
  61. kfs.version=0.1
  62. log4j.version=1.2.17
  63. lucene-core.version=2.3.1
  64. mockito-all.version=1.8.5
  65. jsch.version=0.1.42
  66. oro.version=2.0.8
  67. rats-lib.version=0.5.1
  68. servlet.version=4.0.6
  69. servlet-api.version=2.5
  70. slf4j-api.version=1.7.10
  71. slf4j-log4j12.version=1.7.10
  72. wagon-http.version=1.0-beta-2
  73. xmlenc.version=0.52
  74. xerces.version=1.4.4
  75. protobuf.version=2.5.0
  76. guava.version=11.0.2
  77. netty.version=3.6.2.Final

修改build.xml文件

cd /home/hadoop/Desktop/1/hadoop2x-eclipse-plugin-master/src/contrib/eclipse-plugin
vi build.xml
添加以下绿色的行(如果有就不需要!)















删除替换**
删除以下行

替换成

删除lib的最后一行
image.png
lib/servlet-api-${servlet-api.version}.jar
lib/commons-io-${commons-io.version}.jar
lib/htrace-core-${htrace.version}-incubating.jar”/>

修改代码
修改文件build.xml(位置:…\hadoop2x-eclipse-plugin-master\src\contrib\eclipse-plugin)
把这一行(大概在68行左右)原来的target中的depends=“init, ivy-retrieve-common” 去掉其中的 ivy-retrieve-common后重新编译

cd /home/hadoop/Desktop/1/hadoop2x-eclipse-plugin-master/src/contrib/eclipse-plugin
vi build.xml
set nu #显示行号

编译eclipse插件

cd /home/hadoop/Desktop/1/hadoop2x-eclipse-plugin-master/src/contrib/eclipse-plugin

ant jar -Dversion=2.7.7 -Dhadoop.version=2.7.7 -Declipse.home=/opt/eclipse -Dhadoop.home=/opt/hadoop -debug

version: plugin version
hadoop.version: hadoop version you want to compiled with
eclipse.home: path of eclipse home
hadoop.home: path of hadoop 2.x home
image.png

编译好的jar包

cd /home/hadoop/Desktop/1/hadoop2x-eclipse-plugin-master/build/contrib/eclipse-plugin
ls
image.png

错误:
1.bash: ls: command not found…
Similar command is: ‘lz
https://blog.csdn.net/u013129944/article/details/53906148
解决办法:
使用绝对命令vi打开profile
/bin/vi /etc/profile
添加:
export PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin