Installing and configuring Elastic Search on Debian
Last modified:
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:
Installing Elastic Search 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 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
3. Run sudo apt-get install apt-transport-https
then 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
4. Update Your package information with sudo apt-get update
5. Install Elastic Search by running sudo apt-get install elasticsearch
During the installation of elasticsearch, something like this should pop up:
Save the password for the elastic built-in superuser. It will be needed later.
After that, install kibana by running sudo apt-get install kibana
6. Run systemctl daemon-reload
and then enable Elastic Search and
Kibana by running systemctl enable elasticsearch.service
and systemctl enable kibana.service
Checking if Elastic Search is running
1. Start Elastic Search by running sudo systemctl start elasticsearch.service
2. 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).
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 an user that will be used as a connector between the KanBo application and Elastic Search, but in the future it might get used for visualisations of data inside KanBo. There are two ways to connect Elastic Search service with the Kibana Service:
1. Run
sudo
./usr/share/elasticsearch/bin/elasticsearch-create-enrollment-token -s
kibana
to generate an enrollment token for kibana
2. Go to YOURMACHINEIP:5601 (without https)
3. Paste the enrollment token inside the window and press “Configure Elastic”
4. After that this window will appear
Run sudo ./usr/share/kibana/bin/kibana-verification-code.
A code
will be generated
Type this code and press “Verify”
Creating a user for KanBo
1.
Make sure You have this line in Your KanBo web.config: <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.
2. Save Your web.config
3. Open Kibana and login with the username “elastic” and use the password of the Elastic build-in superuser from “Installing Elastic Search and Kibana”, step 5.
4.
When this window appears, press “Explore on my own”
After that, click on “Create role”
- Cluster privileges: manage , manage_security
- Run As privileges: *
- Indices: kanbosearch.*
- Privileges: all
8.After creating a role, search for “Users” in the top bar and select “Go to
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. For the “roles” section, select the role created in the step before: “admin-KanBoSearch”
From here, save the username and password somewhere for later.
9. Stop Kibana by running sudo systemctl stop kibana.service
, as
it is not needed for now.
Connecting KanBo with Elastic Search
1. Go to KanBo Setup (https://yourkanbo.com/setup), show advanced setup and
click on Elastic.
If the ”Elastic” option does not appear, restart the KanBo App and try
again.
-
2. 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
3.
After that, click on register, and Your KanBo will be connected to the
Elastic Search service.
4. 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.
5. Restart Your KanBo application using IIS (stop / Start KanBo App Pool)
6. 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
3. 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 “.*”
4. Go to Users and click on the user You created
5. Make sure that the correct role is assigned to this user
6. 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”
3. Head to “Services and Ports” and press “Add”
4. 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 press OK.
5. After that is done, press “Apply” and now You should be able to connect to Elastic Search hosted on Your Hyper-V virtual machine.