新闻、帮助、产品更新动态

最新的业界新闻,产品系统更新开发动态,帮助教程和活动发布

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

发布日:2022-02-11 18:22       阅读数:

实时搜索引擎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/

 

编辑:航网科技   来源:腾讯云

本文版权归原作者所有 转载请注明出处

联系我们

客服部:深圳市龙华区龙胜商业大厦5楼B5区

业务部:深圳市南山区讯美科技广场2栋12楼1202

资质证书

  • Copyright © 2011-2020 www.hangw.com. All Rights Reserved 深圳航网科技有限公司 版权所有 增值电信业务经营许可证:粤B2-20201122 - 粤ICP备14085080号

    在线客服

    微信扫一扫咨询客服


    全国免费服务热线
    0755-36300002

    返回顶部