Skip to content

How-to articles

Setup Elasticsearch In Premise

Starting version 7.5, BQ  has moved all its search and filter functionality to Elasticsearch. This guide explains how to install and setup Elasticsearch for in-premise customers.

Prerequisites

  1. Ubuntu 16.04, JDK 1.8

Step-by-step guide

Make sure JDK 1.8 is installed on the server before proceeding.

Step 1 - Download and Install Elasticsearch

Elasticsearch can be downloaded directly from elastic.co in ziptar.gzdeb, or rpm packages. For Ubuntu, it's best to use the deb (Debian) package which will install everything you need to run Elasticsearch.

First, update your package index.

``bash sudo apt-get update

``

Download  Elasticsearch version 2.1.2

``bash wget https://download.elastic.co/elasticsearch/release/org/elasticsearch/distribution/deb/elasticsearch/2.1.2/elasticsearch-2.1.2.deb

``

Then install it in the usual Ubuntu way with dpkg.

java sudo dpkg -i elasticsearch-2.1.2.deb

This results in Elasticsearch being installed in /usr/share/elasticsearch/ with its configuration files placed in /etc/elasticsearch and its init script added in /etc/init.d/elasticsearch.

To make sure Elasticsearch starts and stops automatically with the server, add its init script to the default runlevels.

java sudo systemctl enable elasticsearch.service

Step 2 - Configuring Elasticsearch

Now that Elasticsearch and its Java dependencies have been installed, it is time to configure Elasticsearch. The Elasticsearch configuration files are in the /etc/elasticsearch directory. There are two files:

  • elasticsearch.yml configures the Elasticsearch server settings. This is where all options, except those for logging, are stored, which is why we are mostly interested in this file.
  • logging.yml provides configuration for logging. In the beginning, you don't have to edit this file. You can leave all default logging options. You can find the resulting logs in /var/log/elasticsearch by default.

To start editing the main elasticsearch.yml configuration file with nano or your favorite text editor.

``java sudo nano /etc/elasticsearch/elasticsearch.yml

``

Update the following properties

  • cluster.name: bqurious-cluster
  • node.name: bqurious-node-1
  • network.host: 0.0.0.0

One final setting which you might be interested in changing is path.data, which determines the path where data is stored. The default path is /var/lib/elasticsearch. In a production environment, it's recommended that you use a dedicated partition and mount point for storing Elasticsearch data. In the best case, this dedicated partition will be a separate storage media which will provide better performance and data isolation. You can specify a different path.data path by specifying it like this:

path.data: /media/different_media

Once you make all the changes, save and exit the file. Now you can start Elasticsearch for the first time.

java sudo systemctl start elasticsearch

Give Elasticsearch a few to fully start before you try to use it. Otherwise, you may get errors about not being able to connect.

Step 3 - Testing Elasticsearch

By now, Elasticsearch should be running on port 9200. You can test it with curl, the command line client-side URL transfers tool and a simple GET request.

java curl -X GET 'http://localhost:9200'

You should see the following response:

java { "name" : "bqurious-node-1", "cluster_name" : "bqurious-cluster", "version" : { "number" : "2.1.2", "build_hash" : "63c285e4741baf609e963cb9d463ad1a47e1a179", "build_timestamp" : "2016-01-27T12:57:52Z", "build_snapshot" : false, "lucene_version" : "5.3.1" }, "tagline" : "You Know, for Search" }

If you see a response similar to the one above, Elasticsearch is working properly. If not, make sure that you have followed correctly the installation instructions and you have allowed some time for Elasticsearch to fully start.

Step 4 - Configure BQ App to use Elasticsearch

Add the following to your custom config file:

groovy elasticSearch.client.mode = 'transport' elasticSearch.cluster.name = 'bqurious-cluster' elasticSearch.client.hosts = [ [host: 'IP of ES Server', port: 9300] ]