Installing an Elasticsearch Cluster with 2 Nodes

Download the latest version of Elasticsearch from here and unpack it to /opt:

cd /opt
tar -xvpf elasticsearch-1.3.4.tar.gz
ln -s elasticsearch-1.3.4 elasticsearch

Given you want to create a cluster named my-ecs-cluster, having 2 nodes with IP address and (change it according to your setup, you might also want to use hostnames instead of IPs)

Then edit /opt/elasticsearch/config/elasticsearch.yml on the first node, changing/uncommenting the following lines: my-ecs-cluster
node.master: true true
index.number_of_shards: 2
index.number_of_replicas: 1
transport.tcp.port: 9300
http.port: 9200 3s ["", ""]

On the second node the changes are almost the same, the only difference:


To start the service on the 2 nodes you can do it just as follows:

export ES_JAVA_OPTS="-Duser.timezone=GMT"
export JAVA_OPTS="-Duser.timezone=GMT"
ulimit -l unlimited
export ES_MIN_MEM="2048m"
export ES_MAX_MEM="4096m"
cd /opt/elasticsearch
nohup /opt/elasticsearch/bin/elasticsearch > /dev/null 2>&1 &

Please adjust the proper timezone and values ES_MIN_MEM/ES_MIN_MAX to fit your server's RAM, else the java process might not want to start up if values are too high.

Checking if everyhting is running:

When everything as started, calling should output something like this:

  "cluster_name" : "my-ecs-cluster",
  "status" : "green",
  "timed_out" : false,
  "number_of_nodes" : 2,
  "number_of_data_nodes" : 2,
  "active_primary_shards" : 2,
  "active_shards" : 2,
  "relocating_shards" : 0,
  "initializing_shards" : 0,
  "unassigned_shards" : 0