Elasticsearch allows the customization of several parameters in an installation. In this recipe, we'll see the most used ones to define where to store our data and improve overall performance.
Setting up a node
Getting ready
As described in the downloading and installing Elasticsearch recipe, you need a working Elasticsearch installation and a simple text editor to change configuration files.
How to do it…
The steps required for setting up a simple node are as follows:
- Open the config/elasticsearch.yml file with an editor of your choice.
- Set up the directories that store your server data, as follows:
- For Linux or macOS X, add the following path entries (using /opt/data as the base path):
path.conf: /opt/data/es/conf
path.data: /opt/data/es/data1,/opt2/data/data2
path.work: /opt/data/work
path.logs: /opt/data/logs
path.plugins: /opt/data/plugins
- For Windows, add the following path entries (using c:\Elasticsearch as the base path):
path.conf: c:\Elasticsearch\conf
path.data: c:\Elasticsearch\data
path.work: c:\Elasticsearch\work
path.logs: c:\Elasticsearch\logs
path.plugins: c:\Elasticsearch\plugins
- Set up the parameters to control the standard index shard and replication at creation. These parameters are as follows:
index.number_of_shards: 1
index.number_of_replicas: 1
How it works…
The path.conf parameter defines the directory that contains your configurations, mainly elasticsearch.yml and logging.yml. The default is $ES_HOME/config, with ES_HOME to install the directory of your Elasticsearch server.
The path.data parameter is the most important one. This allows us to define one or more directories (in a different disk) where you can store your index data. When you define more than one directory, they are managed similarly to RAID 0 (their space is sum up), favoring locations with the most free space.
The path.work parameter is a location in which Elasticsearch stores temporary files.
The path.log parameter is where log files are put. These control how a log is managed in logging.yml.
The path.plugins parameter allows you to override the plugins path (the default is $ES_HOME/plugins). It's useful to put system-wide plugins in a shared path (usually using NFS) in case you want a single place where you store your plugins for all of the clusters.
The main parameters are used to control index and shards in index.number_of_shards, which controls the standard number of shards for a new created index, and index.number_of_replicas, which controls the initial number of replicas.
See also
Refer to the following points to learn more about topics related to this recipe:
- The Setting up for Linux systems recipe
- You can refer to the official Elasticsearch documentation at https://www.elastic.co/guide/en/elasticsearch/reference/master/setup.html.