Complete Elasticsearch Setup Configuration Guide

Author

Reads 470

Computer server in data center room
Credit: pexels.com, Computer server in data center room

Setting up Elasticsearch requires careful configuration to ensure optimal performance and scalability.

You'll need to decide on the number of nodes in your cluster, with a minimum of one node for a single-node cluster.

Choose a node type, either master-eligible or data node, depending on your cluster's needs.

A good starting point is to have at least three nodes in your cluster, with one master node and two data nodes.

This allows for redundancy and improved performance.

Setup and Installation

To use Elasticsearch on the Akana API Platform, you'll need to install and configure it properly. You can start by downloading Elasticsearch and installing it on the server or servers you'll be using.

To determine the correct version to install, see the Elasticsearch version page. For example, versions 8.5.3 and 7.14.2 are available for download from the official Elasticsearch website.

You should not run Elasticsearch open to the public, and it's also a good idea to avoid running it as the root user. Here's a quick rundown of the key considerations:

  • Don't run Elasticsearch open to the public.
  • Don't run Elasticsearch as root.

Once you've installed Elasticsearch, you can run it by navigating to the bin directory within the Elasticsearch installation folder. From there, you can run the `elasticsearch` command (or `elasticsearch.bat` on Windows) to start Elasticsearch with the default settings.

By default, Elasticsearch runs on port 9200. You can verify that Elasticsearch is running by entering the address in your web browser or by sending a GET request to `localhost:9200` using a tool like curl in a new terminal window.

Configuration

Credit: youtube.com, Install and Configure Elasticsearch in Windows

To configure Elasticsearch for optimal performance, it's essential to consider your use case and adjust settings accordingly. The heap size should be set to a maximum of 50% of your available RAM, but not more than ~30GB.

You can enable bootstrap checks, which are a set of checks that Elasticsearch performs at startup to prevent common configuration errors. These checks are always enabled, but a production cluster will refuse to start if any of the bootstrap check fails.

To configure the number of shards and replicas, aim for a shard size of between 10GB and 50GB and set the number of replicas based on your availability requirements. This can have a significant impact on the performance of your cluster.

Here are some key settings to consider when configuring Elasticsearch:

  • Cluster name: needed for REST Client
  • Node name: needed for REST Client, if you want to name your own node
  • Path to directory where to store the data
  • Optional: Set the bind address to a specific IP
  • Pass an initial list of hostnames for all the nodes in the cluster
  • Increase the default configuration value for the maximum number of Boolean clauses allowed within a search string

Configure

To configure Elasticsearch, you need to consider the specific requirements of your use case. However, here are some general recommendations to get you started.

Computer server in data center room
Credit: pexels.com, Computer server in data center room

Set the heap size appropriately, aiming for a maximum of 50% of your available RAM, but not more than ~30GB. This ensures there's enough memory left for the operating system and file system cache.

Configure the number of shards and replicas based on your availability requirements. A general rule of thumb is to aim for a shard size of between 10GB and 50GB.

To customize Elasticsearch's behavior, you can modify its configuration file, `elasticsearch.yml`, located in the config directory of the Elasticsearch installation. This is where you can set parameters like the cluster name, node name, and network host.

You can also configure the number of nodes and shards in the Akana Administration Console, under the com.akana.elasticsearch configuration category. The default configuration includes two shards and one replica, with each node storing approximately half the index.

If you're using Elasticsearch on Amazon Web Services (AWS) with the AWS NLB load balancer, you'll need to update the keepalive settings on any servers running Akana containers with Elasticsearch. This involves configuring the TCP keepalive settings, such as `net.ipv4.tcp_keepalive_time`, `net.ipv4.tcp_keepalive_intvl`, and `net.ipv4.tcp_keepalive_probes`.

Here are the key settings you'll need to configure in the `elasticsearch.yml` file:

  • Cluster name (`cluster.name`): defines the name of your cluster
  • Node name (`node.name`): defines the name of the node
  • Network host (`network.host`): defines the network interface(s) a node should bind to

Document Field Terms

Engineer fixing core swith in data center room
Credit: pexels.com, Engineer fixing core swith in data center room

You may need to change the size parameter to get more or less indexed terms. This can be a useful adjustment to make, especially when working with large datasets.

To view indexed terms, you'll need to adjust the size parameter accordingly.

Activate Traces

To activate traces, open the lib/log4j2.xml file and uncomment the ELASTIC section. This will enable the elastic.log file to contain all requests made by the Nuxeo Platform to Elasticsearch.

You can then use the elastic.log file to copy and paste the curl commands for debugging. I've found this to be a huge help when troubleshooting issues with indexing.

The elastic.log file includes the curl commands, making it easy to analyze the requests at the Lucene index level using a tool like Luke.

Aliases and Reindexing (Zero Downtime)

Nuxeo can manage two indexes at the same time to avoid service interruption during reindexing. This is achieved by leveraging Elastic Aliases.

To use this feature, you need to configure Nuxeo to manage Elastic aliases by setting elasticsearch.manageAlias.enabled=true in your nuxeo.conf. If you're switching an existing instance to use manage aliases, it will require a service interruption.

Credit: youtube.com, Understanding Elasticsearch Reindexing Behavior Amidst Ongoing Data Writes

Nuxeo manages two aliases: one for searching and one for writing, both pointing to the same index. The index name ends with a number and is automatically incremented when reindexing.

Here's a step-by-step guide to set up aliases and reindex without service interruption:

  1. Nuxeo must be configured to manage Elastic aliases.
  2. Perform a full reindexing using the Bulk Service.
  3. On completion, delete the old unused index.

YAML and Files

Elasticsearch uses three main configuration files: `elasticsearch.yml`, `jvm.options`, and `log4j2.properties`. These files are crucial for setting up and customizing your Elasticsearch installation.

The `elasticsearch.yml` file is the most important configuration file, as it contains settings for the Elasticsearch node and cluster, such as node name, cluster name, and network settings.

You can find the `elasticsearch.yml` file in the `{elasticsearch_home}/config` folder, where it might have some default placeholder content.

The file needs to be updated with specific settings, including cluster name, node name, path to directory where to store the data, and network host.

Here are the key settings to update:

  • Cluster name: needed for REST Client. For example: `cluster.name: akana`
  • Node name: needed for REST Client, if you want to name your own node. For example: `node.name: node-1`
  • Path to directory where to store the data. For example: `path.data: /path/to/data`
  • Optional if you don't want to bind to all interfaces: Set the bind address to a specific IP. For example: `network.host: 192.168.0.1`
  • Pass an initial list of hostnames for all the nodes in the cluster, to provide a seed list of other nodes in the cluster that are likely to be live and contactable, as part of discovery. For example: `discovery.zen.ping.unicast.hosts: ["localhost", "[::1]"]`

After updating the `elasticsearch.yml` file, you'll need to restart Elasticsearch for the changes to take effect.

Configure Advanced Rest Client

Detailed view of server racks with glowing lights in a data center environment.
Credit: pexels.com, Detailed view of server racks with glowing lights in a data center environment.

Configuring the Advanced REST Client is a crucial step in securing communication between Nuxeo and Elasticsearch. You can do this by installing Elasticsearch X-Pack, which supports the Rest Client since Nuxeo 9.10-HF01.

To enable TLS/SSL configuration, you'll need to set up Nuxeo using nuxeo.conf with specific properties. This involves referencing the Trust Store and Key Store Configuration page for more information.

If you've chosen to configure TLS/SSL, Nuxeo will manage 3 Elasticsearch indexes. This is the case when Elasticsearch is enabled and the audit.elasticsearch.enabled property is set to true in nuxeo.conf, which is the default setting.

Expand your knowledge: Fortigate Ssl Vpn Configuration

Understanding Files

Elasticsearch uses three main configuration files: `elasticsearch.yml`, `jvm.options`, and `log4j2.properties`. These files are crucial in customizing Elasticsearch's behavior.

The `elasticsearch.yml` file contains settings for the Elasticsearch node and cluster, such as node name, cluster name, and network settings. It's typically stored in the `{elasticsearch_home}/config` folder.

To change the cluster name, you'll need to add a line like `cluster.name: akana` to the `elasticsearch.yml` file. This is necessary for the REST Client to work properly.

For more insights, see: Elasticsearch Index Settings

Credit: youtube.com, Are Debug Techniques Applicable to YAML and Configuration Files? - Learn To Troubleshoot

The `jvm.options` file contains settings for the JVM, including initial and maximum heap size. This is important for optimizing Elasticsearch's performance.

Here are the main configuration files and their purposes:

  • `elasticsearch.yml`: Node and cluster settings
  • `jvm.options`: JVM settings
  • `log4j2.properties`: Logging settings

The `log4j2.properties` file controls the logging level and appender. This is essential for monitoring and troubleshooting Elasticsearch.

If you want to change the port that Elasticsearch runs on, you can add the following line to `elasticsearch.yml`: `http.port: 9201`. After making changes, you'll need to restart Elasticsearch for the changes to take effect.

Database Content Comparison

When comparing database content with Elasticsearch, you can use the esync tool. This read-only tool requires access to both the database and Elasticsearch.

The esync tool is a standalone tool that helps pinpoint discrepancies between content. It's a powerful tool that can make a big difference in keeping your data in sync.

To use the esync tool, you'll need to configure the Elasticsearch mapping. This is crucial for accurate comparisons. The tool requires both access to the database and Elasticsearch, using the transport client on port 9300.

Here's a quick rundown of what's involved:

  • Configuring the Elasticsearch mapping is essential for accurate comparisons.
  • Elasticsearch indexing logic is where the magic happens.
  • Making a page provider or content view query Elasticsearch index is a key part of the process.

Performance and Tuning

Credit: youtube.com, Elasticsearch performance tuning (2 Solutions!!)

Performance and Tuning is crucial for an Elasticsearch setup. To optimize performance, set the heap size to a maximum of 50% of your available RAM, but not more than ~30GB, to ensure enough memory for the operating system and file system cache.

Elasticsearch performs bootstrap checks at startup to prevent common configuration errors. These checks are always enabled, and a production cluster will refuse to start if any fail, while a development cluster will log the failures as warnings.

The number of shards and replicas can significantly impact performance. Aim for a shard size between 10GB and 50GB, and set the number of replicas based on your availability requirements.

To prevent indexing errors, consider disabling OS swapping or using an Elasticsearch option to prevent the heap from being swapped.

You can increase the JVM heap to half of the available OS memory by editing the /etc/default/elasticsearch file.

Here are some recommended JVM heap sizes:

Increasing the bulk queue size can also help prevent indexing errors. This can be done by editing the /etc/elasticsearch/elasticsearch.yml configuration file.

To reduce disk IO, you can change the default translog durability from "request" to "async". This can be done by adding the following line to your nuxeo.conf file:

System and Requirements

Credit: youtube.com, Installing and Configuring Elasticsearch and Kibana 8.x

To set up Elasticsearch, you'll need to check the system requirements for the standalone server, which can be found in the platform system requirements document corresponding to your Elasticsearch version.

For the latest information about supported Elasticsearch versions, refer to the System Requirements doc, Elasticsearch section.

The version of Elasticsearch you choose will determine the specific system requirements you need to meet, so be sure to check the latest information before proceeding with your setup.

A different take: Openwrt Build System Setup

System Requirements

To get started with Elasticsearch, you'll need to check the system requirements, which can be found in the platform's system requirements document for the correct version of the platform.

The document lists the specific requirements for each version of Elasticsearch, so be sure to check the version you're using.

For a standalone Elasticsearch server, you'll need to refer to the correct version of the platform system requirements document.

This ensures you have the necessary resources to run the server smoothly and efficiently.

You can find the system requirements document for your version of Elasticsearch by following the link provided in the version's documentation.

Explore further: Elasticsearch Document

Supported Versions

A modern data center featuring a computer setup with monitor and keyboard, emphasizing technology infrastructure.
Credit: pexels.com, A modern data center featuring a computer setup with monitor and keyboard, emphasizing technology infrastructure.

The Nuxeo Platform communicates with Elasticsearch using the HTTP Rest protocol (port 9200 by default), which provides looser coupling with Elasticsearch.

For the latest information about supported Elasticsearch versions, refer to the System Requirements doc, Elasticsearch section. You can also check the Nuxeo Platform's documentation for specific version requirements.

To give you a better idea of the supported versions, here's a breakdown of the supported Elasticsearch versions for different Nuxeo Platform versions:

In production, you'll need to set up an Elasticsearch cluster, which requires more configuration and setup. Refer to the Elasticsearch documentation to install and secure your cluster.

Local Setup

To set up Elasticsearch locally, you'll need to download and install it on your machine.

First, you'll need to have Java installed on your machine. The recommended version for Elasticsearch 8 is Java 17, but newer versions are also compatible.

You can download Elasticsearch directly from the official Elastic website.

Extract the files to your desired location after downloading.

For your interest: Elasticsearch Client Java

Optimization and Testing

Credit: youtube.com, Install and Configure a Secure Elastic Stack

To configure Elasticsearch for optimal performance, set the heap size to a maximum of 50% of your available RAM, but not more than 30GB. This will ensure enough memory is left for the operating system and file system cache.

You should also enable bootstrap checks, which are a set of checks that prevent common configuration errors. A production cluster will refuse to start if any of the bootstrap checks fail.

To optimize Elasticsearch, consider increasing the memory allocation by setting the `ES_JAVA_OPTS` environment variable. For example, to allocate 2GB of memory, you can run a command before starting Elasticsearch.

The number of shards and replicas can have a significant impact on performance, so aim for a shard size of between 10GB and 50GB and set the number of replicas based on your availability requirements.

Here's a summary of key optimization considerations:

  • Heap size: up to 50% of available RAM, max 30GB
  • Bootstrap checks: always enabled
  • Memory allocation: increase with `ES_JAVA_OPTS` environment variable
  • Shard size: 10GB to 50GB
  • Replicas: based on availability requirements

Repository and Audit

In Elasticsearch, the repository is where your data is stored. It's a crucial part of the setup configuration.

Elasticsearch supports multiple repository types, including File System, AWS S3, and Azure Blob Storage.

To ensure data integrity, Elasticsearch provides a built-in auditing feature that allows you to track changes made to your data.

Updating Repository

A complex network of cables in a data center with a monitor in the foreground.
Credit: pexels.com, A complex network of cables in a data center with a monitor in the foreground.

Updating a repository is an essential task to ensure your data remains accurate and up-to-date. You can re-index the repository using the Bulk Service, which returns a command ID that you can use to track the status of the re-indexing.

To update the repository index configuration, you can override the default mapping by creating a custom template with a nuxeo.defaults file that contains the custom mapping. This file should be placed in the ${NUXEO_HOME}/templates/myapp/nxserver/config directory.

The custom mapping file should be named elasticsearch-doc-mapping.json and should contain the custom mapping settings. You can also create a file named elasticsearch-doc-settings.json to override the settings. It's essential to duplicate the original file and modify the copy to avoid conflicts with the default mapping.

To apply the new settings and mapping, you need to restart and re-index the entire repository. This process can be time-consuming, especially for large repositories. To speed up the process, you can fine-tune the WorkManager indexing process by adjusting the indexing worker thread pool size, documents per worker, and documents submitted using the Elasticsearch bulk API.

Engineer fixing core swith in data center room
Credit: pexels.com, Engineer fixing core swith in data center room

Here are some key options to consider:

  • Sizing the indexing worker thread pool: elasticsearch.indexing.maxThreads=4
  • Tuning the number of documents per worker: elasticsearch.reindex.bucketReadSize=500
  • Tuning the number of documents submitted using the Elasticsearch bulk API: elasticsearch.reindex.bucketWriteSize=50

By following these steps and adjusting these options, you can optimize the repository update process and ensure your data remains accurate and up-to-date.

Updating Audit Logs

Updating the audit logs index configuration is a bit more involved, but it's a crucial step in maintaining the health of your Nuxeo Platform.

You'll need to update the mappings or settings configuration by overriding the {NUXEO_HOME}/templates/common-base/nxserver/config/elasticsearch-audit-index-config.xml file.

To do this, use a new name for the audit.elasticsearch.indexName, like nuxeo-audit2.

Once you've made the changes, start the Nuxeo Platform, and the new index will be created with the new mapping.

After that, stop the Nuxeo Platform and copy the audit logs entries in the new index using the _reindex endpoint.

Here's an example of how to do that using curl:

```html

  1. curl -X POST http://localhost:9200/_reindex -H 'Content-Type: application/json'

"source": {

"index": "nuxeo-audit"

},

"dest": {

"index": "nuxeo-audit2"

}

}'

```

Disabling Audit Logs

Disabling Audit Logs can improve scalability, especially when using Nuxeo Drive with a large set of users.

To achieve this, you should read the Backing Up and Restoring the Audit Elasticsearch Index page for more information.

Disabling Elasticsearch and using the SQL database as the default backend for audit logs is possible by updating this property in nuxeo.conf.

Multi Repositories

Networking cables plugged into a patch panel, showcasing data center connectivity.
Credit: pexels.com, Networking cables plugged into a patch panel, showcasing data center connectivity.

To set up a system that can handle multiple repositories, you need to define an index for each repository.

You'll need to create a custom template to change the mapping of the index. This is done by adding an elasticSearchIndex contribution.

For each repository, you'll need to add a second elasticSearchIndex contribution. The name of the contribution should match the Elasticsearch index name, and the repository name should match the actual repository name.

Here's a summary of the steps:

The elasticSearchIndex contribution should include the name of the Elasticsearch index and the repository name.

Rest Client and Names

The REST Client is a mode that communicates with the Elasticsearch server or cluster by accessing a URL, introduced in a recent version of Elasticsearch.

To configure the REST Client in the Akana Administration Console, you'll need to follow a few steps. Choose Configure Elasticsearch Global Configuration on the Tasks tab, under All, and then select REST Client as the Deployment Mode.

Credit: youtube.com, How to Install Elasticsearch & Kibana Locally: Step-by-Step Setup | Spring Data Elasticsearch

The Elastic HTTP URLs field requires you to provide full URLs for each container where Community Manager is running, separated by commas. For example, if you have multiple URLs, they must all use the same protocol, such as HTTP or HTTPS.

If you're configuring the REST Client in a Nuxeo setup, you'll need to choose the RestClient protocol and provide a comma-separated list of URLs in the elasticsearch.addressList field.

Rest Client

The Rest Client is a great way to communicate with Elasticsearch servers or clusters. It's supported since Nuxeo 9.3 and allows you to access a URL to connect to the Elasticsearch server or cluster.

In Nuxeo, you can choose the Rest Client protocol by setting elasticsearch.client to RestClient. This is the default protocol, so you don't need to do anything extra unless you want to change it.

To configure the Rest Client, you need to provide a comma-separated list of URLs in the Elastic HTTP URLs field. These URLs should be full URLs and should have the same protocol (HTTP or HTTPS) for all containers.

Smiling woman in data center showcasing technology expertise.
Credit: pexels.com, Smiling woman in data center showcasing technology expertise.

Here are the steps to configure the Rest Client in Nuxeo:

You can also configure the Rest Client using nuxeo.conf file. You need to set the following properties:

  • elasticsearch.client to RestClient
  • elasticsearch.addressList to a comma-separated list of URLs

Note that if you have installed Elasticsearch X-Pack, you can secure communication between Nuxeo and Elasticsearch using the Rest Client. This is supported since Nuxeo 9.10-HF01.

Names

In the world of Rest Client and Names, understanding the different types of indexes is crucial. The repository index is used to index document content and can be rebuilt from scratch.

You can rebuild it by extracting content from the repository, which is a useful feature to know about. This index is used to store document content, and it's essential for searching and retrieving data.

The audit logs index is a primary storage for audit entries and can't be rebuilt. This means that once the data is stored, it's there to stay. This index is critical for tracking changes and updates to the system.

Various tangled wires connected to system near black metal cases in server room
Credit: pexels.com, Various tangled wires connected to system near black metal cases in server room

Here are some key index names to keep in mind:

  • elasticsearch.indexName: the name of the Elasticsearch index for the default document repository
  • audit.elasticsearch.indexName: the name of the Elasticsearch index for audit logs
  • seqgen.elasticsearch.indexName: the name of the Elasticsearch index for the uid sequencer, extensively used for audit logs

The sequence index is used to serve unique values that can be used as primary keys and is also a primary storage. This index is essential for ensuring data integrity and uniqueness.

Calvin Connelly

Senior Writer

Calvin Connelly is a seasoned writer with a passion for crafting engaging content on a wide range of topics. With a keen eye for detail and a knack for storytelling, Calvin has established himself as a versatile and reliable voice in the world of writing. In addition to his general writing expertise, Calvin has developed a particular interest in covering important and timely subjects that impact society.

Love What You Read? Stay Updated!

Join our community for insights, tips, and more.