我在Linux机器上安装了Cassandra,Sqoop和MySql。
1)在MySql中创建了一个小表,语法如下。
CREATE TABLE TEST_ONE(
test_id INT NOT NULL AUTO_INCREMENT,
test_title VARCHAR(100) NOT NULL,
PRIMARY KEY ( test_id )
);
2)尝试从MySql运行sudo dse sqoop导入到Cassandra
sudo dse sqoop import --connect jdbc:mysql://127.0.0.1/test --username {username} --password {password} --verbose --table TEST_ONE --cassandra-keyspace TEST_ONE_KS --cassandra-column-family TEST_ONE_CF --cassandra-row-key id --cassandra-thrift-host 127.0.0.1 --cassandra-create-schema
跑了几分钟后,它就会挂起。如果我们在 / var / lib / cassandra / data / 路径下检查后端,则存在Keyspace和Column Family。但数据没有得到更新。
无法弄清楚出了什么问题。
请帮忙。
谢谢 阿克斯
答案 0 :(得分:2)
所以我重新创建了你的mysql表
mysql> select * from TEST_ONE;
+---------+------------+
| test_id | test_title |
+---------+------------+
| 1 | hi |
| 2 | there |
| 3 | foo |
| 4 | bar |
| 5 | spam |
| 6 | DSE QA |
+---------+------------+
6 rows in set (0.00 sec)
并使用了你的sqoop命令(但我开启了在cassandra资源目录中调试我的log4j-server文件)
automaton@ip-10-235-42-75:~$ sudo dse/bin/dse sqoop import --connect jdbc:mysql://127.0.0.1/test --username qa --password qapass --verbose --table TEST_ONE --cassandra-keyspace TEST_ONE_KS --cassandra-column-family TEST_ONE_CF --cassandra-row-key id --cassandra-thrift-host 127.0.0.1 --cassandra-create-schema
但我马上得到了
14/01/10 17:09:28 INFO mapreduce.ImportJobBase: Beginning import of TEST_ONE
14/01/10 17:09:29 DEBUG mapreduce.DataDrivenImportJob: Using table class: TEST_ONE
14/01/10 17:09:29 DEBUG mapreduce.DataDrivenImportJob: Using InputFormat: class com.cloudera.sqoop.mapreduce.db.DataDrivenDBInputFormat
14/01/10 17:09:29 DEBUG manager.SqlManager: No connection paramenters specified. Using regular API for making connection.
14/01/10 17:09:29 ERROR tool.ImportTool: Encountered IOException running import job: java.io.IOException: The row-key column specified by --cassandra-row-key is not found in the input.
at org.apache.sqoop.mapreduce.CassandraImportJob.configureOutputFormat(CassandraImportJob.java:133)
at org.apache.sqoop.mapreduce.ImportJobBase.runImport(ImportJobBase.java:195)
at org.apache.sqoop.manager.SqlManager.importTable(SqlManager.java:475)
at org.apache.sqoop.manager.MySQLManager.importTable(MySQLManager.java:108)
at org.apache.sqoop.tool.ImportTool.importTable(ImportTool.java:403)
at org.apache.sqoop.tool.ImportTool.run(ImportTool.java:476)
at org.apache.sqoop.Sqoop.run(Sqoop.java:145)
at org.apache.hadoop.util.ToolRunner.run(ToolRunner.java:65)
at org.apache.sqoop.Sqoop.runSqoop(Sqoop.java:181)
at org.apache.sqoop.Sqoop.runTool(Sqoop.java:220)
at org.apache.sqoop.Sqoop.runTool(Sqoop.java:229)
at org.apache.sqoop.Sqoop.main(Sqoop.java:238)
at com.cloudera.sqoop.Sqoop.main(Sqoop.java:57)
你的cassandra-row-key id应该是责备而且应该是test_id,改变它并且你应该工作。你最终会得到这个。
cqlsh> select * from "TEST_ONE_KS"."TEST_ONE_CF";
key | column1 | value
-----+------------+--------
6 | test_title | DSE QA
4 | test_title | bar
3 | test_title | foo
5 | test_title | spam
2 | test_title | there
1 | test_title | hi