【发布时间】:2016-04-06 03:48:53
【问题描述】:
卡桑德拉 3.1 NodeJS 驱动:cassandra-driver 3.0.0
使用以下语句创建密钥空间:
如果不存在则创建密钥空间 xxxxxx WITH REPLICATION = { 'class' : 'SimpleStrategy', 'replication_factor' : 2 };
即使复制因子为 2,我也只运行一个用于开发目的的实例,并将一致性级别设置为 ONE。 这是当我尝试使用 IF NOT EXISTS 子句插入任何记录时出现一致性级别错误的问题。但是没有 IF NOT EXISTS 的语句可以正常工作。这是来自 cqlsh 的日志:
cqlsh:xxxxxx> CONSISTENCY;
Current consistency level is ONE.
cqlsh:xxxxxx> insert into accounts(account_id) values('test');
cqlsh:xxxxxx> insert into accounts(account_id) values('test1') if not exists;
Traceback (most recent call last): File "/usr/bin/cqlsh.py", line 1258, in perform_simple_statement result = future.result() File "/usr/share/cassandra/lib/cassandra-driver-internal-only-3.0.0-6af642d.zip/cassandra-driver-3.0.0-6af642d/cassandra/cluster.py", line 3122, in result raise self._final_exception Unavailable: code=1000 [Unavailable exception] message="Cannot achieve consistency level QUORUM" info={'required_replicas': 2, 'alive_replicas': 1, 'consistency': 'QUORUM'}
【问题讨论】: