Cassandra 3.1 NodeJS驱动程序:cassandra-driver 3.0.0
使用以下语句创建Keyspace:
创建KEYSPACE如果不是EXXTS 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'}
Run Code Online (Sandbox Code Playgroud)