I am trying to run ES(6.4.3) cluster where I have 2 nodes and I want to make one node as master and data and other as only data. My both nodes are up and running but not able to communicate with each other to discover a cluster.
If I run telnet command to check then I am able to run telnet to localhost on port 9300 but not able to connect to other node.
# ======================== Elasticsearch Configuration =========================
#
# NOTE: Elasticsearch comes with reasonable defaults for most settings.
# Before you set out to tweak and tune the configuration, make sure you
# understand what are you trying to accomplish and the consequences.
#
# The primary way of configuring a node is via this file. This template lists
# the most important settings you may want to configure for a production cluster.
#
# Please consult the documentation for further information on configuration options:
# https://www.elastic.co/guide/en/elasticsearch/reference/index.html
#
# ---------------------------------- Cluster -----------------------------------
#
# Use a descriptive name for your cluster:
#
cluster.name : campaygn-production
#
# ------------------------------------ Node ------------------------------------
#
# Use a descriptive name for the node:
#
node.name: campaygn-production-elasticsearch-node-0
#
# Add custom attributes to the node:
#
#node.attr.rack: r1
#
# ----------------------------------- Paths ------------------------------------
#
# Path to directory where to store the data (separate multiple locations by comma):
#
path.data: /var/lib/elasticsearch
#
# Path to log files:
#
path.logs: /var/log/elasticsearch
#
# ----------------------------------- Memory -----------------------------------
#
# Lock the memory on startup:
#
#bootstrap.memory_lock: true
#
# Make sure that the heap size is set to about half the memory available
# on the system and that the owner of the process is allowed to use this
# limit.
#
# Elasticsearch performs poorly when the system is swapping the memory.
#
# ---------------------------------- Network -----------------------------------
#
# Set the bind address to a specific IP (IPv4 or IPv6):
#
network.host: 209.97.184.107
#
# Set a custom port for HTTP:
#
http.port: 9200
#
# For more information, consult the network module documentation.
#
# --------------------------------- Discovery ----------------------------------
#
# Pass an initial list of hosts to perform discovery when new node is started:
# The default list of hosts is ["127.0.0.1", "[::1]"]
#
discovery.zen.ping.unicast.hosts: ["209.97.184.107","142.93.42.161"]
#
# Prevent the "split brain" by configuring the majority of nodes (total number of master-eligible nodes / 2 + 1):
#
#discovery.zen.minimum_master_nodes:
#
# For more information, consult the zen discovery module documentation.
#
# ---------------------------------- Gateway -----------------------------------
#
# Block initial recovery after a full cluster restart until N nodes are started:
#
#gateway.recover_after_nodes: 3
#
# For more information, consult the gateway module documentation.
#
# ---------------------------------- Various -----------------------------------
#
# Require explicit names when deleting indices:
#
#action.destructive_requires_name: true
#script.inline: true
indices.query.bool.max_clause_count: 100000
#path.repo: ["/tmp/backups/elasticsearch/elasticsearch"]
#define node 1 as master-eligible:
node.master: true
#define nodes 1 as data node:
node.data: true
# ======================== Elasticsearch Configuration =========================
#
# NOTE: Elasticsearch comes with reasonable defaults for most settings.
# Before you set out to tweak and tune the configuration, make sure you
# understand what are you trying to accomplish and the consequences.
#
# The primary way of configuring a node is via this file. This template lists
# the most important settings you may want to configure for a production cluster.
#
# Please consult the documentation for further information on configuration options:
# https://www.elastic.co/guide/en/elasticsearch/reference/index.html
#
# ---------------------------------- Cluster -----------------------------------
#
# Use a descriptive name for your cluster:
#
cluster.name: campaygn-production
#
# ------------------------------------ Node ------------------------------------
#
# Use a descriptive name for the node:
#
node.name: campaygn-production-elasticsearch-node-1
#
# Add custom attributes to the node:
#
#node.attr.rack: r1
#
# ----------------------------------- Paths ------------------------------------
#
# Path to directory where to store the data (separate multiple locations by comma):
#
path.data: /var/lib/elasticsearch
#
# Path to log files:
#
path.logs: /var/log/elasticsearch
#
# ----------------------------------- Memory -----------------------------------
#
# Lock the memory on startup:
#
#bootstrap.memory_lock: true
#
# Make sure that the heap size is set to about half the memory available
# on the system and that the owner of the process is allowed to use this
# limit.
#
# Elasticsearch performs poorly when the system is swapping the memory.
#
# ---------------------------------- Network -----------------------------------
#
# Set the bind address to a specific IP (IPv4 or IPv6):
#
network.host: 142.93.42.161
#
# Set a custom port for HTTP:
#
http.port: 9200
#
# For more information, consult the network module documentation.
#
# --------------------------------- Discovery ----------------------------------
#
# Pass an initial list of hosts to perform discovery when new node is started:
# The default list of hosts is ["127.0.0.1", "[::1]"]
#
discovery.zen.ping.unicast.hosts: ["209.97.184.107","142.93.42.161"]
#
# Prevent the "split brain" by configuring the majority of nodes (total number of master-eligible nodes / 2 + 1):
#
#discovery.zen.minimum_master_nodes:
#
# For more information, consult the zen discovery module documentation.
#
# ---------------------------------- Gateway -----------------------------------
#
# Block initial recovery after a full cluster restart until N nodes are started:
#
#gateway.recover_after_nodes: 3
#
# For more information, consult the gateway module documentation.
#
# ---------------------------------- Various -----------------------------------
#
# Require explicit names when deleting indices:
#
#action.destructive_requires_name: true
indices.query.bool.max_clause_count: 100000
#define node 1 as master-eligible:
node.master: false
#define nodes 1 as data node:
node.data: true
I found out the problem and you were correct, it was permission issue but at server the permissions were fine but for Digital Ocean firewall they have one extra firewall and if you don't give any permission then by default it's not allowed. So, I had to give permissions specifically for those ports to each server.
Just one question I have is how to make sure cluster is working good, I have run following curl request and response is also given:
If you see the output of your curl command, the cluster health is showing yellow. It should be green. Currently its showing status yellow because there are 9 shards which are unassigned. The reason for unassigned shards is, you have only one data node. So your primary shard and replica shards are on same data node. So you need at least 2 data node. So your primary shard and replica shards can be on different data node. Then the cluster status will also changed and it will become green.
Let say, you have 5 primary shards (P1,P2....p5) and 1 replica for each primary shards. Then you will have total 10 shards 5 primary and 5 replicas i.e R1,R2,...R5 (one for each primary shards).
If you have 2 data node then your first data node may have P1,P2,R3,R4,R5 and second data node may have P3,P4,P5,R1,R2. It managed by Elasticsearch itself.
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.