ElasticSearch 单台服务器部署多个节点

转载:https://www.cnblogs.com/wxw16/p/6160186.html

一般情况下单台服务器只会部署一个ElasticSearch node,但是在学习过程中,很多情况下会需要实现ElasticSearch的分布式效果,所以需要启动多个节点,但是学习开发环境(不想开多个虚拟机实现多个服务器的效果),所以就想着在一台服务器上部署多个结点(下文以2个结点作为例子),两个节点分别称为实例一、二。

1、首先将elasticsearch-5.0.2文件夹再复制一份

1# wuxiwei @ wuxiwei in ~/software 2$ cp -R elasticsearch-5.0.2 elasticsearch-5.0.2-node-2 # wuxiwei @ wuxiwei in ~/software $ ls -l total 145568 drwxr-xr-x 12 wuxiwei staff 408 12 11 16:23 elasticsearch-5.0.2 drwxr-xr-x 12 wuxiwei staff 408 12 11 16:27 elasticsearch-5.0.2-node-2

2、主要工作就是修改elasticsearch.yml配置文件。

实例二:config目录下的elasticsearch.yml内容

将node.name: node-1 修改为 node-2,

3、分别开启两个节点

1# wuxiwei @ wuxiwei in ~/software/elasticsearch-5.0.2 2$ ./bin/elasticsearch

1# wuxiwei @ wuxiwei in ~/software/elasticsearch-5.0.2 2$ cd ../elasticsearch-5.0.2-node-2 # wuxiwei @ wuxiwei in ~/software/elasticsearch-5.0.2-node-2 $ ./bin/elasticsearch

4、查询是否成功

1$ curl -i -XGET 'http://localhost:9200/_cluster/health?pretty'\; 2HTTP/1.1 200 OK content-type: application/json; charset=UTF-8 content-length: 457 { "cluster_name" : "my", "status" : "green", "timed_out" : false, "number_of_nodes" : 2, "number_of_data_nodes" : 2, "active_primary_shards" : 20, "active_shards" : 40, "relocating_shards" : 0, "initializing_shards" : 0, "unassigned_shards" : 0, "delayed_unassigned_shards" : 0, "number_of_pending_tasks" : 0, "number_of_in_flight_fetch" : 0, "task_max_waiting_in_queue_millis" : 0, "active_shards_percent_as_number" : 100.0 }

也可以通过Kibana查看节点效果

踩过的坑

(1)如果修改了配置文件的 http.porttransport.tcp.port项,一定要将各个节点的值设置不同,否则会出现占用的情况。正常如果不修改,默认会分配值。

(2)示例二开启时,实例一报警告(实际操作中可以忽略,不然将无法实现ES的分布式集群作用):

[2016-12-11T18:06:43,678][WARN ][o.e.d.z.ElectMasterService] [node-1] value for setting "discovery.zen.minimum_master_nodes" is too low. This can result in data loss! Please set it to at least a quorum of master-eligible nodes (current value: [-1], total number of master-eligible nodes used for publishing in this round: [2])

是因为默认情况下 discovery.zen.minimum_master_nodes=1 一台服务器只能有一个主节点,所以在实例二的配置文件中可以添加 node.master: false

(3)示例二不能开启,报如下错误:

[2016-12-11T16:53:02,711][INFO ][o.e.d.z.ZenDiscovery     ] [node-2] failed to send join request to master [{node-1}{vP19PMOyT2ilJKRAqgn78w}{jDULCExERXGHp4VXpbyuJA}{127.0.0.1}{127.0.0.1:9300}], reason [RemoteTransportException[[node-1][127.0.0.1:9300][internal:discovery/zen/join]]; nested: IllegalArgumentException[can't add node {node-2}{vP19PMOyT2ilJKRAqgn78w}{qhDDVzwZQ0GXZXhIMmpGKA}{127.0.0.1}{127.0.0.1:9301}, found existing node {node-1}{vP19PMOyT2ilJKRAqgn78w}{jDULCExERXGHp4VXpbyuJA}{127.0.0.1}{127.0.0.1:9300} with the same id but is a different node instance]; ] [2016-12-11T16:53:02,911][INFO ][o.e.x.m.e.Exporters ] [node-2] skipping exporter [default_local] as it isn't ready yet [2016-12-11T16:53:02,912][ERROR][o.e.x.m.AgentService ] [node-2] exception when exporting documents org.elasticsearch.xpack.monitoring.exporter.ExportException: exporters are either not ready or faulty  at org.elasticsearch.xpack.monitoring.exporter.Exporters.export(Exporters.java:188) ~[x-pack-5.0.2.jar:5.0.2]  at org.elasticsearch.xpack.monitoring.AgentService$ExportingWorker.run(AgentService.java:208) [x-pack-5.0.2.jar:5.0.2]  at java.lang.Thread.run(Thread.java:745) [?:1.8.0_111]

是因为复制的elasticsearch文件夹下包含了data文件中示例一的节点数据,需要把示例二data文件下的文件清空。

点赞
收藏

评论区

加载中...

相关推荐

MySQL:[Err] 1292 - Incorrect datetime value: ‘0000-00-00 00:00:00‘ for column ‘CREATE_TIME‘ at row 1

文章目录问题用navicat导入数据时,报错:原因这是因为当前的MySQL不支持datetime为0的情况。解决修改sql\mode:sql\mode:SQLMode定义了MySQL应支持的SQL语法、数据校验等,这样可以更容易地在不同的环境中使用MySQL。全局s

Oracle 分组与拼接字符串同时使用

SELECTT.,ROWNUMIDFROM(SELECTT.EMPLID,T.NAME,T.BU,T.REALDEPART,T.FORMATDATE,SUM(T.S0)S0,MAX(UPDATETIME)CREATETIME,LISTAGG(TOCHAR(

MySQL部分从库上面因为大量的临时表tmp_table造成慢查询

背景描述Time:20190124T00:08:14.70572408:00User@Host:@Id:Schema:sentrymetaLast_errno:0Killed:0Query_time:0.315758Lock_

皕杰报表之UUID

​在我们用皕杰报表工具设计填报报表时,如何在新增行里自动增加id呢?能新增整数排序id吗?目前可以在新增行里自动增加id,但只能用uuid函数增加UUID编码,不能新增整数排序id。uuid函数说明:获取一个UUID,可以在填报表中用来创建数据ID语法:uuid()或uuid(sep)参数说明:sep布尔值,生成的uuid中是否包含分隔符'',缺省为

手写Java HashMap源码

HashMap的使用教程HashMap的使用教程HashMap的使用教程HashMap的使用教程HashMap的使用教程22

2020年前端实用代码段,为你的工作保驾护航

有空的时候,自己总结了几个代码段,在开发中也经常使用,谢谢。1、使用解构获取json数据let jsonData  id: 1,status: "OK",data: 'a', 'b';let  id, status, data: number   jsonData;console.log(id, status, number )

ElasticSearch 单台服务器部署多个节点 - HelloWorld