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.
| Component | Recommended |
|---|---|
| Ubuntu | 24.04 LTS |
| RAM | 4 GB minimum (8 GB recommended) |
| CPU | 2 Cores or higher |
| Disk | SSD recommended |
| Java | OpenJDK 21 (or the version recommended by your OpenSearch release) |
| Root Access | Sudo 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.
bashsudo 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.
bashjava -version
If Java is installed, you'll see output similar to:
textopenjdk 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.
bashsudo apt install openjdk-21-jdk -y
After installation, verify again.
bashjava -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.
bashcurl -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.
bashecho "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.
bashsudo 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.
bashsudo 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.
bashopensearch --version
You should see output similar to:
textVersion: 2.x.x
Step 7 — Configure OpenSearch
The primary configuration file is located at:
text/etc/opensearch/opensearch.yml
Open the configuration file.
bashsudo nano /etc/opensearch/opensearch.yml
Locate or add the following settings.
yamlcluster.name: magento-cluster node.name: magento-node network.host: 127.0.0.1 http.port: 9200 discovery.type: single-node
Configuration Explained
| Setting | Description |
|---|---|
| cluster.name | Name of your OpenSearch cluster |
| node.name | Name of this OpenSearch node |
| network.host | IP address OpenSearch listens on |
| http.port | Default REST API port |
| discovery.type | Enables single-node mode |
Why use 127.0.0.1?
For a Magento server, OpenSearch usually runs on the same machine.
Using:
yamlnetwork.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.
bashsudo nano /etc/opensearch/jvm.options
Locate these lines.
text-Xms1g -Xmx1g
These values define the minimum and maximum heap size.
Recommended Heap Sizes
| Server RAM | Heap Size |
|---|---|
| 4 GB | 1 GB |
| 8 GB | 2 GB |
| 16 GB | 4 GB |
| 32 GB | 8 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.
bashsudo systemctl enable opensearch
Expected output:
textCreated symlink...
Step 10 — Start OpenSearch
Start the service.
bashsudo systemctl start opensearch
Check its status.
bashsudo systemctl status opensearch
Example output:
textActive: 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.
bashcurl -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.
bashsudo ss -tulpn | grep 9200
Example:
textLISTEN 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.
bashcurl http://localhost:9200/_cluster/health?pretty
Example response:
json{ "cluster_name": "magento-cluster", "status": "green", "number_of_nodes": 1 }
Cluster Status Explained
| Status | Meaning |
|---|---|
| Green | Everything is working correctly |
| Yellow | Minor issue, typically missing replicas on a single-node cluster |
| Red | Serious 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.
bashsudo systemctl restart opensearch
Verify the status again.
bashsudo 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.
bashsudo 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.
bashdf -h
If disk usage becomes too high, indexing may stop.
3. Monitor Memory Usage
Check memory usage.
bashfree -h
For detailed Java memory information:
bashjcmd $(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.
bashsudo 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:
yamlnetwork.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:
bashsudo ufw allow from YOUR_SERVER_IP to any port 9200
Replace YOUR_SERVER_IP with the IP address of your Magento server.
Enable HTTPS (Recommended)
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.
bashsudo systemctl status opensearch
Review detailed logs.
bashsudo journalctl -u opensearch
Also inspect the OpenSearch log.
bashsudo tail -100 /var/log/opensearch/opensearch.log
Java Not Found
Verify Java.
bashjava -version
If Java isn't installed:
bashsudo apt install openjdk-21-jdk
Port 9200 Already in Use
Identify the process.
bashsudo lsof -i :9200
or
bashsudo ss -tulpn | grep 9200
Stop the conflicting process or change the OpenSearch port if necessary.
Cluster Status is Red
Check cluster health.
bashcurl 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.
bashcurl http://localhost:9200
If it fails:
- Verify the service is running.
- Confirm the configured port.
- Check firewall rules.
- Review
network.hostinopensearch.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:
text9200
How do I restart OpenSearch?
bashsudo systemctl restart opensearch
How do I stop OpenSearch?
bashsudo systemctl stop opensearch
How do I check the OpenSearch version?
bashcurl http://localhost:9200
or
bashopensearch --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.



