elasticsearchkibanadistributedsense

How can a configure two nodes in one cluster in elasticsearch?


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


Solution

  • There is formula for minimum master nodes

    (total number of master-eligible nodes / 2 + 1)
    

    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