Elasticsearch入门初探-单机多节点集群

实时搜索引擎Elasticsearch(简称ES)是一个基于Apache Lucene(TM)的开源搜索引擎,无论在开源还是专有领域,Lucene可以被认为是迄今为止最先进、性能最好,这里分享Elasticsearch入门在单机下如何配置多节点集群。实时搜索引擎Elasticsearch(简称ES)是一个基于Apache Lucene(TM)的开源搜索引擎,无论在开源还是专有领域,Lucene可以被认为是迄今为止最先进、性能最好,这里分享Elasticsearch入门在单机下如何配置多节点集群。

下载Elasticsearch:

https://www.elastic.co/cn/downloads/elasticsearch/

解压后,复制出3份,命名大致如下:

在这里插入图片描述

接下来会对这3个Elasticsearch目录,分别配置 config/elasticsearch.yml 文件,

其中 elasticsearch_0目录作为主节点运行,另外两个作为子节点运行。

配置如下,供参考:

elasticsearch_0/elasticsearch.yml

cluster.name: es-study
node.name: node-0
node.master: true
node.attr.rack: r1
network.host: 127.0.0.1
http.port: 9200
transport.tcp.port: 9900
discovery.seed_hosts: ["127.0.0.1:9900", "127.0.0.1:9901", "127.0.0.1:9902"]
cluster.initial_master_nodes: ["node-0","node-1","node-2"]

elasticsearch_1/elasticsearch.yml

cluster.name: es-study
node.name: node-1
node.master: false
node.attr.rack: r1
node.max_local_storage_nodes: 3
bootstrap.memory_lock: false
network.host: 127.0.0.1
http.port: 9201
transport.tcp.port: 9901
discovery.seed_hosts: ["127.0.0.1:9900", "127.0.0.1:9901", "127.0.0.1:9902"]
cluster.initial_master_nodes: ["node-0","node-1","node-2"]

elasticsearch_2/elasticsearch.yml

cluster.name: es-study
node.name: node-2
node.master: false
node.attr.rack: r1
bootstrap.memory_lock: false
network.host: 127.0.0.1
http.port: 9202
transport.tcp.port: 9902
discovery.seed_hosts: ["127.0.0.1:9900", "127.0.0.1:9901", "127.0.0.1:9902"]
cluster.initial_master_nodes: ["node-0","node-1","node-2"]

启动项目(按顺序之启动):

elasticsearch_0\\bin\\elasticsearch.bat
elasticsearch_1\\bin\\elasticsearch.bat
elasticsearch_2\\bin\\elasticsearch.bat

主节点启动成功,如下:

在这里插入图片描述

但启动 elasticsearch_1/elasticsearch.yml 节点的时候失败了,报错如下:

在这里插入图片描述

这个问题其实也比较好解决。

前面提到,复制了 3份 Elasticsearch目录,这时候

elasticsearch_1
elasticsearch_2

这两个目录是作为子节点使用,但两个目录下还包含了节点目录,所以把目录下的 data 文件夹里的内容删除即可

在这里插入图片描述

重新启动子节点,启动后访问下面url验证下,成功了!

http://localhost:9200/_cluster/health
http://localhost:9200/
http://localhost:9201/
http://localhost:9202/

本站文章资源均来源自网络,除非特别声明,否则均不代表站方观点,并仅供查阅,不作为任何参考依据!
如有侵权请及时跟我们联系,本站将及时删除!
如遇版权问题,请查看 本站版权声明
THE END
分享
二维码
海报
Elasticsearch入门初探-单机多节点集群
https://www.elastic.co/cn/downloads/elasticsearch/
<<上一篇
下一篇>>