使用Sqoop从MySQL导入到Cassandra的自由格式查询

时间:2014-05-05 11:04:29

标签: mysql cassandra sqoop datastax-enterprise

我正在使用DataStax Enterprise 4.0.2。我正在尝试使用与DSE捆绑在一起的Sqoop,将数据从MySQL导入到Cassandra。 Sqoop命令是: -

dse sqoop import --connect jdbc:mysql://192.168.10.98/mydb --username user1 
--password password --outdir /root/dev/output/dir/ --query "SELECT tab1.col1 AS 
COL1, tab1.col2 AS COL2, tab1.col3 AS COL3 FROM table1 AS tab1 WHERE \$CONDITIONS
AND tab1.col1 != 'XYZ' AND tab1.col2 != 2 GROUP BY tab1.col1, tab1.col2" 
--target-dir /root/dev/cassdir --split-by tab1.col1 --cassandra-keyspace csks 
--cassandra-column-family cscf --cassandra-thrift-host localhost 
--cassandra-create-schema --verbose

Keyspace和Columnfamily正在创建,但没有数据。列家族的结构也就像一个虚拟的结构: -

cqlsh> DESC KEYSPACE csks

CREATE KEYSPACE ga WITH replication = {
  'class': 'SimpleStrategy',
  'replication_factor': '1'
};

USE csks;

CREATE TABLE cscf (
  key text,
  column1 text,
  value text,
  PRIMARY KEY (key, column1)
) WITH COMPACT STORAGE AND
  bloom_filter_fp_chance=0.010000 AND
  caching='KEYS_ONLY' AND
  comment='' AND
  dclocal_read_repair_chance=0.000000 AND
  gc_grace_seconds=864000 AND
  index_interval=128 AND
  read_repair_chance=0.100000 AND
  replicate_on_write='true' AND
  populate_io_cache_on_flush='false' AND
  default_time_to_live=0 AND
  speculative_retry='NONE' AND
  memtable_flush_period_in_ms=0 AND
  compaction={'class': 'SizeTieredCompactionStrategy'} AND
  compression={'sstable_compression': 'LZ4Compressor'};

Sqoop输出中没有错误。我应该在哪里查找详细的日志?

1 个答案:

答案 0 :(得分:0)

因为您使用了--target-dir,所以输出结果将在" cfs"文件系统,而不是表格。

自:
http://www.datastax.com/documentation/datastax_enterprise/4.0/datastax_enterprise/ana/anaSqpVld.html

" hadoop fs"命令可用于查看导入。

./dse hadoop fs -ls /root/dev/cassdir

既然您还指定了cassandra列系列并创建了选项,那么这些选项已经完成,这在这里令人困惑。在DSE 4.0中,sqoop表创建代码仍然使用cql2,因此使用cql3的cqlsh中的表看起来有点奇怪。要将数据放入cql3表,将其放入cfs后,可以使用hive将其插入到cassandra中:
http://www.datastax.com/documentation/datastax_enterprise/4.0/datastax_enterprise/ana/anaSqpMgrate.html

在执行此操作之前,您将要删除已创建的cql2表。

相关问题