我使用cassandra-cli -h localhost
创建密钥空间。
我尝试了这个命令:create keyspace reddit with strategy_options = [{replication_factor:1}];
而这一个:create keyspace reddit with strategy_options = {replication_factor:1};
,但我得到的就是:
org.apache.thrift.transport.TTransportException
我在ArchLinux(由AUR构建)上尝试了Cassandra 1.1.6和1.2.2。 (我用systemctl start cassandra
运行Cassandra。)
此外,当我在创建键空间之前尝试use reddit;
时,它返回Keyspace 'reddit' not found.
,但在尝试创建键空间后返回{{1} }}
编辑:忘记提及,但Login failure. Did you specify 'keyspace', 'username' and 'password'?
效果很好,但是当我使用replication_factor创建键空间时,它会抛出异常。
答案 0 :(得分:0)
使用此查询解决:
create keyspace reddit with placement_strategy = 'org.apache.cassandra.locator.SimpleStrategy' and strategy_options = [{replication_factor:1}];
我通过阅读/var/log/cassandra/system.log来到这里:
CustomTThreadPoolServer.java (line 217) Error occurred during processing of message.
java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
at org.apache.cassandra.locator.AbstractReplicationStrategy.createReplicationStrategy(AbstractReplicationStrategy.java:230)
at org.apache.cassandra.thrift.CassandraServer.system_add_keyspace(CassandraServer.java:1342)
at org.apache.cassandra.thrift.Cassandra$Processor$system_add_keyspace.getResult(Cassandra.java:3960)
at org.apache.cassandra.thrift.Cassandra$Processor$system_add_keyspace.getResult(Cassandra.java:3948)
at org.apache.thrift.ProcessFunction.process(ProcessFunction.java:32)
at org.apache.thrift.TBaseProcessor.process(TBaseProcessor.java:34)
at org.apache.cassandra.thrift.CustomTThreadPoolServer$WorkerProcess.run(CustomTThreadPoolServer.java:199)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:722)
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:525)
at org.apache.cassandra.locator.AbstractReplicationStrategy.createReplicationStrategy(AbstractReplicationStrategy.java:226)
... 9 more
Caused by: org.apache.cassandra.exceptions.ConfigurationException: replication_factor is an option for SimpleStrategy, not NetworkTopologyStrategy
at org.apache.cassandra.locator.NetworkTopologyStrategy.<init>(NetworkTopologyStrategy.java:66)
... 14 more