Installing and running Elasticsearch in 5 different ways

Elasticsearch is a great and popular open source search engine which can be installed on many various ways.

I've prepared 5 ways how to install and run Elasticsearch with pros and cons.

I hope this can be useful for beginners and even also for more experienced developers.

1. DigitalOcean + Docker

Pros:

  • Extremely easy way to run Elasticsearch.
  • It just requires a few very simple steps to make it working.
  • Resizing (CPU and RAM) and creating snapshots is very convenient
  • Relatively easy to migrate your docker to another host
  • Creating many Elasticsearch instances on one host with docker is effortless

Cons:

  • I don’t see many cons.
  • You need to have knowledge about servers and take care about maintaining and making backups on your own.

Installation:

ssh root@your-new-ip-address
# disable firewall and allow to open 9200 port
ufw disable
docker run -p 9200:9200 elasticsearch:1.7.6
# open http://your-new-ip-address:9200 to test it out

2. AWS Elasticsearch

Choosing domain and version for Elasticsearch in AWS

Configuring Elasticsearch cluster in Amazon Web Services

Pros

  • Scalable. You can choose how many instances you want and their size
  • Secure. You can control access to API by AWS Identity or Access Management (IAM) policies
  • Easy to run

Cons

  • Only 1.5 and 2.3 versions available of Elasticsearch
  • It is quite expensive. The smallest instance of 1 GB ram and 1 vCPU costs $0.018 per Hour so it is 13$ per Month

3. Elasticsearch with Ansible

- name: Elasticsearch with custom configuration
  hosts: localhost
  roles:
    #expand to all available parameters
    - { role: elasticsearch, es_instance_name: "node1", es_data_dirs: "/opt/elasticsearch/data", es_log_dir: "/opt/elasticsearch/logs", es_work_dir: "/opt/elasticsearch/temp", 
    es_config: {
        node.name: "node1", 
        cluster.name: "custom-cluster",
        discovery.zen.ping.unicast.hosts: "localhost:9301",
        http.port: 9201,
        transport.tcp.port: 9301,
        node.data: false,
        node.master: true,
        bootstrap.mlockall: true,
        discovery.zen.ping.multicast.enabled: false } 
    }
  vars:
    es_scripts: false
    es_templates: false
    es_version_lock: false
    es_heap_size: 1g

Pros

  • It’s very very flexible, configurable and fully automated.
  • Ansible has very low learning curve in comparison to Chef or Puppet in terms of provisioninig

Cons

  • Requires knowledge about Ansible and managing linux system
  • Requires making maintenance and backups on your own

Installation

  • Make sure Ansible is installed in your localhost i.e. by ansible --version
  • run ansible-playbook your-own-playbook.yml

More information there: https://github.com/elastic/ansible-elasticsearch

4. QBox Hosted Elasticsearch

Pros

  • It is very scalable and huge. You can have up to 512 GB Ram and 46 vCPU’s
  • 4 regions available (USA, Europe, Australia and Asia)
  • 24h/7 support and help for every customer
  • automatic backups

Cons

  • It is expensive. The instance of 1 GB ram and 1 vCPU costs $0.05/hr ($40.00/mo). This is 2.5x more expensive than AWS (on the smallest instance)

5. Manual installation on Ubuntu 14.04

Installation Elasticsearch 1.7.2 on Ubuntu

#!/bin/sh

sudo add-apt-repository -y ppa:webupd8team/java
sudo apt-get update
sudo apt-get -y install oracle-java8-installer
wget https://download.elastic.co/elasticsearch/elasticsearch/elasticsearch-1.7.2.deb
sudo dpkg -i elasticsearch-1.7.2.deb
sudo service elasticsearch start

Pros

  • it can be faster than with using docker

Cons

  • Different installation commands on each linux distros.
  • Testing installation
  • Usually it is enough to open it in the browser i.e. http://localhost:9200 or make a request in CLI curl -XGET http://localhost:9200

Typical response:

Thank your for reading the whole article! Feel free to share it to social media if you find it useful