OpenSearch is a robust, open-source search engine technology that allows users to create and implement custom search solutions. Originally developed from Elasticsearch, this community-driven project is ideal for handling large datasets, real-time data analytics, or building custom search applications. Its scalability, flexibility, and community-focused development make it an essential tool across industries.
This guide will show you how to install OpenSearch on Ubuntu 24, optimized for use with Magento 2.4.7, the latest version of the powerful e-commerce platform.
At W3ctrl, we specialize in Magento 2 development services, Magento 2 migration services, and Magento 2 extension development. If you’re looking to improve your online store’s search capabilities with OpenSearch or need assistance with any aspect of Magento development, we can help! Explore our wide range of Magento 2 SEO services and Magento 2 maintenance services tailored to support your e-commerce growth.
Step 1: Adding the OpenSearch Repository
As OpenSearch is not available in Ubuntu 24’s default repositories, the first step is to add the OpenSearch repository to your system.
First, install the necessary dependencies:
apt -y install curl lsb-release gnupg2 ca-certificates
Then, import the GPG key required to sign OpenSearch packages:
curl -fsSL https://artifacts.opensearch.org/publickeys/opensearch.pgp | gpg --dearmor -o /etc/apt/trusted.gpg.d/opensearch.gpg
Add the OpenSearch repository to your sources list:
echo "deb https://artifacts.opensearch.org/releases/bundle/opensearch/2.x/apt stable main" | tee /etc/apt/sources.list.d/opensearch-2.x.list
Update the package list to reflect the changes:
apt update -y
Looking to migrate your online store to Magento 2.4.7? At W3ctrl, we offer seamless Magento 2 migration services to ensure a smooth transition with minimal downtime. Whether you’re upgrading from an older version or moving from a different platform, we’ve got you covered.
Step 2: Installing and Configuring OpenSearch
To set an initial admin password for OpenSearch during installation, use the following command. Replace “Y0ur@SecurP4assword” with a secure password of your choice:
env OPENSEARCH_INITIAL_ADMIN_PASSWORD=Y0ur@SecurP4assword apt install opensearch
Once installed, you need to adjust the configuration file to match your Magento store requirements. Open the configuration file:
nano /etc/opensearch/opensearch.yml
Modify these settings based on your needs:
cluster.name: magento2 network.host: localhost http.port: 9200 plugins.security.disabled: false plugins.security.ssl.http.enabled: false
After making the necessary adjustments, reload the systemd daemon to apply changes:
systemctl daemon-reload
Restart the OpenSearch service:
systemctl restart opensearch
Check the status of OpenSearch with this command:
systemctl status opensearch
How to check OpenSearch cluster status properly using terminal
Please try to execute the following command:
curl -XGET http://localhost:9201/_cluster/health?pretty
Are you looking to enhance your Magento store with powerful custom functionalities? We provide Magento 2 extension development services that allow you to tailor your store to meet specific business requirements. Whether it’s for adding new features or integrating third-party tools, W3ctrl can develop the perfect solution for your store.
If you’re looking for a complete tutorial on installing Magento 2 and a LAMP server, you can follow this article How to Install Magento 2.4.X on Ubuntu with LAMP And ElasticSearch
Step 3: Configure OpenSearch in Magento 2
Now that OpenSearch is installed and running, the next step is to configure it for Magento 2.4.7.
To migrate from Elasticsearch to OpenSearch (version 2.4.5 or below) in Magento, follow these steps:
Log in to your Magento Admin.
Navigate to: Stores > Configurations > Catalog > Catalog > Catalog Search
Update the search engine configuration as follows:
Search Engine: Select Opensearch
OpenSearch Server Hostname: localhost
Opensearch Server Port: 9200
Opensearch Index Prefix: magento2
Enable Opensearch HTTP Auth: No
You can also refer to the image below for visual guidance on setting up these configurations
After making the necessary adjustments, remember to Test Connection.
Finally, run the following commands to reindex and clear the cache:
php bin/magento indexer:reindex && php bin/magento cache:flush
This ensures that Magento is fully integrated with OpenSearch and operating optimally for your online store.
W3ctrl is your trusted partner for all things Magento, offering comprehensive services including Magento 2 SEO optimization, Magento 2 maintenance services, and more. Let us help you scale your business with tailored Magento solutions. Reach out today to learn more!