Installing Elasticsearch on Debian

Table of Contents

Prerequisites

For this installation, you will need a machine with Debian installed. Here’s how to prepare a virtual machine on Azure.

You might also need basic knowledge of using a Linux Terminal, as the whole installation is done without a graphical interface.

Installation

1. Installing Elasticsearch and Kibana

  1. Access your Linux terminal.
  2. Add the Elastic public signing key by running*:

sudo wget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo gpg --dearmor -o /usr/share/keyrings/elasticsearch-keyring.gpg

*You might see an error message that says “gnupg is not found.” If this message appears, install GnuPG by running this command:

sudo apt-get install gnupg
  1. Run:
sudo apt-get install apt-transport-https
  1. Save the elastic repository with:
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
  1. Update your package information with:
sudo apt-get update
  1. Install Elasticsearch by running:
sudo apt-get install elasticsearch.

While installing Elasticsearch, you might see something like this:

  1. Save the password for the elastic built-in superuser. You’ll need it later.
  2. To install Kibana, run the following command:
sudo apt-get install kibana
  1. Run:
systemctl daemon-reload
  1. Enable Elasticsearch and Kibana by running:
systemctl enable elasticsearch.service

     and:

systemctl enable kibana.service

2. Checking if Elasticsearch is running

  1. Start Elasticsearch by running:
sudo systemctl start elasticsearch.service
  1. To access Elastic, go to: https://YOURMACHINEIP:9200,
    where YOURMACHINEIP is the IP address of your machine.

If you can’t access the site, make sure the 9200 port is open to the public on Azure. On some Linux distributions, like Red Hat, you might also need to open the port inside the VM.

3. Connecting Elasticsearch 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 Elasticsearch. In the future, it might be used to visualize data inside KanBo.

There are two ways to connect the Elasticsearch service with the Kibana Service:

  1. To generate an enrollment token for Kibana, run these commands:
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. Select 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 then select Verify.


4. Creating a user for KanBo

  1. Open Kibana and log in with the username “elastic” and the password for the Elastic build-in superuser from 1. Installing Elasticsearch and Kibana
  1. When the window appears, select Explore on my own.
  2. In the search bar at the top, search for Security/Roles.
  3. Select Go to.
  1. Select Create role.
  1. Then configure these options the same way they are shown in the screenshot.
  • Cluster privileges: manage , manage_security
  • Run As privileges: *
  • Indices: kanbosearch.*
  • Privileges: all

  1. After creating a role, search for “Users”, and then select Go to.
  1. Here’s how to create a user:

It is good practice to have the same username as the role name. You set your own password; it is not generated automatically.

  1. For the Roles section, select the role created in the step before: “admin-KanBoSearch”.
  2. Save the username and password so that you can use them later.
  3. Kibana is not needed for now. Stop it by running:
sudo systemctl stop kibana.service

5. Connecting KanBo with Elasticsearch

  1. Open your KanBo’s appsettings.json file and add this code to the “Plugins” section:
{
    "type": "elastic",
    "tenant": "kanbosearch",
	"connection": {
		"url": "https://ELASTIC-URL:9200",
		"login": "admin-KanBoSearch",
		"password": "USER-PASSWORD"
	}
   }
  1. Replace the ELASTIC-URL with the address of your Elasticsearch machine.
  2. Change USER-PASSWORD to the password you’ve created for the Admin-KanBoSearch user.
  3. Make sure to leave https:// and :9200 in the URL of your machine.
  4. After pasting the code, save the changes.
  5. To use the KanBo app with the new configuration, you’ll need to restart the app.
  6. Go to KanBo Setup > Show advanced setup > Elastic.

If the Elastic tab doesn’t appear, restart KanBo and try again.

  1. To index all your data, in the Data import section, select All, check the Clean box, and select Execute.
  2. Wait until Elastic indexes everything.

To test the KanBo Search, go to KanBo, create a space, and a card inside of it. Then, go to KanBo Search, and search for the name of the card. 

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 Elasticsearch service is not hosted on the same machine as KanBo, make sure that this URL is accessible from the KanBo machine.

Checking if the user is configured properly in Kibana

  1. Start Kibana, go to the Kibana URL and log in.
  2. Go to Roles, and select 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 select the user you created.
  3. Make sure that the correct role is assigned to this user.

  1. If you are unsure about the password, you can reset it by selecting Change password.

Opening ports inside of the machine

The 9200 port might be blocked by the firewall inside the VM. If you have a VM hosted on Azure, the port might also not be enabled in the VM’s networking settings. 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 Elasticsearch hosted on a Hyper-V virtual machine

If you’ve decided to host your Elasticsearch virtual machine on Hyper-V, you’ll need to reroute traffic from the host machine’s port to the VM’s port. To do that:

  1. Open Routing and Remote Access.
  2. Double-click on Ethernet.
  1. Go to Services and Ports, and then select Add.
  1. Fill in the fields below:
  • Add a description (e.g., “ElasticSearch”).
  • Keep On this interface and TCP protocol selected.
  • In the Incoming port, type “9200”.
  • In the Private address, enter the IP address of your VM.
  • In the Outgoing port, enter 9200 (the port that Elasticsearch is using).
  1. Select OK.
  2. Select Apply.

Now you should be able to connect to Elasticsearch, which is hosted on your Hyper-V virtual machine.

Was this article helpful?

Please, contact us if you have any additional questions.