1、下载sqoop到/usr/local:wget http://archive.cloudera.com/cdh4/cdh/4/sqoop-1.4.3-cdh4.6.0.tar.gz
2、解压:tar -zxvf sqoop-1.4.3-cdh4.6.0.tar.gz
3、重命名:mv sqoop-1.4.3-cdh4.6.0 sqoop
4、添加环境变量/etc/profile:
export SQOOP_HOME=/usr/local/sqoop
export CLASSPATH=.:$CLASSPATH:$SQOOP_HOME/lib
export PATH=$PATH:$SQOOP_HOME/bin
5、验证安装:sqoop help
6、可能会抛异常:
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/sqoop/Sqoop
Caused by: java.lang.ClassNotFoundException: org.apache.sqoop.Sqoop
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
一看就是找不到jar包,这个问题困扰了我1天,各种修改lib,没用,网上找到的英文资料都没用(版本太新,没有中文资料)。【大坑】解决办法:
去$SQOOP_HOME/bin下,修改sqoop脚本:
修改前:exec ${Hadoop_COMMON_HOME}/bin/hadoop org.apache.sqoop.Sqoop "$@"
修改后:exec ${HADOOP_COMMON_HOME}/bin/hadoop jar $SQOOP_HOME/lib/sqoop-1.4.3-cdh4.5.0.jar org.apache.sqoop.Sqoop "$@"
由此可见,由于使用了hadoop命令,所以在安装sqoop-1.4.3-cdh4.5.0的机器上必选先安装hadoop