使用 sqoop-1.99.3-bin-hadoop200
配置如下
1.解压
tar -xvf sqoop--bin-hadoop.tar.gz
2.加入配置文件 server/conf/catalina.properties 中的common.loader 属性加入hadoop2的lib
因为hadoop_home 下的lib是空的 所以指向
/home/hadoop-2.3.0/share/hadoop/common/*.jar
/home/hadoop-2.3.0/share/hadoop/common/lib/*.jar
/home/hadoop-2.3.0/share/hadoop/yarn/*.jar
/home/hadoop-2.3.0/share/hadoop/hdfs/*.jar
/home/hadoop-2.3.0/share/hadoop/mapreduce/*.jar
启动后发现有问题, 查看 sqoop_home/server/log 报错了
Mar 19, 2014 8:08:55 AM org.apache.catalina.core.StandardContext listenerStart
SEVERE: Exception sending context initialized event to listener instance of class org.apache.sqoop.server.ServerInitializer
java.lang.RuntimeException: Failure in server initialization
at org.apache.sqoop.core.SqoopServer.initialize(SqoopServer.java:57)
Caused by: org.apache.sqoop.common.SqoopException: MAPREDUCE_0002:Failure on submission engine initialization - Invalid Hadoop configuration directory (not a directory or permission issues): /etc/hadoop/conf/
at org.apache.sqoop.submission.mapreduce.MapreduceSubmissionEngine.initialize(MapreduceSubmissionEngine.java:94)
at org.apache.sqoop.framework.JobManager.initialize(JobManager.java:215)
at org.apache.sqoop.core.SqoopServer.initialize(SqoopServer.java:53)
... 25 more
找到了 server/conf/sqoop.properties 里面的属性要改成
# Hadoop configuration directory
#org.apache.sqoop.submission.engine.mapreduce.configuration.directory=/etc/hadoop/conf/
org.apache.sqoop.submission.engine.mapreduce.configuration.directory=/home/hadoop-2.3.0/etc/hadoop
查看log 没有错误.进入./bin/sqoop.sh client
show version --all 查看有没错误。再次确认启动成功.
建立一个connection 根据提示输入
create connection --cid 1 (connection id为1)
Creating connection for connector with id 1
Please fill following values to create new connection object
Name: VPRCFJTBCOBI-02
Connection configuration
JDBC Driver Class: com.microsoft.sqlserver.jdbc.SQLServerDriver
JDBC Connection String: jdbc:sqlserver://VPRCFJTBCOBI-02\\BOE140:62064;DatabaseName=AdventureWorksDW2008R2;useUnicode=true;characterEncoding=UTF-8
Username: sa
Password: ********
JDBC Connection Properties:
There are currently 0 values in the map:
entry#
Security related configuration options
Max connections: 0
New connection was successfully created with validation status FINE and persistent id 2
查看下成果
show connector
+----+------------------------+---------+------------------------------------------------------+
| Id | Name | Version | Class |
+----+------------------------+---------+------------------------------------------------------+
| 1 | generic-jdbc-connector | 1.99.3 | org.apache.sqoop.connector.jdbc.GenericJdbcConnector |
show connection
+----+-----------------+-----------+---------+
| Id | Name | Connector | Enabled |
+----+-----------------+-----------+---------+
| 2 | VPRCFJTBCOBI-02 | 1 | true |
+----+-----------------+-----------+---------+
PS 建错了connection 就删了 delete connection --xid 1 也可以update connection --xid 1