Skip to content

Instantly share code, notes, and snippets.

@hydeenoble
Last active June 15, 2023 06:40
Show Gist options
  • Save hydeenoble/e3edb7e73df13095a8804bc1cbd31e10 to your computer and use it in GitHub Desktop.
Save hydeenoble/e3edb7e73df13095a8804bc1cbd31e10 to your computer and use it in GitHub Desktop.
Install Elasticsearch on Amazon Linux (EC2)

Installing Elasticsearch on AWS Linux AMI

The following will guide you through the process of installing Elasticsearch on an AWS EC2 instance running Amazon Linux AMI 2016.09 - Release Notes

For this process I'll be using a t2.micro EC2 instance running Amazon Linux AMI. Once the EC2 instance is up-and-running, connect to your server via ssh.

Install JAVA 8

sudo yum install java-1.8.0
sudo yum remove java-1.7.0-openjdk

Installing Elasticsearch using RPM

$ sudo rpm -i https://download.elastic.co/elasticsearch/release/org/elasticsearch/distribution/rpm/elasticsearch/2.3.3/elasticsearch-2.3.3.rpm

Other versions of Elasticsearch are available here. Refer to the guide if you prefer installing with yum.

Register Elasticsearch as a system service.

$ sudo chkconfig --add elasticsearch

Start elasticsearch as a service

$ sudo service elasticsearch start

Once started, let's verify the Elasticsearch cluster by using curl to request the cluster state.

$ curl localhost:9200/_cluster/health?pretty

We should have something as below displayed in the terminal.

{ 
  “cluster_name” : “esonaws”, 
  “status” : “green”, 
  “timed_out” : false, 
  “number_of_nodes” : 3, 
  “number_of_data_nodes” : 3, 
  “active_primary_shards” : 8, 
  “active_shards” : 16, 
  “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 
}

You might want to play around the configuration for elasticsearch. To open the configuration file, run:

sudo nano /etc/elasticsearch/elasticsearch.yml

Your Elasticsearch cluster is ready!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment