Run ElasticSearch and Kibana in Vagrant box

      No Comments on Run ElasticSearch and Kibana in Vagrant box

 

Goal

The goal of this blog is to describe steps to reach following state.

  • I want to run CentOS7 box in Vagrant using VirtualBox Vagrant provider.
  • I want to run ElasticSearch in the CentOS7 box on port 9200.
  • I want tu run Kibana in the CentOS7 box on port 5601.
  • I want Kibana to display data from ElasticSearch.
  • I want ElasticSearch to be accessible through port 9201 on our localhost.
  • I want Kibana to be accessible through port 5602 on our localhost.

Set up Vagrant

Get official CentOS 7 box if you yet don’t have it.

Run the box.

Now Vagrantfile was created in our current directory. We need to edit to configure following.

  • Setup port forwarding from port 5601(in box) to 5602 (localhost of host machine).
  • Setup port forwarding from 9201 to 9200.
  • Setup amount of memory available for the box to 4GB (the default amount for VirtualBox is not enough to run ES/Kibana).

Uncomment and setup following options in your Vagrantfile.

You can also use provider other than VirtualBox, then you should however check how to setup memory for it because the memory setup above might not work.

Let’s boot it up!

Install ElasticSearch and Kibana

Now we need to install java, setup YUM repository for elasticsearch, start the service and then check whether it is up and running. You can simly use following script.

Similarly, for Kibana you can use following script

Configure ElasticSearch and Kibana

The ElasticSearch configuration is located at /etc/elasticsearch/elasticsearch.yml
The minimal change required to configuration is to set following value

By default the value is 127.0.0.1, which however prevents to access from outside the machine. Learn here why is that.

Kibana confiruation file is similarly located at /etc/kibana/kibana.yml and the values you have to modify are

After modifying configuration, you need to restart elasticsearch and kibana service.

You can wait few seconds and make sure they are truly still up and running.

If some of the services failed, you can investigate why that happend by running

Otherwise, if everything is fine, you can navigate to http://localhost:5602 in your browser – your Kibana should be there.
However, Kibana will first of all ask you for index pattern. To get going quickly, you can post some sample data to ES, which will also by default create index and mapping.

Now you can setup your first index pattern in Kibana catalog* and you should be able to discover the '{ "hello": "world" }' document.

 

Leave a Reply

Your email address will not be published. Required fields are marked *