Introduction:
Elasticsearch is a powerful and scalable open-source search and analytics engine. It allows you to store, search, and analyze large volumes of data quickly and efficiently. In this article, we will walk you through the process of installing and configuring Elasticsearch on Rocky Linux 8.
Step 1: Update System Packages
Before proceeding with the installation, it is recommended to update the system packages to their latest versions. Open a terminal and execute the following commands:
sudo dnf update
Step 2: Install Java
Elasticsearch requires Java to run. Rocky Linux 8 ships with OpenJDK, which is suitable for running Elasticsearch. Install OpenJDK by running the following command:
sudo dnf install java-11-openjdk-devel
Verify the installation by checking the Java version:
java -version
Step 3: Import Elasticsearch GPG Key
Import the Elasticsearch GPG key to ensure package integrity. Run the following command to import the key:
sudo rpm --import https://artifacts.elastic.co/GPG-KEY-elasticsearch
Step 4: Add Elasticsearch Repository
Add the Elasticsearch repository to your system’s package manager. Create the repository configuration file with the following command:
sudo nano /etc/yum.repos.d/elasticsearch.repo
Copy and paste the following configuration into the file:
[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
Save the changes and exit the editor.
Step 5: Install Elasticsearch
Now, you can install Elasticsearch by running the following command:
sudo dnf install elasticsearch
Step 6: Configure Elasticsearch
Open the Elasticsearch configuration file for editing:
sudo nano /etc/elasticsearch/elasticsearch.yml
By default, Elasticsearch is configured to listen on localhost (127.0.0.1). If you want to allow connections from other machines on the network, find the following line and replace it with your server’s IP address:
network.host: 0.0.0.0
Save the changes and exit the editor.
Step 7: Start and Enable Elasticsearch
Start the Elasticsearch service:
sudo systemctl start elasticsearch
Enable Elasticsearch to start on boot:
sudo systemctl enable elasticsearch
Step 8: Test Elasticsearch
Verify that Elasticsearch is running correctly. Open a web browser and navigate to the following URL:
http://localhost:9200
You should see a JSON response containing information about your Elasticsearch cluster.
Step 9: Secure Elasticsearch (Optional)
For production environments, it is recommended to secure your Elasticsearch cluster. You can refer to the official Elasticsearch documentation for detailed instructions on how to enable security features such as authentication and SSL/TLS encryption.
Conclusion:
Congratulations! You have successfully installed and configured Elasticsearch on Rocky Linux 8. Elasticsearch provides a robust search and analytics platform that can power various applications and use cases. Take some time to explore the Elasticsearch documentation to learn more about its capabilities and how to leverage them for your specific needs.