Installing plugins in ElasticSearch
One of the main features of ElasticSearch is the possibility to extend it with plugins. Plugins extend ElasticSearch features and functionality in several ways. There are two kinds of plugins:
- Site plugins: These are used to serve static content at their entry points. They are mainly used to create a management application for the monitoring and administration of a cluster. The most common site plugins are:
- ElasticSearch head (http://mobz.github.io/elasticsearch-head/)
- Elastic HQ (http://www.elastichq.org/)
- Bigdesk (http://bigdesk.org)
- Native plugins: These are the
.jar
files that contain the application code. They are used for:- Rivers (plugins that allow you to import data from DBMS or other sources)
- Scripting Language Engines (JavaScript, Python, Scala, and Ruby)
- Custom analyzers, tokenizers, and scoring
- REST entry points
- Supporting new protocols (Thrift, memcache, and so on)
- Supporting new storages (Hadoop)
Getting ready
You need a working ElasticSearch server installed.
How to do it...
ElasticSearch provides a script to automatically download and install plugins in the bin/
directory called plugin
.
The following steps are required to install a plugin:
- Call the plugin and install it using the ElasticSearch command with the plugin name reference. To install an administrative interface for ElasticSearch, simply type the following command:
- Linux / MacOSX:
plugin -install mobz/elasticsearch-head
- Windows:
plugin.bat -install mobz/elasticsearch-head
- Linux / MacOSX:
- Start the node and check whether the plugin is correctly loaded.
The following screenshot shows the installation and the beginning of the ElasticSearch server with the installed plugin:
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
option.
To install a plugin, there are two methods:
- Passing the URL of the plugin (the
.zip
archive) with the-url
parameter:bin/plugin –url http://mywoderfulserve.com/plugins/awesome-plugin.zip
- Using the
–install
parameter with the GitHub repository of the plugin
The install parameter, which must be provided, is formatted in this way:
<username>/<repo>[/<version>]
In the previous example the parameter settings were:
<username>
parameter asmobz
<repo>
parameter aselasticsearch-head
<version>
was not given, so the master/trunk was used
During the installation process, ElasticSearch Plugin Manager is able to do the following activities:
- Download the plugin
- Create a
plugins
directory inES_HOME
if it's missing - Unzip the plugin's content in the plugin directory
- Remove temporary files
The installation process is completely automatic, and no further actions are required. The user must only pay attention to the fact that the process ends with an Installed
message to be sure that the install process is completed correctly.
A server restart is always required to ensure that the plugin is correctly loaded by ElasticSearch.
There's more...
If your current ElasticSearch application depends on one or more plugins, a node can be configured to fire up only if these plugins are installed and available. To achieve this behavior, you can provide the plugin.mandatory
directive in the elasticsearch.yml
configuration file.
In the previous example (elasticsearch-head
), this configuration line needs to be added:
plugin.mandatory: head
There are some points that you need to remember when installing plugins. The first and most important point is that the plugin must be certified for your current ElasticSearch version: some releases can break your plugins. Typically, the ElasticSearch versions supported by the plugin will be listed on the plugin developer page.
For example, if you take a look at the Python language plugin page (https://github.com/elasticsearch/elasticsearch-lang-python), you'll see a reference table similar to that shown in the following screenshot:
You must choose the version that works with your current ElasticSearch version.
Updating some plugins in a node environment can bring about malfunctions due to different plugin versions at different nodes. If you have a big cluster, for safety, it's better to check updates in a separate environment to prevent problems.
See also
- On the ElasticSearch website, there is an updated list of the available plugins (http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/modules-plugins.html#_plugins)
- The Installing a plugin manually recipe in this chapter to manually install a plugin