Installing and Configuring Elastic Search on Debian

Table of Contents

Prerequisites

For this installation You will need a machine with Debian installed. You
can read on how to prepare a virtual machine on Azure here.

Basic knowledge of using a Linux Terminal might also be needed, as the
whole installation is done without a graphical interface.

Installation

1. Installing Elastic Search and Kibana

  1. Access Your Linux terminal.
  2. Add the Elastic public signing key by running:
  3. sudo wget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo gpg --dearmor -o /usr/share/keyrings/elasticsearch-keyring.gpg
You might encounter an error message that says that “gnupg is not found”. If this message appears, install gnupg by running this command: sudo apt-get install gnupg
  1. Run:
  2. sudo apt-get install apt-transport-https.
  3. Save the elastic repository with:
  4. echo "deb [signed-by=/usr/share/keyrings/elasticsearch-keyring.gpg] <a href="https://artifacts.elastic.co/packages/8.x/apt"> https://artifacts.elastic.co/packages/8.x/apt</a> stable main" | sudo tee /etc/apt/sources.list.d/elastic-8.x.list.
  5. Update Your package information with:
  6. sudo apt-get update.
  7. Install Elastic Search by running:
  8. sudo apt-get install elasticsearch.

During the installation of elasticsearch, something like this should pop up:

  1. Save the password for the elastic built-in superuser. It will be needed later.
  2. Install kibana by running:
sudo apt-get install kibana .
  1. Run:
  2. systemctl daemon-reload.
  3. Enable Elastic Search and Kibana by running:
  4. systemctl enable elasticsearch.service and: systemctl enable kibana.service.

2. Checking if Elastic Search is running

  1. Start Elastic Search by running:
  2. sudo systemctl start elasticsearch.service.
  3. Check if you can access elastic by going to: https://YOURMACHINEIP:9200, with YOURMACHINEIP being the ip address of Your machine. If You can not access the site, make sure You have the 9200 port open to the public on Azure (in some Linux distributions like Red Hat opening the port inside of the VM might also be needed).

3. Connecting Elastic Search with Kibana

Kibana is the visual front-end for the Elastic Stack applications. For now, we will need Kibana to set up and configure a user that will be used as a connector between the KanBo and Elastic Search, but in the future, it might get used for visualizations of data inside KanBo. There are two ways to connect the Elastic Search service with the Kibana Service:

  1. To generate an enrollment token for kibana run:
  2. sudo./usr/share/elasticsearch/bin/elasticsearch-create-enrollment-token -s kibana.

  1. Go to YOURMACHINEIP:5601 (without https).
  2. Paste the enrollment token inside the window.
  3. Click “Configure Elastic”.

  1. After that this window will appear:

  1. Run: sudo ./usr/share/kibana/bin/kibana-verification-code.

A code will be generated:

  1. Type this code and click “Verify”.


4. Creating a user for KanBo

  1. Make sure You have this line in Your KanBo web.config:
  2. <elastic key=”55a42c0f7fc8e9444ba6e22370d8339c”/>. The key here is the encryption key and is a random String of min. 30 characters. This key will not be used anywhere in the configuration and is used to encrypt the communication between KanBo and elastic as additional layer of security.
  3. Save Your web.config.
  4. Open Kibana and login with the username “elastic” and use the password of the Elastic build-in superuser from “Installing Elastic Search and Kibana”.

  1. When this window appears, click “Explore on my own”.
  2. In the search bar at the top of the site, search for “Roles” and select it by “Go to”.

  1. After that, click on “Create role”.

  1. In the search bar at the top of the site, search for “Roles” and select it by “Go to".

  1. Then configure these options the same way they are configured in the screenshot.
    • Cluster privileges: manage , manage_security
    • Run As privileges: *
    • Indices: kanbosearch.*
    • Privileges: all
  2. After creating a role, search for “Users” in the top bar and select “Go to".

  1. And create a user in this fashion:

It is good practice to have the same username as the role name. The password is not generated and is set by you.

  1. For the “roles” section, select the role created in the step before: “admin-KanBoSearch”.
  2. Save the username and password somewhere for later.
  3. Stop Kibana by running:
  4. sudo systemctl stop kibana.service, as it is not needed for now.

5. Connecting KanBo with Elastic Search

  1. Go to KanBo Setup (https://yourkanbo.com/setup), show advanced setup and click on Elastic.

  1. If the ”Elastic” option does not appear, restart the KanBo and try again.
    • The input for the boxes in the “connection” section should be:
      Url: https://YOURMACHINEIP:9200.
      Replace YOURMACHINEIP with the ip address of Your Elastic Search VM. The 9200 port is the port that Elastic search runs on.
    • User: The Username from “Creating a user for KanBo”, step 8
    • Password: The password from “Creating a user for KanBo”, step 8
    • Tenant name: kanbosearch

  1. Click on register and Your KanBo will be connected to the Elastic Search service.
  2. Index all your data by choosing “All”, in the “Data import” section, ticking the “clean” box and clicking on “Execute”.

Wait until Elastic indexed everything.

  1. Restart Your KanBo using IIS (stop / Start KanBo Pool).
  2. Your KanBo now uses Elastic Search!


Troubleshooting

Failed registering elastic connection: Elastic ping failed.

This error appears whenever any of the input in the “connection” section are incorrect, (not just the URL), or if KanBo cannot connect to the specified IP. Please, make sure that:

  1. The url starts with https://, the machine ip is correct and is followed by “:9200” at the end.
  2. The Username and Password are correct.
  3. The tenant name doesn’t include the “.*” part that was present inside the Indices of a role we have created in Kibana
  4. In case the Elastic Search service is not hosted on the same machine as KanBo, make sure that this URL is accessible from the KanBo machine.

Check if the user is configured properly in Kibana

  1. Start Kibana, go to the Kibana URL and log in.
  2. Go to roles and click on the role you created.

  1. Make sure that the Cluster privileges, Run As privileges, Indices and Privileges are configured accordingly to the previous steps. Also make sure that indices end with “.*”.
  2. Go to Users and click on the user you created.
  3. Make sure that the correct role is assigned to this user.
  4. If You are unsure about the password, you can reset it by clicking “change password”.


Open ports inside of the Machine

It is possible that the 9200 port is blocked by the firewall inside of the VM (and if You have a VM hosted on Azure, the port might also have not been enabled inside of the VM’s Networking setting, please refer to the article about preparing the VM on Azure) . To open the port on a Debian VM, run sudo iptables -I INPUT 1 -p tcp --dport 9200 -j ACCEPT


Connecting to Elastic Search hosted on a Hyper-V Virtual Machine

If You decided to host Your Elastic Search virtual machine on Hyper-V, Your host machine needs to reroute traffic to the machine’s port to a VM’s port. To do that:

  1. Open Routing and Remote Access.
  2. Double click on “Ethernet”.

  1. Head to “Services and Ports” and click “Add”.

  1. Add a description (for example “ElasticSearch”), keep “On this interface” and “TCP” protocol selected. In incoming port, type “9200”. In private address type in the IP address of Your VM, and in outgoing port type in 9200 (the port that Elastic Search is using) and click OK.

  1. After that is done, click “Apply” and now You should be able to connect to Elastic Search hosted on Your Hyper-V virtual machine.

Was this article helpful?

Please, contact us if you have any additional questions.