How to Install Elasticsearch on Arch Linux
Overview
This tutorial will guide you through the process of installing Elasticsearch from https://www.elastic.co/ on Arch Linux.
Prerequisites
- Arch Linux installed
- Terminal or command-line interface access with sudo privileges
- Internet connection
Step-by-Step Guide
Open a terminal window on your Arch Linux system
Run the following command to update your system package list and upgrade installed packages:
sudo pacman -Syu
- Elasticsearch is a Java-based application, so make sure you have Java installed on your system. Run the following command to check for the availability of Java on your system:
java -version
If Java is not installed, run the following command to install it:
sudo pacman -S jre-openjdk
- Now you can proceed to download and install Elasticsearch. Run the following command to download the Elasticsearch package:
curl -L -O https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.15.1-linux-x86_64.tar.gz
You can replace the version number with the latest Elasticsearch version number available at the time of installing.
- Extract the downloaded package using the following command:
tar -xvf elasticsearch-7.15.1-linux-x86_64.tar.gz
- Move the extracted files to the /usr/share/elasticsearch directory with the following command:
sudo mv elasticsearch-7.15.1 /usr/share/elasticsearch
- Elasticsearch requires all of its data to be stored in a separate location from the installation directory. Therefore, you need to create a separate directory for data storage.
sudo mkdir /var/lib/elasticsearch
- Grant ownership of the newly created directory to the Elasticsearch user with the following command:
sudo chown -R elasticsearch:elasticsearch /var/lib/elasticsearch
- Configure Elasticsearch. Run the following command to open Elasticsearch's configuration file:
sudo nano /usr/share/elasticsearch/config/elasticsearch.yml
- In the configuration file, uncomment and modify the following lines to:
cluster.name: my_cluster_name
node.name: my_node_name
path.data: /var/lib/elasticsearch
path.logs: /usr/share/elasticsearch/logs
Save the configuration file and exit the editor by pressing
Ctrl+X, followed byYandEnter.Install Elasticsearch as a service. Run the following command:
sudo /usr/share/elasticsearch/bin/elasticsearch-systemd-pre-units install
- Enable and start the Elasticsearch service by running the following commands:
sudo systemctl enable elasticsearch
sudo systemctl start elasticsearch
- Verify that Elasticsearch is running by accessing its REST API endpoint:
curl -X GET "http://localhost:9200/"
If Elasticsearch is running successfully, then you'll receive a JSON output.
Conclusion
That's it! You have successfully installed Elasticsearch on your Arch Linux system! Elasticsearch is a powerful search engine that can be used to search, analyze, and visualize your data. We hope that you found this tutorial helpful.