Cassandra Schema for KairosDB

672 views
Skip to first unread message

Keith Hughes

unread,
Aug 25, 2015, 12:21:15 PM8/25/15
to KairosDB
Hi folks,

Can someone help me set up the KairosDB schema in Cassandra?

I am using Cassandra 2.1.8, apparently its syntax changes a lot for cqlsh.

I found the following

create keyspace kairosdb with placement_strategy = 'org.apache.cassandra.locator.SimpleStrategy' and strategy_options = {replication_factor:1};
Use kairosdb;
create column family data_points with comparator = BytesType;
create column family row_key_index with comparator = BytesType;
create column family string_index with comparator = BytesType;
update column family data_points with read_repair_chance = 0.1;
update column family row_key_index with read_repair_chance = 0.1;
update column family string_index with read_repair_chance = 0.1;

The keyspace creation had to change to 

create keyspace kairosdb with replication = {'class':'SimpleStrategy','replication_factor':1};


which is easy enough, but I have yet to figure out the new column family syntax, though I believe it is now "columnfamily", not "column family". Currently I get error messages like




cqlsh:kairosdb> create columnfamily data_points with comparator = BytesType;

SyntaxException: <ErrorMessage code=2000 [Syntax error in CQL query] message="line 1:32 mismatched input 'with' expecting '(' (create columnfamily data_points [with] comparator...)">

There is a ( needed, just not entirely sure what should go in it.

Thanks!



Keith Hughes

unread,
Aug 26, 2015, 1:03:15 AM8/26/15
to KairosDB
OK, I figured it out.

I was using cqlsh, which uses the new syntax. When I found and used cassandra_cli, I was able to use the syntax given in the first post.

Using cassandra_cli to input and then cqlsh to look at the tables, I found things like

CREATE KEYSPACE kairosdb WITH replication = {'class': 'SimpleStrategy', 'replication_factor': '1'}  AND durable_writes = true;


CREATE TABLE kairosdb.data_points (

    key blob,

    column1 blob,

    value blob,

    PRIMARY KEY (key, column1)

) WITH COMPACT STORAGE

    AND CLUSTERING ORDER BY (column1 ASC)

    AND caching = '{"keys":"ALL", "rows_per_partition":"NONE"}'

    AND comment = ''

    AND compaction = {'class': 'org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy'}

    AND compression = {'sstable_compression': 'org.apache.cassandra.io.compress.LZ4Compressor'}

    AND dclocal_read_repair_chance = 0.1

    AND default_time_to_live = 0

    AND gc_grace_seconds = 864000

    AND max_index_interval = 2048

    AND memtable_flush_period_in_ms = 0

    AND min_index_interval = 128

    AND read_repair_chance = 0.1

    AND speculative_retry = 'NONE';


I suspect a lot could be left off when creating the initial tables.

Brian Hawkins

unread,
Sep 1, 2015, 9:51:20 PM9/1/15
to KairosDB
Kairos automatically creates the column families (aka tables) when it starts up.  You don't have to create it manually.

Brian

Keith Hughes

unread,
Sep 6, 2015, 11:57:00 AM9/6/15
to KairosDB
Brian,

Hmm, I was getting errors when I tried to just start KairoDB up and the errors went away when I created the tables myself.

What is the minimum I have to do? Just create the keyspace and I am done?

Thanks!
-Keith

Keith Hughes

unread,
Sep 6, 2015, 8:24:21 PM9/6/15
to KairosDB
Brian,

Answered my own question. I am not sure why it failed the first time, but I wiped my cassandra instance completely from my machine, reinstalled it and started kairosdb and everything got created.

Wonder why it didn't work the first time, but there were so many variables, it is not surprising if I did something wrong.

Anyway, thanks!
-Keith

Brian Hawkins

unread,
Sep 10, 2015, 10:37:11 PM9/10/15
to KairosDB
Yup, it was designed to work without doing anything special with Cassandra.  Just point it at it and go, but if the startup got interrupted or some odd error happened I could see that maybe only a portion of the tables and or keyspace could get created which would cause a failure.

Brian
Reply all
Reply to author
Forward
0 new messages