在cassandra上使用sstableloader时出错

时间:2015-02-20 15:29:58

标签: cassandra

我是一名卡桑德拉新手。我在Cassandra cqlsh 5.0.1中看到以下错误Cassandra 2.1.2 | CQL规范3.2.0

以下是我在使用sstableloader时看到的错误:

./sstableloader -d <hostname> -u <user> -pw <pass> <filename>
Could not retrieve endpoint ranges: 
java.lang.IllegalArgumentException
java.lang.RuntimeException: Could not retrieve endpoint ranges: 
    at org.apache.cassandra.tools.BulkLoader$ExternalClient.init(BulkLoader.java:337)
    at org.apache.cassandra.io.sstable.SSTableLoader.stream(SSTableLoader.java:157)
    at org.apache.cassandra.tools.BulkLoader.main(BulkLoader.java:105)
Caused by: java.lang.IllegalArgumentException
    at java.nio.Buffer.limit(Buffer.java:275)
    at org.apache.cassandra.utils.ByteBufferUtil.readBytes(ByteBufferUtil.java:543)
    at org.apache.cassandra.serializers.CollectionSerializer.readValue(CollectionSerializer.java:122)
    at org.apache.cassandra.serializers.MapSerializer.deserializeForNativeProtocol(MapSerializer.java:99)
    at org.apache.cassandra.serializers.MapSerializer.deserializeForNativeProtocol(MapSerializer.java:28)
    at org.apache.cassandra.serializers.CollectionSerializer.deserialize(CollectionSerializer.java:48)
    at org.apache.cassandra.db.marshal.AbstractType.compose(AbstractType.java:66)
    at org.apache.cassandra.cql3.UntypedResultSet$Row.getMap(UntypedResultSet.java:282)
    at org.apache.cassandra.config.CFMetaData.fromSchemaNoTriggers(CFMetaData.java:1793)
    at org.apache.cassandra.config.CFMetaData.fromThriftCqlRow(CFMetaData.java:1101)
    at org.apache.cassandra.tools.BulkLoader$ExternalClient.init(BulkLoader.java:329)
    ... 2 more

奇怪的是,我仅针对特定键空间获得此错误。当我创建一个新的密钥空间(使用与问题密钥空间完全相同的命令并尝试sstableloader时,我没有看到同样的问题。当我设置DEBUG日志级别时,我看到以下内容:

DEBUG [Thrift:1] 2015-02-20 00:32:38,006 CustomTThreadPoolServer.java:212 - Thrift transport error occurred during processing of message.
org.apache.thrift.transport.TTransportException: null
    at org.apache.thrift.transport.TIOStreamTransport.read(TIOStreamTransport.java:132) ~[libthrift-0.9.1.jar:0.9.1]
    at org.apache.thrift.transport.TTransport.readAll(TTransport.java:84) ~[libthrift-0.9.1.jar:0.9.1]
    at org.apache.thrift.transport.TFramedTransport.readFrame(TFramedTransport.java:129) ~[libthrift-0.9.1.jar:0.9.1]
    at org.apache.thrift.transport.TFramedTransport.read(TFramedTransport.java:101) ~[libthrift-0.9.1.jar:0.9.1]
    at org.apache.thrift.transport.TTransport.readAll(TTransport.java:84) ~[libthrift-0.9.1.jar:0.9.1]
    at org.apache.thrift.protocol.TBinaryProtocol.readAll(TBinaryProtocol.java:362) ~[libthrift-0.9.1.jar:0.9.1]
    at org.apache.thrift.protocol.TBinaryProtocol.readI32(TBinaryProtocol.java:284) ~[libthrift-0.9.1.jar:0.9.1]
    at org.apache.thrift.protocol.TBinaryProtocol.readMessageBegin(TBinaryProtocol.java:191) ~[libthrift-0.9.1.jar:0.9.1]
    at org.apache.thrift.TBaseProcessor.process(TBaseProcessor.java:27) ~[libthrift-0.9.1.jar:0.9.1]
    at org.apache.cassandra.thrift.CustomTThreadPoolServer$WorkerProcess.run(CustomTThreadPoolServer.java:202) ~[apache-cassandra-2.1.2.jar:2.1.2]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [na:1.7.0_65]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [na:1.7.0_65]
    at java.lang.Thread.run(Thread.java:745) [na:1.7.0_65]

不确定这是否真的是一个错误,因为根据某些在线链接,我发现无论在设置调试日志级别时都会显示此消息

1 个答案:

答案 0 :(得分:0)

我正在尝试使用Cassandra 2.1.8。您看到的错误是这块Cassandra代码的产物:

try
{
    // Query endpoint to ranges map and schemas from thrift
    InetAddress host = hostiter.next();
    Cassandra.Client client = createThriftClient(host.getHostAddress(), rpcPort, this.user, this.passwd, this.transportFactory);

    setPartitioner(client.describe_partitioner());
    Token.TokenFactory tkFactory = getPartitioner().getTokenFactory();

    for (TokenRange tr : client.describe_ring(keyspace))
    {
        Range<Token> range = new Range<>(tkFactory.fromString(tr.start_token), tkFactory.fromString(tr.end_token), getPartitioner());
        for (String ep : tr.endpoints)
        {
            addRangeForEndpoint(range, InetAddress.getByName(ep));
        }
    }

    String cfQuery = String.format("SELECT * FROM %s.%s WHERE keyspace_name = '%s'",
                                 Keyspace.SYSTEM_KS,
                                 SystemKeyspace.SCHEMA_COLUMNFAMILIES_CF,
                                 keyspace);
    CqlResult cfRes = client.execute_cql3_query(ByteBufferUtil.bytes(cfQuery), Compression.NONE, ConsistencyLevel.ONE);


    for (CqlRow row : cfRes.rows)
    {
        String columnFamily = UTF8Type.instance.getString(row.columns.get(1).bufferForName());
        String columnsQuery = String.format("SELECT * FROM %s.%s WHERE keyspace_name = '%s' AND columnfamily_name = '%s'",
                                            Keyspace.SYSTEM_KS,
                                            SystemKeyspace.SCHEMA_COLUMNS_CF,
                                            keyspace,
                                            columnFamily);
        CqlResult columnsRes = client.execute_cql3_query(ByteBufferUtil.bytes(columnsQuery), Compression.NONE, ConsistencyLevel.ONE);

        CFMetaData metadata = CFMetaData.fromThriftCqlRow(row, columnsRes);
        knownCfs.put(metadata.cfName, metadata);
    }
    break;
}
catch (Exception e)
{
    if (!hostiter.hasNext())
        throw new RuntimeException("Could not retrieve endpoint ranges: ", e);
}

因此,您所拥有的是在消息中汇总的各种错误,“无法检索端点范围”。如果没有下载Cassandra源代码并通过它进行调试,您将无法分辨出具体的错误。这就是我做的。

我的架构是使用https://github.com/DonBranson/cql_schema_versioning在多步骤过程中构建的。一步就是这样:

ALTER TABLE user_reputation DROP ban_votes;

DROP触发Cassandra BulkLoader错误,该错误会打印您看到的错误消息。但是,无数其他错误条件显示相同的消息。错误消息绝对没有帮助我们真正解决问题。

我还发现,如果您正在加密这样的节点间通信,那么BulkLoader将无法工作:

internode_encryption: all

因此,在我正在运行的DigitalOcean云中,我必须加密internode comm,它会失败,但至少会显示一条指示连接失败的消息:

../apache-cassandra-2.1.8/bin/sstableloader -d 192.168.56.101 makeyourcase/arenas
Established connection to initial hosts
Opening sstables and calculating sections to stream
Skipping file makeyourcase-arenas.arenas_name_idx-jb-2-Data.db: column family makeyourcase.arenas.arenas_name_idx doesn't exist
Skipping file makeyourcase-arenas.arenas_name_idx-jb-1-Data.db: column family makeyourcase.arenas.arenas_name_idx doesn't exist
Streaming relevant part of makeyourcase/arenas/makeyourcase-arenas-jb-2-Data.db makeyourcase/arenas/makeyourcase-arenas-jb-1-Data.db to [/192.168.56.102, /192.168.56.101]
ERROR 01:46:39 [Stream #a7e5fb80-3593-11e5-9b52-cdde6a46fde5] Streaming error occurred
java.net.ConnectException: Connection refused
    at sun.nio.ch.Net.connect0(Native Method) ~[na:1.7.0_71]