Installing OpenSearch Locally on Ubuntu without Docker
Are you looking to install OpenSearch for your local Magento2 development environment but hesitant to use Docker? You’re not alone! In this post, we’ll guide you through the process of installing and running OpenSearch directly on your Ubuntu 22.04 machine.
Why Install OpenSearch Locally?
Before diving into the installation steps, let’s briefly discuss why you might want to install OpenSearch locally without Docker:
- Resource Control: Installing OpenSearch directly gives you more control over resource allocation for both the application and the underlying operating system.
- Ease of Integration: You can easily integrate it with your existing local tools and workflows without worrying about Docker-specific configurations.
- Learning Experience: Understanding the manual installation process helps deepen your knowledge of OpenSearch.
Prerequisites
Before you begin, make sure you have:
- An Ubuntu 22.04 system
- Magento 2.4.6 installed in your local environment (optional)
Step-by-Step Installation Guide
1. Update Your System
First, update your package index and upgrade the installed packages:
sudo apt update
sudo apt upgrade -y
2. Install Required Dependencies
OpenSearch requires Java to run. Since Ubuntu comes with OpenJDK by default, you don’t need to install it separately. However, let’s ensure you have the necessary permissions and tools:
sudo apt install openjdk-8-jdk -y
sudo apt install wget curl -y
3. Download and Extract OpenSearch
Navigate to the official OpenSearch download page: https://www.opensearch.org/downloads.html
For this guide, we’ll use the latest version available at the time of writing (1.2.0):
cd /tmp
wget https://artifacts.opensearch.org/releases/downloads/opensearch-1.2.0-amd64.deb
Extract the downloaded .deb file:
sudo dpkg -x opensearch-1.2.0-amd64.deb /opt/opensearch
4. Configure OpenSearch
Now, let’s configure the OpenSearch instance.
Navigate to the configuration directory:
cd /opt/opensearch/config/opensearch.yml
Open the opensearch.yml file in your preferred text editor (e.g., nano):
sudo nano opensearch.yml
Ensure the following lines are uncommented and updated accordingly:
# Set the cluster name. By default, the node name is set to the hostname.
cluster.name: my-opensearch-cluster
# Add custom attributes to the nodes configuration
node.name: opensearch-node-1
# Set the path for storing OpenSearch data
path.data: /opt/opensearch/data
# Set the path for temporary files
path.logs: /opt/opensearch/logs
# The names of plugins that should be pre-installed on all nodes.
plugins.security.enabled: true
5. Start and Verify OpenSearch
Start the OpenSearch service:
sudo systemctl start opensearch
Enable the service to start on boot:
sudo systemctl enable opensearch
Verify that OpenSearch is running by checking its status:
sudo systemctl status opensearch
You should see a message indicating that it’s active (running).
To check if your instance is accessible, navigate to http://localhost:9200 in your browser. If the installation was successful, you should see the OpenSearch version information.
Conclusion
In this post, we demonstrated how to install and run OpenSearch locally on an Ubuntu 22.04 machine without using Docker. We covered prerequisites, dependency installation, download and extraction of the OpenSearch package, configuration, and final startup verification.
Remember, while this approach works for local development environments, it’s essential to use a proper server and containerization tools like Docker in production settings for better security and manageability.
For more advanced OpenSearch configurations or if you encounter any issues, consider checking out the official documentation at https://www.opensearch.org/documentation.html.
Happy coding!