Want to setup a two-node elastic search cluster on same machine - elasticsearch

I am on elastic search [7.10.1. For learning purposes want to setup a clutser of two nodes on the same host. Unable to find a configuration which works for me.
I have done same elastic serach installation in two different folders node1 and node2.
node1 elasticsearch.yml file:
...
cluster.name: tktest_esclutser
node.name: tkesnode-1
http.port: 19200
transport.port: 19201
discovery.seed_hosts: ["localhost:29200"]
...
node2 elasticsearch.yml file:
...
cluster.name: tktest_esclutser
node.name: tkesnode-2
http.port: 29200
transport.port: 29201
discovery.seed_hosts: ["localhost:19200"]
...
For some reason cluster is not being formed. log file shows master-node could not be discovered.

Below configuration works perfectly fine for me, initially you may have to delete the folders inside the data folder of both nodes to start with clean state.
Node 1 elasticsearch.yml
cluster.name: es_710
node.name: opster
http.port: 9900
cluster.initial_master_nodes: ["opster"]
Node 2 elasticsearch.yml
http.port: 9910
xpack.ml.enabled: false
cluster.name: es_710
cluster.initial_master_nodes: ["opster"]

Related

Setting up ElasticSearch cluster on different VPS

I want to make a basic ElasticSearch cluster with two nodes.
I am using two VPS servers:
VPS1 has public IP address: 5.xxx.96.233
VPS2 has public IP address: 5.xxx.96.234
This is how the elasticsearch.yml file looks like (besides the default settings):
VPS1:
cluster.name: mx-cluster
node.name: mx-node-1
network.host: 0.0.0.0
discovery.zen.ping.unicast.hosts: ["5.xxx.96.233", "5.xxx.96.234"]
VPS2:
cluster.name: mx-cluster
node.name: mx-node-2
network.host: 0.0.0.0
discovery.zen.ping.unicast.hosts: ["5.xxx.96.233", "5.xxx.96.234"]
The ufw rules are set to allow to port 9300 from the other server.
VPS1:
9300 ALLOW 5.xxx.96.234
VPS2:
9300 ALLOW 5.xxx.96.233
Now an ElasticSearch instance is running on both of them, but it's unable to discover eachother to make a cluster.
Both servers are new and I only installed ElasticSearch on it.
I am not sure if this is possible or this is the way to do it, I wasn't able to find an answer online so I'm posting this.
Below 2 configs issue solved the issue, I just make only 1 master node mx-node-1 which also act as a data-node and another node mx-node-1 act as only data-node.
Master and data node config(mx-node-1)
cluster.name: mx-cluster
node.name: mx-node-2
path.data: /var/lib/elasticsearch
path.logs: /var/log/elasticsearch
network.host: 0.0.0.0
discovery.seed_hosts: ["5.255.96.233"]
logger.org.elasticsearch.discovery: TRACE --> note used this to debug issue
Data node(mx-node-2) config
cluster.name: mx-cluster
node.name: mx-node-2
path.data: /var/lib/elasticsearch
path.logs: /var/log/elasticsearch
network.host: 0.0.0.0
node.master: false --> note this would mark it as data node only
discovery.seed_hosts: ["5.255.96.233"]
logger.org.elasticsearch.discovery: TRACE

Failed to send join request to master ElasticSearch on AWS EC2 owned cluster

I am trying to build a cluster of 3 EC2 instances (I do not want to use the ElasticSearch service of amazon) and after installing the software and configuring it in all three instances I encounter the problem that they do not communicate with each other.
I’m working with ES 5.5.1 on instances with Ubuntu 16.04
All nodes are up and running
All nodes has a Security Groupof AWS with permissions for all traffic between nodes (all ports)
Internal firewall on very machine white list for every node
Master
cluster.name: excelle
node.name: ${HOSTNAME}
node.master: true
path.data: /srv/data
path.logs: /var/log/elasticsearch
bootstrap.memory_lock: true
network.host: 172.31.MAS.TER
discovery.zen.ping.unicast.hosts: ["172.31.MAS.TER", "172.31.NODE.TWO", "172.31.NODE.THREE"]
Node two
cluster.name: excelle
node.name: ${HOSTNAME}
node.master: false
path.data: /srv/data
path.logs: /var/log/elasticsearch
bootstrap.memory_lock: true
network.host: 172.31.NODE.TWO
discovery.zen.ping.unicast.hosts: ["172.31.MAS.TER", "172.31.NODE.TWO", "172.31.NODE.THREE"]
Node 3
cluster.name: excelle
node.name: ${HOSTNAME}
node.master: false
path.data: /srv/data
path.logs: /var/log/elasticsearch
bootstrap.memory_lock: true
network.host: 172.31.NODE.THREE
discovery.zen.ping.unicast.hosts: ["172.31.MAS.TER", "172.31.NODE.TWO", "172.31.NODE.THREE"]
But on logs, on node 3 for exmple...
[2017-08-15T11:01:41,241][INFO ][o.e.d.z.ZenDiscovery ] [es03] failed to send join request to master [{esmaster}{scquEEaETDKMKLHzZvEHZQ}{NdLtMUXtT7WXnv1a4uHWqQ}{172.31.44.107}{172.31.44.107:9300}], reason [RemoteTransportException[[esmaster][172.31.44.107:9300][internal:discovery/zen/join]]; nested: ConnectTransportException[[es03][172.31.18.76:9300] connect_timeout[30s]]; nested: IOException[connection timed out: 172.31.18.76/172.31.18.76:9300]; ]
I testing connection from node 3 to master not problem (for network question)
telnet 172.31.MAS.TER 9300
Trying 172.31.MAS.TER...
Connected to 172.31.MAS.TER.
Escape character is '^]'.
What it's wrong? Any idea?
I found an answer to this posted on ElasticSearch
The gem was from manst:
"solution for this error (you must deleted contents of data folder(/var/lib/elasticsearch/nodes/0) and restarted both the servers ):"
I deleted the nodes folder from each of my SpotInst instances and rebooted. My 3 ES distributed master-only nodes all came online. My 8 data-only nodes have connected automatically without any issue.

Nodes not joining cluster in Elasticsearch 5.1 cluster

I want to setup a cluster with 3 nodes(1 master, 1 client and 1 data node) with Elasticsearch 5.1.1. I have connected 3 windows 10 machines through a wireless network and edited the elasticsearch.ymlfile of each node as follows:
master node:
cluster.name: searchapp
node.name: es-master-01
node.master: true
node.data: false
node.ingest: false
network.host: 192.168.1.3
discovery.zen.ping.unicast.hosts: ["es-client-01", "es-master-01", "es-data-01"]
client node:
cluster.name: searchapp
node.name: es-client-01
node.master: false
node.data: false
node.ingest: true
network.host: 192.168.1.4
discovery.zen.ping.unicast.hosts: ["es-client-01", "es-master-01", "es-data-01"]
data node:
cluster.name: searchapp
node.name: es-data-01
node.master: false
node.data: true
node.ingest: false
network.host: 192.168.1.2
discovery.zen.ping.unicast.hosts: ["es-client-01", "es-master-01", "es-data-01"]
When I try to run elasticsearch on the master node it gives the following output
The nodes are not joining the cluster and I tried replacing the hostnames to IPs but still the nodes aren't joining.
According to the attached logs, it seems that your elasticsearch cluster cannot resolve the host names for the machines.
I suggest to add all of your hosts names to the hosts file so each machine would know how to resolve the host names.
For linux:
/etc/hosts
For windows:
%SystemRoot%\System32\drivers\etc\hosts
Where by default, %SystemRoot% means: C:\Windows

Elasticsearch cluster instances are showing up as an individual masters

I am trying to deploy a 2 node elasticsearch cluster.
I have 2 VM's as follow:
VM1 -> 10.20.1.4 (CentOS7)
VM2 -> 10.20.1.5 (CentOS7)
I have installed java8 as a prerequisite in both the above VM.
Downloaded the elasticsearch tar from below link:
https://download.elasticsearch.org/elasticsearch/release/org/elasticsearch/distribution/tar/elasticsearch/2.1.0/elasticsearch-2.1.0.tar.gz
In VM1 (10.20.1.4), I have below configuration in elasticsearch.yml file
cluster.name: TestCluster
node.name: "node1"
node.master: true
transport.tcp.port: 9300
http.port: 9200
discovery.zen.ping.multicast.enabled: false
discovery.zen.ping.unicast.hosts: ["10.20.1.4:9300", "10.20.1.5:9300"]
In VM2 (10.20.1.5), I have below configuration in elasticsearch.yml file
cluster.name: TestCluster
node.name: "node2"
transport.tcp.port: 9300
http.port: 9200
discovery.zen.ping.multicast.enabled: false
discovery.zen.ping.unicast.hosts: ["10.20.1.4:9300", "10.20.1.5:9300"]
But with this configuration, when I start elasticsearch instance, both the instances are coming up as an individual master node. They are not forming the cluster as they are unable to discover them.
I have also tried below variation of zen unicast but none of them are working for me
discovery.zen.ping.unicast.hosts: ["10.20.1.4:9200", "10.20.1.5:9200"]
OR
discovery.zen.ping.unicast.hosts: ["10.20.1.4", "10.20.1.5"]
OR
discovery.zen.ping.unicast.hosts: ["node1", "node2"]
Can someone please help me to get this elasticsearch cluster work.
It's because the ES server is bound to localhost by default, i.e. in your config you can see this network.bind_host: _local_
They took that decision to prevent ES clusters from forming with undesired hosts from the outside world.
Instead you should set the following setting on each of your hosts:
network.host: 10.20.1.4 # on VM1
and
network.host: 10.20.1.5 # on VM2
Note that setting network.host will set both network.bind_host and network.publish_host to the same IP address.

Elastic data node with shield

but it can't working after I setup shield
I added user to elastic by command
shield/esusers useradd es_admin -r admin
This is my master node config
cluster.name: vision
node.name: "node_master"
node.master: true
node.data: false
discovery.zen.ping.multicast.enabled: false
discovery.zen.ping.unicast.hosts: ["192.168.1.5"]
path.logs: /var/elastic/log
path.data: /var/elastic/data
This is my data node config
cluster.name: vision
node.name: "node_data"
node.master: false
node.data: true
discovery.zen.ping.multicast.enabled: false
discovery.zen.ping.unicast.hosts: ["192.168.1.5"]
path.logs: /var/elastic/log
path.data: /var/elastic/data
How can I connect data node to master node?
There is no extra work you need to do to join data and master node to form a cluster.It treats both type of nodes same.
Your hosts setting is mentioning only one host.
discovery.zen.ping.unicast.hosts: ["host1:port","host2:port"]
Each node will keep pinging the hosts listed above until both are initialized.Adding the local host is of no harm to array as ping wont fail but help in automated deployement of elasticsearch on multinode ecosystem.
since you are using shield make sure if you enabled ssl for node communicatioon then also specify the path to SSL keystore files.

Resources