ElasticSearch Cookbook
上QQ阅读APP看书,第一时间看更新

Installing a plugin

One of the main features of ElasticSearch is the possibility to extend it with plugins. Plugins extend ElasticSearch features and functionalities in several ways. There are two kinds of plugins:

  • Site plugins: These are used to serve static contents in their entry points. They are mainly used to create management application: monitoring and administration of a cluster.
  • Binary plugins: These are jar files that contain application code. They are used for:
    • Rivers (plugins that allow importing data from DBMS or other sources)
    • ScriptEngine (JavaScript, Python, Scala, and Ruby)
    • Custom analyzers and tokenizers
    • REST entry points
    • Supporting new protocols (Thrift, memcache, and so on)
    • Supporting new storages (Hadoop)

Getting ready

You need an installed working ElasticSearch server.

How to do it...

ElasticSearch provides a script for automatically downloading and installing plugins in bin/directory, called plugin.

The steps required to install a plugin are:

  1. Call the plugin install the ElasticSearch command with the plugin name reference.

    For installing an administrative interface for Elasticsearch, simply call:

    • on Linux/Mac:
      plugin -install mobz/elasticsearch-head
      
    • on Windows:
      plugin.bat -install mobz/elasticsearch-head
      
  2. Check by starting the node that the plugin is correctly loaded.

    The following screenshot shows the installation and the initialization of ElasticSearch server with the installed plugin.

    How to do it...

Note

Remember that a plugin installation requires to restart the ElasticSearch server.

How it works...

The plugin[.bat] script is a wrapper for ElasticSearch Plugin Manager. It can be used to install or remove a plugin with the –remove options.

To install a plugin, there are two kinds of options:

  • Pass the URL of the plugin (zip archive) with the -url parameter, that is, bin/plugin –url http://mywoderfulserve.com/plugins/awesome-plugin.zip
  • Use the –install parameter with the Github repository of the plugin.

    The install parameter, that must be given, is formatted in this way:

    <username>/<repo>[/<version>]

In the previous example:

  • <username> was mobz
  • <repo> was elasticsearch-head
  • <version> was not given so master/trunk was used

During the install process, ElasticSearch Plugin Manager is able to:

  • Download the plugin
  • Create a plugins directory in ES_HOME if it's missing
  • Unzip the plugin content in the plugin directory
  • Remove temporary files

There's more...

There are some hints to remember while installing plugins. The first and most important is that the plugin must be certified for your current ElasticSearch version: some releases can break your plugins. Typically on the plugin developer page, there are the ElasticSearch versions supported by this plugin.

For example, if you look at the Python language plugin page (https://github.com/elasticsearch/elasticsearch-lang-python), you'll see a reference table similar to the following table:

---------------------------------------
| Python Plugin    | ElasticSearch    |
--------------------------------------- 
| master           | 0.90 -> master   |
--------------------------------------- 
| 1.2.0            | 0.90 -> master   |
--------------------------------------- 
| 1.1.0            | 0.19 -> 0.20     | 
--------------------------------------- 
| 1.0.0            | 0.18             | 
---------------------------------------

You must choose the version working with your current ElasticSearch version.

Updating some plugins in a node environment can cause malfunction due to different plugin versions in different nodes. If you have a big cluster for safety, it's better to check the update in a separate environment to prevent problems.

Note that updating an ElasticSearch server could also break your custom binary plugins due to some internal API changes.

See also