Paridhi SolutionsBlog
Magento

How to Install OpenSearch on Ubuntu 24.04 LTS for Magento 2.4.8 (Complete Guide)

Learn how to install and configure OpenSearch on Ubuntu 24.04 LTS for Magento. This step-by-step guide covers installation, configuration, JVM optimization, verification, troubleshooting, and production best practices.

Paridhi Solutions
2026-07-02
12 min read read
How to Install OpenSearch on Ubuntu 24.04 LTS for Magento 2.4.8 (Complete Guide)

How to Install OpenSearch on Ubuntu 24.04 LTS for Magento

OpenSearch is one of the most important components of a modern Magento installation. It powers product search, layered navigation, catalog indexing, and delivers fast, relevant search results for customers.

Starting with recent Magento releases, a dedicated search engine is mandatory. OpenSearch is the recommended open-source search engine and provides excellent performance while remaining fully compatible with Magento.

In this guide, you'll learn how to install OpenSearch on Ubuntu 24.04 LTS, configure it correctly, verify that it's working, and prepare it for a production Magento environment.


What is OpenSearch?

OpenSearch is an open-source search and analytics engine built for high-performance searching and indexing.

Originally derived from Elasticsearch, OpenSearch is now maintained by the OpenSearch Project and is widely adopted for eCommerce platforms, logging, analytics, and enterprise search.

For Magento, OpenSearch stores indexed catalog data, allowing customers to quickly search thousands of products without placing unnecessary load on the database.

Some of the key advantages include:

  • Extremely fast search performance
  • Advanced filtering and aggregation
  • Scalability
  • REST API support
  • Open-source licensing
  • Active community development

Why Does Magento Require OpenSearch?

Magento no longer relies on MySQL for product search.

Instead, Magento indexes products into OpenSearch, allowing customers to search by:

  • Product Name
  • SKU
  • Categories
  • Attributes
  • Price
  • Brand
  • Color
  • Custom Filters

Without OpenSearch, Magento cannot build or query its search indexes correctly.


System Requirements

Before installing OpenSearch, ensure your server meets these minimum recommendations.

ComponentRecommended
Ubuntu24.04 LTS
RAM4 GB minimum (8 GB recommended)
CPU2 Cores or higher
DiskSSD recommended
JavaOpenJDK 21 (or the version recommended by your OpenSearch release)
Root AccessSudo User

Tip

OpenSearch performs best on SSD storage with sufficient RAM. For production Magento stores, 8 GB or more of memory is recommended.


Prerequisites

Before continuing, make sure you've already completed the following guides.

✅ Install PHP

✅ Install Composer

✅ Install MySQL

OpenSearch is typically installed before Magento itself so the installer can connect to the search engine during setup.


Step 1 — Update Ubuntu

Begin by updating your package list and installed packages.

bash
sudo apt update
sudo apt upgrade -y

Keeping your server updated ensures that you receive the latest security patches and package improvements before installing additional software.


Step 2 — Verify Java Installation

OpenSearch requires Java.

Check whether Java is already installed.

bash
java -version

If Java is installed, you'll see output similar to:

text
openjdk version "21"
OpenJDK Runtime Environment
OpenJDK 64-Bit Server VM

If Java is not installed, continue to the next step.


Step 3 — Install OpenJDK

Install OpenJDK.

bash
sudo apt install openjdk-21-jdk -y

After installation, verify again.

bash
java -version

You should now see the installed Java version.

Why is Java required?

OpenSearch is written in Java and runs on the Java Virtual Machine (JVM). Without Java, OpenSearch cannot start.


Step 4 — Import the OpenSearch GPG Key

To verify package authenticity, import the official signing key.

bash
curl -o- https://artifacts.opensearch.org/publickeys/opensearch.pgp \
| sudo gpg --dearmor \
| sudo tee /usr/share/keyrings/opensearch-keyring.gpg >/dev/null

This ensures packages installed from the OpenSearch repository are trusted.


Step 5 — Add the OpenSearch Repository

Create the repository configuration file.

bash
echo "deb [signed-by=/usr/share/keyrings/opensearch-keyring.gpg] https://artifacts.opensearch.org/releases/bundle/opensearch/2.x/apt stable main" | sudo tee /etc/apt/sources.list.d/opensearch-2.x.list

Refresh package information.

bash
sudo apt update

Ubuntu now knows where to download OpenSearch packages.


What We've Completed

At this stage you've successfully:

  • Updated Ubuntu
  • Verified Java
  • Installed OpenJDK (if required)
  • Added the official OpenSearch repository
  • Refreshed package information

Step 6 — Install OpenSearch

Now that the repository has been added successfully, install OpenSearch.

bash
sudo apt install opensearch -y

The installation may take a few minutes depending on your server and internet connection.

Once completed, verify that the package is installed.

bash
opensearch --version

You should see output similar to:

text
Version: 2.x.x

Step 7 — Configure OpenSearch

The primary configuration file is located at:

text
/etc/opensearch/opensearch.yml

Open the configuration file.

bash
sudo nano /etc/opensearch/opensearch.yml

Locate or add the following settings.

yaml
cluster.name: magento-cluster

node.name: magento-node

network.host: 127.0.0.1

http.port: 9200

discovery.type: single-node

Configuration Explained

SettingDescription
cluster.nameName of your OpenSearch cluster
node.nameName of this OpenSearch node
network.hostIP address OpenSearch listens on
http.portDefault REST API port
discovery.typeEnables single-node mode

Why use 127.0.0.1?

For a Magento server, OpenSearch usually runs on the same machine.

Using:

yaml
network.host: 127.0.0.1

prevents external users from directly accessing your search engine.

This is considered a good security practice.

Only expose OpenSearch publicly if you understand the associated security implications.


Step 8 — Configure JVM Memory

OpenSearch runs on Java.

Its memory allocation is controlled by the JVM.

Open the JVM configuration.

bash
sudo nano /etc/opensearch/jvm.options

Locate these lines.

text
-Xms1g

-Xmx1g

These values define the minimum and maximum heap size.


Server RAMHeap Size
4 GB1 GB
8 GB2 GB
16 GB4 GB
32 GB8 GB

A good rule of thumb is to allocate approximately 50% of your available RAM to the JVM while leaving enough memory for the operating system, PHP, MySQL, and other services.

⚠️ Important

Avoid allocating more than 50% of your server's RAM to OpenSearch, as the operating system and other applications also require memory.


Step 9 — Enable OpenSearch at Boot

Enable the service so it starts automatically whenever the server restarts.

bash
sudo systemctl enable opensearch

Expected output:

text
Created symlink...

Step 10 — Start OpenSearch

Start the service.

bash
sudo systemctl start opensearch

Check its status.

bash
sudo systemctl status opensearch

Example output:

text
Active: active (running)

If the service is running successfully, OpenSearch has started correctly.


Step 11 — Verify OpenSearch is Running

Use curl to query the REST API.

bash
curl -X GET http://localhost:9200

Example response:

json
{
  "name": "magento-node",
  "cluster_name": "magento-cluster",
  "cluster_uuid": "xxxxxxxx",
  "version": {
    "number": "2.x.x"
  },
  "tagline": "The OpenSearch Project: https://opensearch.org/"
}

Receiving a JSON response confirms that OpenSearch is operational.


Step 12 — Verify the Service is Listening

Check that OpenSearch is listening on port 9200.

bash
sudo ss -tulpn | grep 9200

Example:

text
LISTEN 0 511 127.0.0.1:9200

This confirms the service is accepting connections on the expected port.


Step 13 — Test Cluster Health

Query the cluster health endpoint.

bash
curl http://localhost:9200/_cluster/health?pretty

Example response:

json
{
  "cluster_name": "magento-cluster",
  "status": "green",
  "number_of_nodes": 1
}

Cluster Status Explained

StatusMeaning
GreenEverything is working correctly
YellowMinor issue, typically missing replicas on a single-node cluster
RedSerious issue requiring investigation

For a single-node Magento server, a yellow status can be expected if replica shards are configured. A green status indicates all primary and replica requirements are satisfied.


Step 14 — Restart OpenSearch

Whenever you modify the configuration, restart the service.

bash
sudo systemctl restart opensearch

Verify the status again.

bash
sudo systemctl status opensearch

If no errors appear, the configuration has been applied successfully.


What We've Completed

Congratulations! At this point you've:

  • Installed OpenSearch
  • Configured the cluster
  • Configured the node
  • Secured network access
  • Optimized JVM memory
  • Enabled automatic startup
  • Started the service
  • Verified the REST API
  • Checked cluster health

Production Best Practices

Installing OpenSearch is only the first step. For a production Magento store, proper configuration and maintenance are equally important.

Follow these best practices to improve performance, stability, and security.

1. Keep OpenSearch Updated

Regularly update your server.

bash
sudo apt update
sudo apt upgrade

New releases include:

  • Security patches
  • Performance improvements
  • Bug fixes

2. Monitor Disk Space

OpenSearch continuously stores indexes.

Check available disk space.

bash
df -h

If disk usage becomes too high, indexing may stop.


3. Monitor Memory Usage

Check memory usage.

bash
free -h

For detailed Java memory information:

bash
jcmd $(pgrep java) VM.flags

If your server frequently runs out of memory, consider increasing RAM instead of allocating excessive heap memory.


4. Monitor OpenSearch Logs

Logs are extremely useful when troubleshooting.

bash
sudo tail -f /var/log/opensearch/opensearch.log

Common issues include:

  • Memory allocation
  • Missing permissions
  • JVM errors
  • Plugin issues

5. Back Up Your Configuration

Keep backups of important configuration files.

text
/etc/opensearch/opensearch.yml

/etc/opensearch/jvm.options

This makes recovery much easier after accidental changes.


Security Recommendations

Although OpenSearch is often installed on the same server as Magento, basic security practices should still be followed.

Keep OpenSearch Private

If Magento and OpenSearch run on the same server:

yaml
network.host: 127.0.0.1

Avoid exposing OpenSearch directly to the internet unless it's protected by proper authentication and network controls.


Restrict Firewall Access

If OpenSearch is installed on a dedicated server, allow access only from trusted application servers.

Example using UFW:

bash
sudo ufw allow from YOUR_SERVER_IP to any port 9200

Replace YOUR_SERVER_IP with the IP address of your Magento server.


For production environments, encrypt communication between Magento and OpenSearch using HTTPS.

This protects search traffic from interception.


Troubleshooting

OpenSearch Won't Start

Check the service status.

bash
sudo systemctl status opensearch

Review detailed logs.

bash
sudo journalctl -u opensearch

Also inspect the OpenSearch log.

bash
sudo tail -100 /var/log/opensearch/opensearch.log

Java Not Found

Verify Java.

bash
java -version

If Java isn't installed:

bash
sudo apt install openjdk-21-jdk

Port 9200 Already in Use

Identify the process.

bash
sudo lsof -i :9200

or

bash
sudo ss -tulpn | grep 9200

Stop the conflicting process or change the OpenSearch port if necessary.


Cluster Status is Red

Check cluster health.

bash
curl localhost:9200/_cluster/health?pretty

Common causes include:

  • Missing primary shards
  • Corrupted indexes
  • Disk full
  • Node failures

Review the logs to identify the underlying issue.


Out of Memory Errors

Symptoms include:

  • OpenSearch crashes
  • Slow indexing
  • High CPU usage

Possible solutions:

  • Increase server RAM.
  • Adjust JVM heap size.
  • Reduce the number of indexed documents if appropriate.

Connection Refused

Test the endpoint.

bash
curl http://localhost:9200

If it fails:

  • Verify the service is running.
  • Confirm the configured port.
  • Check firewall rules.
  • Review network.host in opensearch.yml.

Frequently Asked Questions

Why does Magento require OpenSearch?

Magento uses OpenSearch for catalog indexing, product search, layered navigation, and search suggestions. It provides significantly faster and more scalable search capabilities than querying the database directly.


Which port does OpenSearch use?

By default:

text
9200

How do I restart OpenSearch?

bash
sudo systemctl restart opensearch

How do I stop OpenSearch?

bash
sudo systemctl stop opensearch

How do I check the OpenSearch version?

bash
curl http://localhost:9200

or

bash
opensearch --version

Where is the configuration file located?

text
/etc/opensearch/opensearch.yml

Where are the log files stored?

text
/var/log/opensearch/

Conclusion

Congratulations! 🎉

You have successfully installed and configured OpenSearch on Ubuntu 24.04 LTS.

Your server is now ready to provide fast, scalable search capabilities for Magento.

In this guide, you learned how to:

  • Install OpenSearch
  • Configure the cluster
  • Configure JVM memory
  • Start and manage the service
  • Verify the installation
  • Monitor cluster health
  • Apply production best practices
  • Troubleshoot common issues

With OpenSearch running correctly, you're one step closer to completing a production-ready Magento server.


Continue the Magento Installation Series

Follow the complete installation series:

  • ✅ Install PHP 8.4 on Ubuntu 24.04
  • ✅ Install Composer on Ubuntu 24.04
  • ✅ Install MySQL 8 on Ubuntu 24.04
  • ✅ Install OpenSearch on Ubuntu 24.04
  • ➜ Install Redis on Ubuntu 24.04
  • Install Nginx
  • Install Magento 2.4.8
  • Configure Production Mode
  • Configure Cron Jobs
  • Set Correct File Permissions

Need Professional Magento Development?

Whether you're launching a new Magento store, migrating from another platform, integrating third-party systems, or optimizing performance, Paridhi Solutions can help.

Our expertise includes:

  • Adobe Commerce & Magento Development
  • Custom Module Development
  • API & ERP Integrations
  • Performance Optimization
  • Store Migration & Upgrades
  • Ongoing Maintenance & Support

🌐 Website: https://paridhisolutions.com

📧 Email: info@paridhisolutions.com

If this guide helped you, consider sharing it with your team or bookmarking it for future reference.

Tags

MagentoOpenSearchUbuntuUbuntu 24.04Search EngineLinux

Written by

Paridhi Solutions

Publishing in-depth tutorials, coding guides, and best practices for modern web development.

Visit Website →

Share this article

Related Articles