es:http://www.elasticsearch.org/guide/en/elasticsearch/guide/current/_add_failover.html
下一篇:http://my.oschina.net/qiangzigege/blog/264185
内容:
只有一个节点运行,意味着你有单一故障点:没有冗余备份。
只需要启动另外一个节点。一个新的节点将自动加入集群只要有同样的集群名字,可以互相交互。
此时,我们启动第二个节点,所有的主从分片都正确分配了。
第2个节点已经加入集群,并且三个从分片已经分配给第2个节点,意味着我们可以失去任何一个节点并且数据都是完好无缺的。
那么一个文档要增加,怎样的过程呢?
先根据分片策略,存储在一个主分片里,然后并行复制到对应的从分片,保证我们的文档可以从主分片或者任何一个从分片里查询到。
当前查询集群健康:绿色。
意味着6个分片(3主3从)都是OK的。
{
"cluster_name": "elasticsearch",
"status": "green",
"timed_out": false,
"number_of_nodes": 2,
"number_of_data_nodes": 2,
"active_primary_shards": 3,
"active_shards": 6,
"relocating_shards": 0,
"initializing_shards": 0,
"unassigned_shards": 0
}
集群良好!
为了大家理解更深刻:
这里把前后放在一起:
XXX@UBUNTU ~$ curl http://localhost:9200/_cluster/health?pretty
{
"cluster_name" : "elasticsearch",
"status" : "yellow",
"timed_out" : false,
"number_of_nodes" : 1,
"number_of_data_nodes" : 1,
"active_primary_shards" : 10,
"active_shards" : 10,
"relocating_shards" : 0,
"initializing_shards" : 0,
"unassigned_shards" : 10
}
XXX@UBUNTU ~$ curl http://localhost:9200/_cluster/health?pretty
{
"cluster_name" : "elasticsearch",
"status" : "green",
"timed_out" : false,
"number_of_nodes" : 2,
"number_of_data_nodes" : 2,
"active_primary_shards" : 10,
"active_shards" : 20,
"relocating_shards" : 0,
"initializing_shards" : 0,
"unassigned_shards" : 0
}