Step-by-Step Guide
- Update the Package Index
Open a terminal and update the package index to ensure you have the latest information about available packages:
sudo yum update -y
- Download and Install the Elasticsearch Public Signing Key
Add the Elasticsearch public GPG key to your system:
sudo rpm --import https://artifacts.elastic.co/GPG-KEY-elasticsearch
- Create the Elasticsearch Repository
Create a repository file for Elasticsearch:
sudo tee /etc/yum.repos.d/elasticsearch.repo <<EOF
[elasticsearch-7.x]
name=Elasticsearch repository for 7.x packages
baseurl=https://artifacts.elastic.co/packages/7.x/yum
gpgcheck=1
gpgkey=https://artifacts.elastic.co/GPG-KEY-elasticsearch
enabled=1
autorefresh=1
type=rpm-md
EOF
- Install Elasticsearch
Install Elasticsearch using theyum
package manager:
sudo yum install elasticsearch -y
- Configure Elasticsearch
Open the Elasticsearch configuration file for editing:
sudo nano /etc/elasticsearch/elasticsearch.yml
Set the network.host
to localhost
to restrict external access:
network.host: localhost
Save and close the file.
- Start and Enable Elasticsearch
Start the Elasticsearch service:
sudo systemctl start elasticsearch
Enable Elasticsearch to start on boot:
sudo systemctl enable elasticsearch
- Verify Elasticsearch Installation
Check the Elasticsearch service status to ensure it is running:
sudo systemctl status elasticsearch
If Elasticsearch is running, you should see an active (running) status.
- Test Elasticsearch Installation
Test the Elasticsearch installation by sending an HTTP request to the Elasticsearch server:curl -X GET "localhost:9200/"
You should see a JSON response with information about your Elasticsearch cluster. - Install Elasticsearch Plugins (Optional)
Elasticsearch supports various plugins. To install a plugin, use theelasticsearch-plugin
command. For example, to install the analysis-icu plugin:sudo /usr/share/elasticsearch/bin/elasticsearch-plugin install analysis-icu
Restart Elasticsearch to apply the changes:sudo systemctl restart elasticsearch
- Configure Elasticsearch Memory Settings (Optional)
By default, Elasticsearch allocates 1GB of heap memory. To adjust the heap size, open thejvm.options
file:bash sudo nano /etc/elasticsearch/jvm.options
Modify the-Xms
and-Xmx
settings to allocate the desired amount of memory (e.g., 2GB):conf -Xms2g -Xmx2g
Save and close the file. Restart Elasticsearch to apply the changes:bash sudo systemctl restart elasticsearch