How to Install Elasticsearch: Step-by-Step Guide
To install
Elasticsearch, download the official package from the Elasticsearch website or use your system's package manager like apt for Ubuntu or yum for CentOS. After installation, start the elasticsearch service and verify it is running by accessing http://localhost:9200.Syntax
Installation commands vary by operating system. Use package managers for easy installation:
- Ubuntu/Debian: Use
aptto install Elasticsearch. - CentOS/RHEL: Use
yumto install Elasticsearch. - Windows: Download the ZIP package and run Elasticsearch manually.
After installation, use systemctl start elasticsearch to start the service and systemctl enable elasticsearch to start it on boot.
bash
sudo apt update sudo apt install elasticsearch sudo systemctl start elasticsearch sudo systemctl enable elasticsearch
Example
This example shows how to install Elasticsearch on Ubuntu using apt, start the service, and check if it is running by querying the default HTTP port.
bash
sudo apt update
sudo apt install elasticsearch
sudo systemctl start elasticsearch
curl -X GET "http://localhost:9200/"Output
{
"name" : "your-node-name",
"cluster_name" : "elasticsearch",
"cluster_uuid" : "some-uuid",
"version" : {
"number" : "8.x.x",
"build_flavor" : "default",
"build_type" : "tar",
"build_hash" : "hash",
"build_date" : "date",
"build_snapshot" : false,
"lucene_version" : "version",
"minimum_wire_compatibility_version" : "version",
"minimum_index_compatibility_version" : "version"
},
"tagline" : "You Know, for Search"
}
Common Pitfalls
Common mistakes when installing Elasticsearch include:
- Not updating package lists before installation, causing outdated versions.
- Failing to start the Elasticsearch service after installation.
- Not enabling the service to start on boot, leading to Elasticsearch being off after reboot.
- Firewall blocking port 9200, preventing access to Elasticsearch.
Always check service status with sudo systemctl status elasticsearch and ensure port 9200 is open.
bash
sudo apt install elasticsearch # Missing 'sudo systemctl start elasticsearch' means Elasticsearch won't run # Correct way: sudo systemctl start elasticsearch sudo systemctl enable elasticsearch
Quick Reference
Summary tips for installing Elasticsearch:
- Use official repositories or packages for your OS.
- Always update your package manager before installing.
- Start and enable the Elasticsearch service after installation.
- Verify installation by accessing
http://localhost:9200. - Check firewall settings to allow Elasticsearch traffic.
Key Takeaways
Use your system's package manager or official downloads to install Elasticsearch.
Always start and enable the Elasticsearch service after installation.
Verify Elasticsearch is running by accessing http://localhost:9200.
Update package lists before installation to get the latest version.
Check firewall settings to ensure Elasticsearch port 9200 is accessible.