Reader small image

You're reading from  Elasticsearch 7.0 Cookbook. - Fourth Edition

Product typeBook
Published inApr 2019
Reading LevelBeginner
PublisherPackt
ISBN-139781789956504
Edition4th Edition
Languages
Right arrow
Author (1)
Alberto Paro
Alberto Paro
author image
Alberto Paro

Alberto Paro is an engineer, manager, and software developer. He currently works as technology architecture delivery associate director of the Accenture Cloud First data and AI team in Italy. He loves to study emerging solutions and applications, mainly related to cloud and big data processing, NoSQL, Natural language processing (NLP), software development, and machine learning. In 2000, he graduated in computer science engineering from Politecnico di Milano. Then, he worked with many companies, mainly using Scala/Java and Python on knowledge management solutions and advanced data mining products, using state-of-the-art big data software. A lot of his time is spent teaching how to effectively use big data solutions, NoSQL data stores, and related technologies.
Read more about Alberto Paro

Right arrow

Setting up a node via Docker

Docker ( https://www.docker.com/ ) has become a common way to deploy application servers for testing or production.

Docker is a container system that makes it possible to easily deploy replicable installations of server applications. With Docker, you don't need to set up a host, configure it, download the Elasticsearch server, unzip it, or start the server—everything is done automatically by Docker.

Getting ready

How to do it…

  1. If you want to start a vanilla server, just execute the following command:
docker pull docker.elastic.co/elasticsearch/elasticsearch:7.0.0
  1. An output similar to the following will be shown:
7.0.0: Pulling from elasticsearch/elasticsearch
256b176beaff: Already exists
1af8ca1bb9f4: Pull complete
f910411dc8e2: Pull complete
0c0400545052: Pull complete
6e4d2771ff41: Pull complete
a14f19907b79: Pull complete
ea299a414bdf: Pull complete
a644b305c472: Pull complete
Digest: sha256:3da16b2f3b1d4e151c44f1a54f4f29d8be64884a64504b24ebcbdb4e14c80aa1
Status: Downloaded newer image for docker.elastic.co/elasticsearch/elasticsearch:7.0.0
  1. After downloading the Elasticsearch image, we can start a develop instance that can be accessed outside from Docker:
docker run -p 9200:9200 -p 9300:9300 -e "http.host=0.0.0.0" -e "transport.host=0.0.0.0" docker.elastic.co/elasticsearch/elasticsearch:7.0.0

You'll see the output of the ElasticSearch server starting.

  1. In another window/Terminal, to check if the Elasticsearch server is running, execute the following command:
docker ps

The output will be similar to the following:

CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
b99b252732af docker.elastic.co/elasticsearch/elasticsearch:7.0.0 "/usr/local/bin/dock…" 2 minutes ago Up 2 minutes 0.0.0.0:9200->9200/tcp, 0.0.0.0:9300->9300/tcp gracious_bassi
  1. The default exported ports are 9200 and 9300.

How it works…

The Docker container provides a Debian Linux installation with Elasticsearch installed.

Elasticsearch Docker installation is easily repeatable and does not require a lot of editing and configuration.

The default installation can be tuned into in several ways, for example:

  1. You can pass a parameter to Elasticsearch via the command line using the -e flag, as follows:
docker run -d docker.elastic.co/elasticsearch/elasticsearch:7.0.0 elasticsearch -e "node.name=NodeName"
  1. You can customize the default settings of the environment that's providing custom Elasticsearch configuration by providing a volume mount point at /usr/share/elasticsearch/configas follows:
docker run -d -v "$PWD/config":/usr/share/elasticsearch/config docker.elastic.co/elasticsearch/elasticsearch:7.0.0
  1. You can persist the data between Docker reboots configuring a local data mount point to store index data. The path to be used as a mount point is /usr/share/elasticsearch/configas follows:
docker run -d -v "$PWD/esdata":/usr/share/elasticsearch/data docker.elastic.co/elasticsearch/elasticsearch:7.0.0

There's more…

The official Elasticsearch images are not only provided by Docker. There are also several customized images for custom purposes. Some of these are optimized for large cluster deployments or more complex Elasticsearch cluster topologies than the standard ones.

Docker is very handy for testing several versions of Elasticsearch in a clean way, without installing too much stuff on the host machine.

In the code repository directory ch01/docker/, there is a docker-compose.yaml file that provides a full environment that will set up the following elements:

  • elasticsearch, which will be available at http://localhost:9200
  • kibana, which will be available at http://localhost:5601
  • cerebro, which will be available at http://localhost:9000

To install all the applications, you can simply execute docker-compose up -d. All the required binaries will be downloaded and installed in Docker, and they will then be ready to be used.

See also

Previous PageNext Page
You have been reading a chapter from
Elasticsearch 7.0 Cookbook. - Fourth Edition
Published in: Apr 2019Publisher: PacktISBN-13: 9781789956504
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
undefined
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime

Author (1)

author image
Alberto Paro

Alberto Paro is an engineer, manager, and software developer. He currently works as technology architecture delivery associate director of the Accenture Cloud First data and AI team in Italy. He loves to study emerging solutions and applications, mainly related to cloud and big data processing, NoSQL, Natural language processing (NLP), software development, and machine learning. In 2000, he graduated in computer science engineering from Politecnico di Milano. Then, he worked with many companies, mainly using Scala/Java and Python on knowledge management solutions and advanced data mining products, using state-of-the-art big data software. A lot of his time is spent teaching how to effectively use big data solutions, NoSQL data stores, and related technologies.
Read more about Alberto Paro