Installing Elasticsearch on Ubuntu Server
Elasticsearch is a powerful open-source search and analytics engine. This guide will walk you through the process of installing Elasticsearch on an Ubuntu server.Prerequisites
- []An Ubuntu server (20.04 or later recommended).
[]A user with sudo privileges. - At least 2GB of RAM for optimal performance.
Ensure your system is up to date.
Code: Select all
sudo apt update && sudo apt upgrade -y
Elasticsearch requires Java. Install the OpenJDK package:
Code: Select all
sudo apt install openjdk-17-jdk -y
Code: Select all
java -version
Code: Select all
openjdk version "17.x.x"
1. Download and install the public signing key:
Code: Select all
curl -fsSL https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo gpg --dearmor -o /usr/share/keyrings/elasticsearch-keyring.gpg
Code: Select all
echo "deb [signed-by=/usr/share/keyrings/elasticsearch-keyring.gpg] https://artifacts.elastic.co/packages/8.x/apt stable main" | sudo tee /etc/apt/sources.list.d/elastic-8.x.list
Code: Select all
sudo apt update
Install Elasticsearch using the apt package manager:
Code: Select all
sudo apt install elasticsearch -y
Open the configuration file:
Code: Select all
sudo nano /etc/elasticsearch/elasticsearch.yml
Set the network host to allow external connections:
Code: Select all
network.host: 0.0.0.0
Code: Select all
cluster.name: my-cluster
Step 6: Enable and Start Elasticsearch
Enable Elasticsearch to start on boot:
Code: Select all
sudo systemctl enable elasticsearch
Code: Select all
sudo systemctl start elasticsearch
Code: Select all
sudo systemctl status elasticsearch
Test if Elasticsearch is running:
Code: Select all
curl -X GET "http://localhost:9200/"
Code: Select all
{
"name" : "your-server-name",
"cluster_name" : "my-cluster",
"version" : {
"number" : "8.x.x",
...
}
}
Set up a password for the elastic user:
Code: Select all
sudo /usr/share/elasticsearch/bin/elasticsearch-setup-passwords interactive
Optional: Allow Remote Access
To access Elasticsearch from other machines, open port 9200 in the firewall:
Code: Select all
sudo ufw allow 9200
Code: Select all
sudo systemctl restart elasticsearch
Kibana is a visualization tool for Elasticsearch. To install it:
1. Install Kibana:
Code: Select all
sudo apt install kibana -y
Code: Select all
sudo systemctl enable kibana
sudo systemctl start kibana
Code: Select all
http://your-server-ip:5601
Conclusion
Elasticsearch is now successfully installed on your Ubuntu server!