
Elasticsearch Cluster Setup and Configuration Tutorial step by step in AWS ec2.
sudo vi /etc/security/limits.conf
ec2-user - nofile 65535
This change will only take effect the next time the ec2-user user opens a new session.
To make it persistent, you can add this line:
$ sudo vi /etc/sysctl.conf
vm.max_map_count=262144
$ sudo sysctl -p
Role | Public IPs | Private IPs |
---|---|---|
Master | 13.234.59.125 | 172.31.20.87 |
Data | 13.126.179.145 | 172.31.30.190 |
Client | 35.154.20.21 | 172.31.23.201 |
In Master (Pub-13.234.59.125 Pvt-172.31.20.87)
$ sudo hostnamectl set-hostname es-master01
$ hostname
In Data (Pub-13.126.179.145 Pvt-172.31.30.190)
$ sudo hostnamectl set-hostname es-data01
$ hostname
In Client (Pub-35.154.20.21 Pvt-172.31.23.201)
$ sudo hostnamectl set-hostname es-client01
$ hostname
In 13.234.59.125(Master)
$ sudo vi /etc/hosts
172.31.20.87 es-master01
172.31.30.190 es-client01
172.31.23.201 es-data01
The more heap available to Elasticsearch, the more memory it can use for its internal caches, but the less
memory it leaves available for the operating system to use for the filesystem cache. Also, larger heaps can
cause longer garbage collection pauses.
Method 1 - in jvm.options file Here are examples of how to set the heap size via the jvm.options file:
-Xms1g # Set the minimum heap size to 1g.
-Xms2g # Set the minimum heap size to 2g.
-Xmx2g # Set the maximum heap size to 2g.
Method 2 - Set environment variable using ES_JAVA_OPTS
**Set the minimum 1000 MB and maximum heap size to 2000 MB.**
ES_JAVA_OPTS="-Xms1000m -Xmx2000m" ./bin/elasticsearch
**Set the minimum and maximum heap size to 2 GB.**
ES_JAVA_OPTS="-Xms2g -Xmx2g" ./bin/elasticsearch
**Set the minimum and maximum heap size to 4000 MB.**
ES_JAVA_OPTS="-Xms4000m -Xmx4000m" ./bin/elasticsearch
Recommended: For 1 CPU and 2 GB RAM for demo - this is recommended settings.
CLIENT
-Xms1g
-Xmx1g
Master
-Xms2g
-Xmx2g
DATA
-Xms1g
-Xmx1g
In Master (Pub-13.234.59.125 Pvt-172.31.20.87)
cluster.name: devopsschool
node.name: es-master01
node.master: true
node.data: false
network.host: 172.31.20.87
cluster.initial_master_nodes: ["es-master01"]
#discovery.seed_hosts: ["172.31.0.107", "172.31.14.88", "172.31.13.85"]
#or
discovery.seed_hosts: ["es-master01", "es-client01", "es-data01"]
In Data (Pub-13.126.179.145 Pvt-172.31.30.190)
cluster.name: devopsschool
node.name: es-client01
node.master: false
node.data: false
network.host: 172.31.30.190
cluster.initial_master_nodes: ["es-master01"]
#discovery.seed_hosts: ["172.31.0.107", "172.31.14.88", "172.31.13.85"]
#or
discovery.seed_hosts: ["es-master01", "es-client01", "es-data01"]
In Client (Pub-35.154.20.21 Pvt-172.31.23.201)
cluster.name: devopsschool
node.name: es-client01
node.master: false
node.data: false
network.host: 172.31.23.201
cluster.initial_master_nodes: ["es-master01"]
#discovery.seed_hosts: ["172.31.0.107", "172.31.14.88", "172.31.13.85"]
#or
discovery.seed_hosts: ["es-master01", "es-client01", "es-data01"]









I’m a DevOps/SRE/DevSecOps/Cloud Expert passionate about sharing knowledge and experiences. I am working at Cotocus. I blog tech insights at DevOps School, travel stories at Holiday Landmark, stock market tips at Stocks Mantra, health and fitness guidance at My Medic Plus, product reviews at I reviewed , and SEO strategies at Wizbrand.
Please find my social handles as below;
Rajesh Kumar Personal Website
Rajesh Kumar at YOUTUBE
Rajesh Kumar at INSTAGRAM
Rajesh Kumar at X
Rajesh Kumar at FACEBOOK
Rajesh Kumar at LINKEDIN
Rajesh Kumar at PINTEREST
Rajesh Kumar at QUORA
Rajesh Kumar at WIZBRAND