NoHostAvailable:,在elassandra上使用网络拓扑策略进行插入查询

时间:2017-09-13 10:57:56

标签: elasticsearch cassandra cqlsh elassandra

在使用网络拓扑策略的插入查询的elassandra中,它显示“没有主机可用'。

cqlsh>CREATE KEYSPACE IF NOT EXISTS twitter WITH replication={ 'class':'NetworkTopologyStrategy', 'dc1':'1' };

cqlsh>CREATE TABLE twitter.user (
   name text,
   attrs map<text,text>,
   PRIMARY KEY (name)
);

cqlsh>INSERT INTO twitter.user (name,attrs) VALUES ('bob',{'email':'bob@gmail.com','firstname':'bob'});

enter image description here nodetool status enter image description here

另一个使用相同dc的键空间,显示这个 enter image description here

2 个答案:

答案 0 :(得分:3)

将密钥空间的数据中心名称更改为DC1

ALTER KEYSPACE twitter WITH replication = {'class': 'NetworkTopologyStrategy', 'DC1' : 1};
  

数据中心名称区分大小写。

<强>被修改

有两种复制策略可供选择:

  • SimpleStrategy:仅用于单个数据中心。如果您打算使用多个数据中心,请使用NetworkTopologyStrategy。
  • NetworkTopologyStrategy:强烈推荐用于大多数部署,因为在未来扩展需要时,可以更轻松地扩展到多个数据中心。

答案 1 :(得分:0)

创建密钥空间时,

'dc1'应该是使用nodetool status时的数据中心名称