How to Install and Configure Elasticsearch on OpenSUSE Leap 15.3

In this guide, we will learn how to install and configure Elasticsearch on OpenSUSE Leap 15.3.

Elasticsearch is a distributed search and analytics engine built on Apache Lucene. It provides a distributed, multitenant-capable full-text search engine with an HTTP web interface and schema-free JSON documents. Elasticsearch has quickly become the most popular search engine and is commonly used for log analytics, full-text search, security intelligence, business analytics, and operational intelligence use cases.

Related Content

Prerequisites

To follow along, ensure that you have:

  • An updated OpenSUSE Leap 15.3 server with at least 2 GB of RAM and 2 cores
  • Root access to the server or user with sudo access
  • Access to the internet from the server

Ensuring that the server is up to date

Before proceeding, let us ensure that our server is up to date and all the packages are the latest version. Use these commands to achieve this:

1
2
sudo zypper refresh
sudo zypper update -y

If there are packages to upgrade, the above command may take a couple of minutes

Import the Elasticsearch GPG Key

Elasticsearch signs all of packages with the Elasticsearch Signing Key (PGP key D88E42B4, available from https://pgp.mit.edu) with fingerprint:

1
4609 5ACC 8548 582C 1A26 99A9 D27D 666C D88E 42B4

Download and install the public signing key:

1
sudo rpm --import https://artifacts.elastic.co/GPG-KEY-elasticsearch

Install Elasticsearch from the RPM repository

Create a file called elasticsearch.repo in the /etc/zypp/repos.d/. Use your text editor to open the file:

1
sudo vim /etc/zypp/repos.d/elasticsearch.repo

Then add the following the content:

1
2
3
4
5
6
7
8
[elasticsearch]
name=Elasticsearch repository for 7.x packages
baseurl=https://artifacts.elastic.co/packages/7.x/yum
gpgcheck=1
gpgkey=https://artifacts.elastic.co/GPG-KEY-elasticsearch
enabled=0
autorefresh=1
type=rpm-md

And your repository is ready for use. You can now install Elasticsearch.

Use this command to install elasticsearch

1
2
3
sudo zypper modifyrepo --enable elasticsearch && \
  sudo zypper install elasticsearch; \
  sudo zypper modifyrepo --disable elasticsearch

Confirm the installation:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
~> rpm -qi elasticsearch
Name        : elasticsearch
Epoch       : 0
Version     : 7.16.3
Release     : 1
Architecture: x86_64
Install Date: Sat Jan 15 07:04:44 2022
Group       : Application/Internet
Size        : 517226057
License     : Elastic License
Signature   : RSA/SHA512, Fri Jan  7 02:57:25 2022, Key ID d27d666cd88e42b4
Source RPM  : elasticsearch-7.16.3-1-src.rpm
Build Date  : Thu Jan  6 23:49:11 2022
Build Host  : packer-virtualbox-iso-1636998457
Relocations : /usr
Packager    : Elasticsearch
Vendor      : Elasticsearch
URL         : https://www.elastic.co/
Summary     : Distributed RESTful search engine built for the cloud
Description :
Reference documentation can be found at
  https://www.elastic.co/guide/en/elasticsearch/reference/current/index.html
  and the 'Elasticsearch: The Definitive Guide' book can be found at
  https://www.elastic.co/guide/en/elasticsearch/guide/current/index.html
Distribution: Elasticsearch

Start and enable the Elasticsearch service

The Elasticsearch service won’t be started by default. Use this command to start:

1
sudo systemctl start elasticsearch

Confirm the service status using this command:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
~> sudo systemctl status elasticsearch

● elasticsearch.service - Elasticsearch
     Loaded: loaded (/usr/lib/systemd/system/elasticsearch.service; disabled; vendor preset: disabled)
     Active: active (running) since Sat 2022-01-15 07:05:29 UTC; 31s ago
       Docs: https://www.elastic.co
   Main PID: 9636 (java)
      Tasks: 72 (limit: 4587)
     CGroup: /system.slice/elasticsearch.service
             ├─9636 /usr/share/elasticsearch/jdk/bin/java -Xshare:auto -Des.networkaddress.cache.ttl=60 -Des.networkaddress.cache.negative.ttl=10 -XX:+AlwaysPreTouch -Xss1m -Djava.awt.headless=true ->
             └─9848 /usr/share/elasticsearch/modules/x-pack-ml/platform/linux-x86_64/bin/controller

Jan 15 07:05:06 dev-susesrv.inv.re systemd[1]: Starting Elasticsearch...
Jan 15 07:05:29 dev-susesrv.inv.re systemd[1]: Started Elasticsearch.

The above output shows that the service is up and running. Enable the service using this command:

1
sudo systemctl enable elasticsearch

If Elasticsearch fails to start for any reason, it will print the reason for failure to STDOUT. Log files can be found in /var/log/elasticsearch/.

By default the Elasticsearch service doesn’t log information in the systemd journal. To enable journalctl logging, the --quiet option must be removed from the ExecStart command line in the elasticsearch.service file.

When systemd logging is enabled, the logging information are available using the journalctl commands:

To tail the journal:

1
sudo journalctl -f

To list journal entries for the elasticsearch service:

1
sudo journalctl --unit elasticsearch

To list journal entries for the elasticsearch service starting from a given time:

1
sudo journalctl --unit elasticsearch --since  "2016-10-30 18:17:16"

Verify Elasticsearch Installation

At this point, ElasticSearch is started and listening on port 9200. You can check it with the following command:

1
ss -antpl | grep 9200

You should see the following output:

1
2
3
4
5
6
7
8
~> ss -antpl | grep 9200
LISTEN   0        128        [::ffff:127.0.0.1]:9200                   *:*
LISTEN   0        128                     [::1]:9200                [::]:*</pre>

you can also verify ElasticSearch with the following command.

```sh
curl -X GET "localhost:9200/"

output:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
~> curl -X GET "localhost:9200/"

{
  "name" : "dev-susesrv.citizix.com",
  "cluster_name" : "elasticsearch",
  "cluster_uuid" : "RBGWTT44SxqoAybSDQqL6A",
  "version" : {
    "number" : "7.16.3",
    "build_flavor" : "default",
    "build_type" : "rpm",
    "build_hash" : "4e6e4eab2297e949ec994e688dad46290d018022",
    "build_date" : "2022-01-06T23:43:02.825887787Z",
    "build_snapshot" : false,
    "lucene_version" : "8.10.1",
    "minimum_wire_compatibility_version" : "6.8.0",
    "minimum_index_compatibility_version" : "6.0.0-beta1"
  },
  "tagline" : "You Know, for Search"
}

Performing simple operations with Elasticsearch

You can use the Curl command to add data to the ElasticSearch as shown below:

1
curl -H 'Content-Type: application/json' -X POST 'http://localhost:9200/todo/task/1' -d '{ "name": "Go to the mall." }'

You should see the following output:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
{
  "_index": "todo",
  "_type": "task",
  "_id": "1",
  "_version": 1,
  "result": "created",
  "_shards": { "total": 2, "successful": 1, "failed": 0 },
  "_seq_no": 0,
  "_primary_term": 1
}

You can now retrieve your data using the GET request:

1
curl -X GET 'http://localhost:9200/todo/task/1'

You should see the following output:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
{
  "_index": "todo",
  "_type": "task",
  "_id": "1",
  "_version": 1,
  "_seq_no": 0,
  "_primary_term": 1,
  "found": true,
  "_source": { "name": "Go to the mall." }
}

To retrieve the data in human-readable format, run the following command:

1
curl -X GET 'http://localhost:9200/todo/task/1?pretty'

You should get the following output:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
{
  "_index": "todo",
  "_type": "task",
  "_id": "1",
  "_version": 1,
  "_seq_no": 0,
  "_primary_term": 1,
  "found": true,
  "_source": {
    "name": "Go to the mall."
  }
}

Conclusion

That’s it. In this guide, you we learned how to install and use ElasticSearch on OpenSUSE Leap 15.3 server. You can now easily add, read, delete, and update data in Elasticsearch.

comments powered by Disqus
Citizix Ltd
Built with Hugo
Theme Stack designed by Jimmy