Setup ElasticSearch - nimbo3/Keenbo GitHub Wiki

Setup ElasticSearch on cluster

Prerequisites

  • Do not work with root (you'll receive exception)
  • java is installed and JAVA_HOME is set(don't use OpenJDK).
  • The HOSTNAME is set on servers(i used "master", "slave-1", "slave-2", "slave-3"). it used for node name.

Install

We had some problem with version 7 so we used version 6.6.2 for setting elastic up run bellow commands on all servers:

wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-6.6.2.tar.gz
tar -xvf elasticsearch-6.6.2.tar.gz 
cd elasticsearch-6.6.2/

put these lines in elasticsearch.yml (make sure the firewall is working well):

node.name: ${HOSTNAME}
cluster.name: Keenbo
network.host: 0.0.0.0
discovery.zen.ping.unicast.hosts: ["master", "slave-1", "slave-2", "slave-3"]
discovery.zen.ping.unicast.hosts: ["IP_server1", "IP_server2", "slave-2", "slave-3"]
gateway.recover_after_nodes: 4

Note: master node will be selected automatically.

Run/Close Elasticsearch

References:

Change working directory in ElasticSearch home. for starting ElasticSearch run following commands:

./bin/elasticsearch -p /tmp/elasticsearch-pid -d
  • -d: means running as deamen.
  • -p: means save used PID on given file. it will be used for closing ElasticSearch.

for closing ElasticSearch run:

pkill -F /tmp/elasticsearch-pid

Replicas

My index name is search-engine

curl -XPUT 'localhost:9200/search-engine/_settings' -d '
{
    "index" : {
        "number_of_replicas" : 1
    }
}'

or run this command on kibana:

PUT search-engine/_settings
{
    "index" : {
        "number_of_replicas" : 2
    }
}

for check the number of replicas run:

GET search-engine/_settings

Make / Drop an index

for drop an index run:

DELETE search-engine/

or

curl -XDELETE localhost:9200/search-engine

and for creating an index run:

PUT search-engine
{
  
}

or

curl -XPUT "http://localhost:9200/search-engine" -H 'Content-Type: application/json' -d'
{
  
}'
  • Note: make sure the index be created before using ElasticDAOImpl