Installing Elasticsearch on EC2 Instance

Anirudh Agarwal
Aug 23, 2018 · 2 min read
(SSH into EC2 Instance)
ssh -v -i /pathto/[certfilename].pem ec2-user@[ec2hostname]
(Check JAVA Version)
java -version
(If its JAVA7, install JAVA8 and switch the default)
sudo yum install java-1.8.0
sudo alternatives --config java
(to switch the default JAVA version)
(Install Elasticsearch (6.3.2) using RPM)
sudo rpm -i https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-6.3.2.rpm
(Add Elasticsearch as a service in system default)
sudo chkconfig --add elasticsearch
(Start Elasticsearch)
sudo service elasticsearch start
java.nio.file.AccessDeniedException: /etc/elasticsearch/elasticsearch.keystoreor/etc/elasticsearch/elasticsearch.keystore (File not Found)
(Give permission to elasticsearch folder)
sudo chmod g+w /etc/elasticsearch
(Create the elasticsearch keystore file manually)
sudo -u elasticsearch -s /usr/share/elasticsearch/bin/elasticsearch-keystore create
(Start the Elasticsearch server)
sudo service elasticsearch start
curl localhost:9200/_cluster/health?prettyResponse:{
"cluster_name" : "elasticsearch",
"status" : "yellow",
"timed_out" : false,
"number_of_nodes" : 1,
"number_of_data_nodes" : 1,
"active_primary_shards" : 5,
"active_shards" : 5,
"relocating_shards" : 0,
"initializing_shards" : 0,
"unassigned_shards" : 5,
"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" : 50.0
}
(Add your private IP in the elasticsearch.yml file)
sudo vi /etc/elasticsearch/elasticsearch.yml
(In this file, find the network.host config and add your IP and uncomment http.port config also)
(Snippet from elasticsearch.yml)# Set the bind address to a specific IP (IPv4 or IPv6):#network.host: <EC2 Instance PRIVATE IP>## Set a custom port for HTTP:#http.port: 9200(Restart Elasticsearch)
sudo service elasticsearch restart
http://<PUBLIC-DNS>:9200/_cluster/health/?pretty

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade