栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 前沿技术 > 大数据 > 大数据系统

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

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

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

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/710214.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号