2

I have tried to alter the keypace with strategy class and options using below command in cassandra-cli of version cassandra 1.1.6 but it says 'Syntax error at position 0: no viable alternative at input 'ALTER'.

ALTER KEYSPACE system_auth WITH REPLICATION =
  {'class' : 'NetworkTopologyStrategy', 'dc1' : 3, 'dc2' : 2};

What is wrong here?

Aaron
  • 55,518
  • 11
  • 116
  • 132
Dinesh Kumar
  • 141
  • 10

2 Answers2

2

What is happening, is that you are using CQL syntax to update a keyspace from within the (deprecated) cassandra-cli tool. If you were using the cqlsh tool, your command would work just fine. But with cassandra-cli, that's not going to work. As Yasmeen indicated, the correct syntax that you will want to use is UPDATE KEYSPACE:

UPDATE KEYSPACE system_auth with placement_strategy = 'NetworkTopologyStrategy'
and strategy_options = {'dc1' : 3, 'dc2' : 2};

I do recommend that you use cqlsh in the future. The cassandra-cli is deprecated, and will not receive any further updates.

Also, you should also see about upgrading your cluster to a more recent version of Cassandra. While you are missing out on several new features, there have been many bugs fixed since 1.1.6 (bugs that you are probably running into).

Aaron
  • 55,518
  • 11
  • 116
  • 132
0
UPDATE KEYSPACE demo 
WITH placement_strategy = 'NetworkTopologyStrategy'  
AND strategy_options = {'dc1' : 3, 'dc2' : 2};
Aaron
  • 55,518
  • 11
  • 116
  • 132
Yasmeen
  • 801
  • 1
  • 7
  • 20
  • 2
    While syntactically correct, this answer is code-only and offers no explanation to the OP's question of "What's wrong here?" – Aaron Jan 29 '15 at 15:27