本文转载自http://blog.csdn.net/liuwenbo0920/article/details/40504045
1.安装准备工作:
已经装好的hadoop环境是hadoop 2.2.0
下载的sqoop安装包(注意是hadoop200)
下载sqoop wget http://mirrors.cnnic.cn/apache/sqoop/1.99.6/sqoop-1.99.3-bin-hadoop200.tar.gz
2.解压文件到工作目录:
将sqoop解压到目标目录,我的是 /opt/soft/sqoop-1.99.3-bin-hadoop200
配置环境变量:
- export SQOOP_HOME=/opt/soft/sqoop-1.99.3-bin-hadoop200
- export CATALINA_HOME=$SQOOP_HOME/server
- export LOGDIR=$SQOOP_HOME/logs
- export PATH=$SQOOP_HOME/bin:$PATH
保存退出即时生效:
source /etc/profile
3.修改sqoop配置:
vi /opt/soft/sqoop-1.99.3-bin-hadoop200/server/conf/sqoop.properties
在文件中找到org.apache.sqoop.submission.engine.mapreduce.configuration.directory,用Hadoop的配置文件目录赋值,最终效果如下:
org.apache.sqoop.submission.engine.mapreduce.configuration.directory=/opt/soft/hadoop-2.2.0/etc/hadoop
4.修改配置文件:
修改配置文件catalina.properties:
vim $SQOOP_HOME/server/conf/catalina.properties
在文件中找到common.loader,在其后添加hadoop相关jar包路径,最终效果如下
- common.loader=${catalina.base}/lib,
- ${catalina.base}/lib/*.jar,
- ${catalina.home}/lib,
- ${catalina.home}/lib/*.jar,
- ${catalina.home}/../lib/*.jar,
- /opt/soft/hadoop-2.2.0/share/hadoop/common/*.jar,
- /opt/soft/hadoop-2.2.0/share/hadoop/common/lib/*.jar,
- /opt/soft/hadoop-2.2.0/share/hadoop/hdfs/*.jar,
- /opt/soft/hadoop-2.2.0/share/hadoop/hdfs/lib/*.jar,
- /opt/soft/hadoop-2.2.0/share/hadoop/mapreduce/*.jar,
- /opt/soft/hadoop-2.2.0/share/hadoop/mapreduce/lib/*.jar,
- /opt/soft/hadoop-2.2.0/share/hadoop/tools/*.jar,
- /opt/soft/hadoop-2.2.0/share/hadoop/tools/lib/*.jar,
- /opt/soft/hadoop-2.2.0/share/hadoop/yarn/*.jar,
- /opt/soft/hadoop-2.2.0/share/hadoop/yarn/lib/*.jar,
- /opt/soft/hadoop-2.2.0/share/hadoop/httpfs/tomcat/lib/*.jar
安装中遇到的问题:
我在启动show version --all时,出现GET http://localhost:12000/sqoop/version returned a response status of 404 Not Found
后来查看日志,发现时log4j的原因。
由于在catalina.properties配置文件的common.loader属性中配置引入了所有的hadoop相关jar包,而hadoop的lib目录下是有log4j包的,只是版本和sqoop自带的log4j不一致。
我们需要将/opt/soft/sqoop-1.99.3-bin-hadoop200/server/webapps/sqoop/WEB-INF/lib目录下的log4j-1.2.16.jar移除即可。
发现还是不能解决,日志仍然抱 java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory ,于是手动将hadoop的jar包全部copy出来,
然后复制到/opt/soft/sqoop-1.99.3-bin-hadoop200/server/webapps/sqoop/WEB-INF/lib目录下,还原common.loader中修改的内容,然后启动就好了。
5.下载mysql驱动包
mysql-connector-java-5.1.16-bin.jar 第三步,jar包相关工作:
我拷贝到了两个目录 $SQOOP_HOME/server/lib 下
6.启动/停止sqoop200
./bin/sqoop.sh server start
./bin/sqoop.sh server stop
查看启动日志:
hadoop@hadoopMaster:/usr/local/sqoop/server/logs$ vim catalina.out
7.进入客户端交互目录
bin/sqoop.sh client