本人按照http://www.haogongju.net/art/1219370这里介绍的流程配置好了sqoop,大家可以看到
[[email protected] lib]# whereis sqoop
sqoop: /usr/bin/sqoop /etc/sqoop /usr/lib/sqoop /usr/local/sqoop /usr/share/man/man1/sqoop.1.gz
我执行
列出mysql数据库中的所有数据[[email protected] sqoop]#sqoop list-databases --connect jdbc:mysql://localhost:3306/ --username root --password `cat /data/save/mysql_root`
连接mysql并列出数据库中的表命令[[email protected] sqoop]#sqoop list-tables --connect jdbc:mysql://localhost:3306/aa --username root --password `cat /data/save/mysql_root`将关系型数据的表结构复制到hive中
[[email protected] sqoop]# sqoop create-hive-table --connect jdbc:mysql://localhost:3306/aa --table mysql_total --username root --password `cat /data/save/mysql_root` --hive-table test
这里没有问题的。
但是到了第4,第5个命令就有问题了。要知道,这两步对于我们项目来说,是最紧急的一两步。
sqoop export --connect jdbc:mysql://localhost:3306/aa --username root --password 123456 --table mysql_total --export-dir hdfs://localhost:9000/user/hive/warehouse/total_count
上面是我敲的命令,报错如下:
Warning: /usr/lib/hbase does not exist! HBase imports will fail.
Please set $HBASE_HOME to the root of your HBase installation.
12/01/13 11:15:23 WARN tool.BaseSqoopTool: Setting your password on the command-line is insecure. Consider using -P instead.
12/01/13 11:15:23 INFO manager.MySQLManager: Preparing to use a MySQL streaming resultset.
12/01/13 11:15:23 INFO tool.CodeGenTool: Beginning code generation
12/01/13 11:15:26 INFO manager.SqlManager: Executing SQL statement: SELECT t.* FROM `mysql_total` AS t LIMIT 1
12/01/13 11:15:26 INFO orm.CompilationManager: HADOOP_HOME is /usr/lib/hadoop
12/01/13 11:15:26 INFO orm.CompilationManager: Found hadoop core jar at: /usr/lib/hadoop/hadoop-core.jar
12/01/13 11:15:48 ERROR orm.CompilationManager: Could not rename /tmp/sqoop-root/compile/2b0c38051a72dc3ef11c09849d697368/mysql_total.java to /usr/lib/sqoop/lib/./mysql_total.java
java.io.IOException: Destination '/usr/lib/sqoop/lib/./mysql_total.java' already exists
at org.apache.commons.io.FileUtils.moveFile(FileUtils.java:1811)
at com.cloudera.sqoop.orm.CompilationManager.compile(CompilationManager.java:229)
at com.cloudera.sqoop.tool.CodeGenTool.generateORM(CodeGenTool.java:85)
at com.cloudera.sqoop.tool.ExportTool.exportTable(ExportTool.java:66)
at com.cloudera.sqoop.tool.ExportTool.run(ExportTool.java:99)
at com.cloudera.sqoop.Sqoop.run(Sqoop.java:146)
at org.apache.hadoop.util.ToolRunner.run(ToolRunner.java:65)
at com.cloudera.sqoop.Sqoop.runSqoop(Sqoop.java:182)
at com.cloudera.sqoop.Sqoop.runTool(Sqoop.java:221)
at com.cloudera.sqoop.Sqoop.runTool(Sqoop.java:230)
at com.cloudera.sqoop.Sqoop.main(Sqoop.java:239)
12/01/13 11:15:48 INFO orm.CompilationManager: Writing jar file: /tmp/sqoop-root/compile/2b0c38051a72dc3ef11c09849d697368/mysql_total.jar
12/01/13 11:15:53 INFO mapreduce.ExportJobBase: Beginning export of mysql_total
12/01/13 11:15:58 ERROR tool.ExportTool: Encountered IOException running export job: org.apache.hadoop.ipc.RPC$VersionMismatch: Protocol org.apache.hadoop.hdfs.protocol.ClientProtocol version mismatch. (client = 63, server = 61)
百思不得其解,不知道我哪里还没有配置好,请各位帮忙看下,谢谢了!
------解决方案--------------------
http://www.54chen.com/java-ee/sqoop-mysql-to-hive.html
6.修改configure-sqoop
注释掉hbase zookeeper检查:
#if [ ! -d "${HBASE_HOME}" ]; then
# echo "Error: $HBASE_HOME does not exist!"
# echo 'Please set $HBASE_HOME to the root of your HBase installation.'
# exit 1
#fi
#if [ ! -d "${ZOOKEEPER_HOME}" ]; then
# echo "Error: $ZOOKEEPER_HOME does not exist!"
# echo 'Please set $ZOOKEEPER_HOME to the root of your ZooKeeper installation.'
# exit 1
#fi