3
votes

I am new to cassandra and trying to do multi node setup on two Mac machine. Its not a datastax casandra. like my Ip is 10.100.1.12 and other machine ip is 10.100.1.15. I have changed the following properties in cassandra.yaml files on bothe the machine:

10.100.1.15:

  • seeds: "127.0.0.1,10.100.1.12,10.100.1.15"
  • listen_address: 10.100.1.15
  • rpc_address: 10.100.1.15
  • endpoint_snitch: GossipingPropertyFileSnitch

10.100.1.12:

  • seeds: "127.0.0.1,10.100.1.12,10.100.1.15"

  • listen_address: 10.100.1.12

  • rpc_address: 10.100.1.12

  • endpoint_snitch: GossipingPropertyFileSnitch

    cassandra runs fine cqlsh is also opening using the command bin/cqlsh 10.100.1.12

but when i am trying to retrieve the count of tables its showing me the error:

ReadTimeout: Error from server: code=1200 [Coordinator node timed out waiting for replica nodes' responses] message="Operation timed out - received only 0 responses." info={'received_responses': 0, 'required_responses': 1, 'consistency': 'ONE'}

i tried changing the read_request_timeout_in_ms proprtty from 5000 to 20000 but still i am getting the same error. Could anyone please help what i am doing wrong?

the table schema is following:

cqlsh:app_auditor> describe table traffic_data;

CREATE TABLE app_auditor.traffic_data (
    current_time bigint PRIMARY KEY,
    appid bigint,
    attributes map<text, text>,
    device bigint,
    flow_type text,
    message_time bigint
) WITH bloom_filter_fp_chance = 0.01
    AND caching = {'keys': 'ALL', 'rows_per_partition': 'NONE'}
    AND comment = ''
    AND compaction = {'class': 'org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy', 'max_threshold': '32', 'min_threshold': '4'}
    AND compression = {'chunk_length_in_kb': '64', 'class': 'org.apache.cassandra.io.compress.LZ4Compressor'}
    AND crc_check_chance = 1.0
    AND dclocal_read_repair_chance = 0.1
    AND default_time_to_live = 0
    AND gc_grace_seconds = 86400
    AND max_index_interval = 2048
    AND memtable_flush_period_in_ms = 0
    AND min_index_interval = 128
    AND read_repair_chance = 0.0
    AND speculative_retry = '99PERCENTILE';

the count query i am using is select count(*) from traffic_data;

1
You definitely don't want 127.0.0.1 in your list of seeds. Just the 2 listen addresses. What is the result of nodetool ring when you have both nodes up and running?mikea
Can you execute Normal queries ?Ashraful Islam
i can execute describe queries, like describe keyspaces and tables. the nodetool status is following:Datacenter: datacenter1 ======================= Status=Up/Down |/ State=Normal/Leaving/Joining/Moving -- Address Load Tokens Owns Host ID Rack UN 10.100.1.12 472.14 KiB 256 ? 2c09d826-387a-49d6-a99a-c538fcb159cb rack1 UN 10.100.1.15 887.97 KiB 256 ? b945b293-2f54-4440-afa0-d0536bed3230 rack1priyanka Dhiman
show your table schema and the query. I think it's because of your count queryAshraful Islam

1 Answers

3
votes

In Cassandra count(*) is very costly, cassandra needs to scan all the row from all the node just to give you the count, that's why it's giving you timeout exception.

Instead of using count(*) maintain a counter table, like the below one :

CREATE TABLE traffic_counter (
    type int PRIMARY KEY,
    traffic_count counter
);

When a data insert into traffic_data data, increment the value of traffic_count

UPDATE traffic_counter SET traffic_count = traffic_count + 1 WHERE type = 0;

Now you can select traffic count very efficiently.

SELECT traffic_count FROM traffic_counter WHERE type = 0;