openSUSE

How To Install Elasticsearch on openSUSE

Install Elasticsearch on openSUSE

In this tutorial, we will show you how to install Elasticsearch on openSUSE. Elasticsearch is a powerful open-source search and analytics engine that allows you to store, search, and analyze large volumes of data quickly and efficiently. It is widely used in various applications, such as log analysis, full-text search, security analytics, and business intelligence.

This article assumes you have at least basic knowledge of Linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple and assumes you are running in the root account, if not you may need to add ‘sudo’ to the commands to get root privileges. I will show you the step-by-step installation of the Elasticsearch on openSUSE.

Prerequisites

  • A server running one of the following operating systems: openSUSE (Leap or Tumbleweed)
  • Familiarity with basic Linux commands and openSUSE’s package management system (zypper) is also beneficial, as you’ll be interacting with the command line during the installation process.
  • You will need access to the terminal to execute commands. openSUSE provides the Terminal application for this purpose. It can be found in your Applications menu.
  • You’ll need an active internet connection to download Elasticsearch and its dependencies.
  • You’ll need administrative (root) access or a user account with sudo privileges.

Install Elasticsearch on openSUSE

Step 1. Keeping your system up-to-date is a best practice for security and performance. Open your terminal and execute the following command to refresh your system’s package repository and upgrade all your installed packages to their latest versions:

sudo zypper refresh
sudo zypper update

Step 2. Installing Java.

Before proceeding with the installation, it is essential to ensure that your system meets the necessary prerequisites. Elasticsearch requires Java to be installed, as it is written in Java. Open a terminal and run the following command to check if Java is installed:

java -version

If Java is not installed, you can install OpenJDK (Open Java Development Kit) by running the following command:

sudo zypper install java-11-openjdk

Step 3. Installing Elasticsearch on openSUSE.

At the time of writing this guide, the latest stable version of Elasticsearch is 8.12. You can download the appropriate package for openSUSE from the official Elasticsearch website. Open a terminal and navigate to the directory where you want to download the package. Then, run the following command to download the Elasticsearch archive:

wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-8.12.2-linux-x86_64.tar.gz

Once the download is complete, you can proceed with the installation process. First, extract the downloaded archive using the following command:

tar -xvf elasticsearch-8.12.2-linux-x86_64.tar.gz

Next, change the ownership and permissions of the extracted directory to ensure proper access and execution:

sudo chown -R elasticsearch:elasticsearch /path/to/elasticsearch-8.12.2
sudo chmod -R 755 /path/to/elasticsearch-8.12.2

The Elasticsearch directory structure contains several important files and folders:

  • bin/: This directory contains executable scripts for starting and managing Elasticsearch.
  • config/: This directory contains configuration files, such as elasticsearch.yml and jvm.options.
  • data/: This directory is used to store the Elasticsearch data.
  • logs/: This directory contains the Elasticsearch log files.

Step 4. Configuring Elasticsearch.

Before starting Elasticsearch, you need to configure it according to your requirements. Open the elasticsearch.yml file located in the config/ directory using a text editor:

sudo nano /path/to/elasticsearch-8.6.2/config/elasticsearch.yml

In the elasticsearch.yml file, you can modify various settings, such as the cluster name, node name, and data directory path. Here are some recommended settings:

cluster.name: your-cluster-name
node.name: your-node-name
path.data: /path/to/data/directory

Replace your-cluster-name and your-node-name with your desired cluster and node names, respectively. Additionally, you can specify the path to the data directory by modifying the path.data setting.

If you plan to store a large amount of data, you may need to increase the heap size allocated to Elasticsearch. You can modify the heap size by editing the jvm.options file located in the config/ directory:

sudo nano /path/to/elasticsearch-8.12.2/config/jvm.options

Find the lines that set the minimum and maximum heap size, and adjust them according to your system’s available memory. For example:

-Xms4g
-Xmx4g

This configuration sets the minimum and maximum heap size to 4 GB.

Step 5. Starting Elasticsearch.

Once you have completed the configuration, you can start Elasticsearch as a service. Open a terminal and navigate to the bin/ directory within the Elasticsearch installation directory:

cd /path/to/elasticsearch-8.12.2/bin

Then, run the following command to start Elasticsearch:

sudo ./elasticsearch

You should see Elasticsearch startup logs in the terminal, indicating that the service is starting up. You can also check the status of the Elasticsearch service by running the following command:

sudo systemctl status elasticsearch

If Elasticsearch started successfully, you should see an output similar to the following:

● elasticsearch.service - Elasticsearch
   Loaded: loaded (/usr/lib/systemd/system/elasticsearch.service; disabled; vendor preset: disabled)
   Active: active (running) since Mon 2024-12-14 10:15:32 UTC; 5s ago
     Docs: http://www.elastic.co
 Main PID: 12345 (java)
    Tasks: 30
   Memory: 1.3G
   CGroup: /system.slice/elasticsearch.service
           └─12345 /path/to/jdk/bin/java -Xms4g -Xmx4g -XX:+UseConcMarkSweepGC -XX:CMSInitiatingOccupancyFraction=75 -Des.networkaddress.cache.ttl=60 ...

Step 6. Testing Elasticsearch.

After a successful installation and startup, you can test if Elasticsearch is running correctly by sending requests to its RESTful API. One way to test Elasticsearch is by using a tool like cURL or a web browser. To check the cluster health, run the following command:

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

This command sends a request to the _cluster/health endpoint and includes the pretty parameter to format the JSON response for better readability. If Elasticsearch is running correctly, you should see a response similar to the following:

{
  "cluster_name" : "your-cluster-name",
  "status" : "green",
  "timed_out" : false,
  "number_of_nodes" : 1,
  "number_of_data_nodes" : 1,
  "active_primary_shards" : 0,
  "active_shards" : 0,
  "relocating_shards" : 0,
  "initializing_shards" : 0,
  "unassigned_shards" : 0,
  "delayed_unassigned_shards" : 0,
  "number_of_pending_tasks" : 0,
  "number_of_in_flight_fetch" : 0,
  "task_max_waiting_in_queue_millis" : 0,
  "active_shards_percent_as_number" : 100.0
}

You can also retrieve information about the Elasticsearch nodes by sending a request to the _nodes endpoint:

curl http://localhost:9200/_nodes?pretty

Additionally, you can test the search functionality by creating a sample index and indexing some data. First, create a new index named test-index:

curl -X PUT http://localhost:9200/test-index?pretty

Then, index a sample document:

curl -X POST http://localhost:9200/test-index/_doc?pretty -H 'Content-Type: application/json' -d '
{
  "name": "meilana maria",
  "age": 26,
  "city": "New York"
}'

Finally, you can search for the indexed document by running the following command:

curl -X GET http://localhost:9200/test-index/_search?pretty -H 'Content-Type: application/json' -d '
{
  "query": {
    "match_all": {}
  }
}'

This command will return the indexed document in the search results.

Congratulations! You have successfully installed Elasticsearch. Thanks for using this tutorial for installing Elasticsearch on your openSUSE system. For additional or useful information, we recommend you check the official Elasticsearch website.

VPS Manage Service Offer
If you don’t have time to do all of this stuff, or if this is not your area of expertise, we offer a service to do “VPS Manage Service Offer”, starting from $10 (Paypal payment). Please contact us to get the best deal!

r00t

r00t is a seasoned Linux system administrator with a wealth of experience in the field. Known for his contributions to idroot.us, r00t has authored numerous tutorials and guides, helping users navigate the complexities of Linux systems. His expertise spans across various Linux distributions, including Ubuntu, CentOS, and Debian. r00t's work is characterized by his ability to simplify complex concepts, making Linux more accessible to users of all skill levels. His dedication to the Linux community and his commitment to sharing knowledge makes him a respected figure in the field.
Back to top button