Downloading and installing Elasticsearch

Elasticsearch has an active community and the release cycles are very fast.

Because Elasticsearch depends on many common Java libraries (Lucene, Guice, and Jackson are the most famous ones), the Elasticsearch community tries to keep them updated and fixes bugs that are discovered in them and in Elasticsearch core. The large user base is also source of new ideas and features for improving Elasticsearch use cases.

For these reasons, if it's possible, the best practice is to use the latest available release (usually the more stable one and the less bugs free).

Getting ready

A supported Elasticsearch operative system (Linux/MacOSX/Windows) with a Java JVM 1.8 (the Oracle one is the preferred http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html) or above installed. A web browser is required to download the Elasticsearch binary release. At least 1GB of free disk space is required to install Elasticsearch.

How to do it...

For downloading and installing an Elasticsearch server, we will perform the steps given as follows:

We download Elasticsearch from the Web. The latest version is always downloadable at the web address https://www.elastic.co/downloads/elasticsearch. The three versions that are available for different operative systems are as follows:

  • elasticsearch-{version-number}.zip is for both Linux/Mac OSX and Windows operative systems
  • elasticsearch-{version-number}.tar.gz is for Linux/Mac
  • elasticsearch-{version-number}.deb is for Debian-based Linux distributions (this also covers the Ubuntu family); it is installable with the Debian command dpkg -i elasticsearch-*.deb
  • elasticsearch-{version-number}.rpm is for RedHat-based Linux distributions (this also covers the Centos family). It is installable with the rpm -i elasticsearch-*.rpm command.

Tip

The preceding packages contain everything to start Elasticsearch. This book targets version 5.x or above, the latest and most stable version of Elasticsearch was 5.1.1. To check out whether it's latest or not, visit https://www.elastic.co/downloads/elasticsearch.

We extract the binary content. After downloading the correct release for your platform, the installation involves expanding the archive in a working directory.

Tip

Choose a working directory that is safe to charset problems and it has not a long path to prevent problems when Elasticsearch creates its directories to store index data.

For Windows platform, a good directory could be c:es, on Unix and MacOSX /opt/es.

To run Elasticsearch, you need a Java Virtual Machine 1.8 or above installed. For better performances, I suggest you to use the latest Sun/Oracle 1.8 version.

If you are a Mac OS X user and you have installed Homebrew (http://brew.sh/), the first and the second step are automatically managed by the command brew install elasticsearch.

We start Elasticsearch to check if everything is working. To start your Elasticsearch server, just install the directory and type for Linux and MacOsX:

 # bin/elasticsearch

Alternatively, you can type the following for Windows:

# binelasticserch.bat        

Your server should now start up as shown in the following screenshot:

How to do it...

How it works...

The Elasticsearch package generally contains three directories:

  • bin: This contains the script to start and manage Elasticsearch. The most important ones are and follows:
    • elasticsearch(.bat): This is the main script to start Elasticsearch
    • plugin(.bat): This is a script to manage plugins 
  • config: This contains the Elasticsearch configs. The most important ones are as follows:
    • elasticsearch.yml: This is the main config file for Elasticsearch
    • log4j2.properties: This is the logging config file 
  • lib: This contains all the libraries required to run Elasticsearch
  • modules: This contains the Elasticsearch default module extensions
  • plugins: This contains the installed plugins

There's more...

During Elasticsearch start up a lot of events happened:

  • A node name is chosen automatically (for example, Robert Kelly) if not provided in elasticsearch.yml. The name is randomly taken from an in-code embedded Elasticsearch text file (src/main/resources/config/names.txt).
  • A node name hash is generated for this node (for example, whqVp_4zQGCgMvJ1CXhcWQ).
  • If the modules are loaded, the default installed modules are:
    • aggs-matrix-stats: This acts as a good support for aggregation matrix stats
    • ingest-common: These include common functionalities for ingesting
    • lang-expression: This acts as a good support for Expression language
    • lang-groovy: This acts as a good support for Groovy language
    • lang-mustache: This acts as a good support for Mustacle language
    • lang-painless: This acts as a good support for Painless language
    • percolator: This acts as a good support for percolator capabilities
    • reindex: This acts as a good support for reindex action
  • If there are plugins, they are loaded.
  • Automatically, if not configured, Elasticsearch binds on all network addresses available, two ports:
    • Port 9300 is used for internal intranode communication
    • Port 9200 is used for HTTP rest API 
  • After starting, if indices are available, they are restored and ready to be used.

If these port numbers are already bound, Elasticsearch automatically increments the port number and tries to bind on them until a port is available (that is, 9201, 9202, and so on). This feature is very useful when you want to fire up several nodes on the same machine mainly for testing and developing.

There are more events that are fired during Elasticsearch start-up. We'll see them in detail in other recipes.

See also

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.117.74.231