添加链接
link之家
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more

I have a situation where I have installed two instances of Elasticsearch setup in remote server 1 (node1) and remote server 2 (node2), and I want to connect both these nodes in one cluster, however I also installed the kibana in one server and when I run the GET _cluster/health I get

"cluster_name" : "elasticsearch", "status" : "green", "timed_out" : false, "number_of_nodes" : 1, "number_of_data_nodes" : 1, "active_primary_shards" : 1, "active_shards" : 1, "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

Can you please help while providing any sample for both configs for node1 and node2, and how can I confirm both nodes are added in one cluster.

Below is my elasticsearch.yml file in server 1

bootstrap.memory_lock: false
cluster.name: elasticsearch
http.port: 9200
node.data: true
node.ingest: true
node.master: true
node.max_local_storage_nodes: 2
node.name: Server1
path.data: C:\ProgramData\Elastic\Elasticsearch\data
path.logs: C:\ProgramData\Elastic\Elasticsearch\logs
transport.tcp.port: 9300
xpack.license.self_generated.type: basic
xpack.security.enabled: false
discovery.zen.minimum_master_nodes: 2
discovery.zen.ping.unicast.hosts: ["Server1","Server2"]
network.host: Server1

Server2 : elasticsearch.yml file -

bootstrap.memory_lock: false
cluster.name: elasticsearch
http.port: 9200
node.data: true
node.ingest: true
node.master: false
node.max_local_storage_nodes: 1
node.name: Server2
path.data: C:\ProgramData\Elastic\Elasticsearch\data
path.logs: C:\ProgramData\Elastic\Elasticsearch\logs
transport.tcp.port: 9300
xpack.license.self_generated.type: basic
xpack.security.enabled: false
discovery.zen.ping.unicast.hosts: ["Server1","Server2"]
network.host: Server2

Thanks Gaurav Singh

So 2 nodes in one cluster is one master node and one is slave node

As of formula (2 / 2+1) = 0.6666 ~ 1
discovery.zen.minimum_master_nodes: 1
                Thanks for the help, I also need to put the line in both config and then it worked : discovery.zen.minimum_master_nodes: 1
– Mr. Gaurav Singh Rathore
                Mar 6 '19 at 12:49

you configured minimum_master_nodes (discovery.zen.minimum_master_nodes) of 2, but the second node have

node.master: false

either change the second node to master:true or reduce minimum_master_nodes to 1

node.max_local_storage_nodes: 2 node.name: Server1 path.data: C:\ProgramData\Elastic\Elasticsearch\data path.logs: C:\ProgramData\Elastic\Elasticsearch\logs transport.tcp.port: 9300 xpack.license.self_generated.type: basic xpack.security.enabled: false discovery.zen.minimum_master_nodes: 1 discovery.zen.ping.unicast.hosts: ["Server1","Server2"] network.host: Server1

Slave Node Configuration :

bootstrap.memory_lock: false
cluster.name: elasticsearch
http.port: 9200
node.data: true
node.ingest: true
node.master: false
node.max_local_storage_nodes: 1
node.name: Server2
path.data: C:\ProgramData\Elastic\Elasticsearch\data
path.logs: C:\ProgramData\Elastic\Elasticsearch\logs
transport.tcp.port: 9300
xpack.license.self_generated.type: basic
xpack.security.enabled: false
discovery.zen.minimum_master_nodes: 1
discovery.zen.ping.unicast.hosts: ["Server1","Server2"]
network.host: Server2

After doing this you will get the response like :

"cluster_name": "elasticsearch", "status": "green", "timed_out": false, "number_of_nodes": 2, "number_of_data_nodes": 2, "active_primary_shards": 1, "active_shards": 2, "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

Thanks
Gaurav Singh

Thanks for contributing an answer to Stack Overflow!

  • Please be sure to answer the question. Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.