Back to Mattermost

Elasticsearch server setup

docs/main/administration-guide/scale/elasticsearch-setup.mdx

11.10.04.8 KB
Original Source

import Inc0_common_configure_mattermost_for_enterprise_search from './common-configure-mattermost-for-enterprise-search.mdx';

<PlanAvailability slug="ent-plus" />

Elasticsearch allows you to search large volumes of data quickly, in near real-time, by creating and managing an index of post data. The indexing process can be managed from the System Console after setting up and connecting an Elasticsearch server. The post index is stored on the Elasticsearch server and updated constantly after new posts are made. In order to index existing posts, a bulk index of the entire post database must be generated.

Deploying Elasticsearch includes the following two steps: setting up Elasticsearch, and configuring Mattermost.

Set up Elasticsearch

We highly recommend that you set up Elasticsearch server on a dedicated machine separate from the Mattermost Server.

  1. Download and install the latest release of Elasticsearch v8, or Elasticsearch v7.17+. See the Elasticsearch documentation for installation details.
  2. Set up Elasticsearch with systemd by running the following commands:
sh
sudo /bin/systemctl daemon-reload
sudo /bin/systemctl enable elasticsearch.service
sudo systemctl start elasticsearch.service
  1. Confirm Elasticsearch is working on the server by running the following command:
sh
curl localhost:9200
  1. Get your network interface name by running the following command:
sh
ip addr
  1. Edit the Elasticsearch configuration file in vi by running the following command:
sh
vi /etc/elasticsearch/elasticsearch.yml
  1. In this file, replace the network.host value of _eth0_ with your network interface name, and save your changes.
  2. When using Elasticsearch v8, ensure you set action.destructive_requires_name to false in elasticsearch.yml to allow for wildcard operations to work.
  3. Restart Elasticsearch by running the following commands:
sh
sudo systemctl stop elasticsearch
sudo systemctl start elasticsearch
  1. Confirm the ports are listenings by running the following command:
sh
netstat -plnt

You should see the following ports, including the ones listening on ports 9200 and 9300. Confirm these are listening on your server's IP address.

  1. Create an Elasticsearch directory and give it the proper permissions.
  2. Install the icu-analyzer plugin to the /usr/share/elasticsearch/plugins directory by running the following command:
sh
sudo /usr/share/elasticsearch/bin/elasticsearch-plugin install analysis-icu

(Optional) CJK language analyzer plugins: To improve search for Korean, Japanese, or Chinese content, install one or more of the following language-specific analyzer plugins: analysis-nori (Korean), analysis-kuromoji (Japanese), and analysis-smartcn (Chinese).

sh
sudo /usr/share/elasticsearch/bin/elasticsearch-plugin install analysis-nori
sudo /usr/share/elasticsearch/bin/elasticsearch-plugin install analysis-kuromoji
sudo /usr/share/elasticsearch/bin/elasticsearch-plugin install analysis-smartcn

After installing the CJK plugins, restart Elasticsearch to load them:

sh
sudo systemctl restart elasticsearch

Then enable the EnableCJKAnalyzers configuration setting. See Enabling Chinese, Japanese, and Korean Search for additional CJK search configuration options.

<div class="important"> <div class="title">

Important

</div>

If you enable CJK analyzers on a server with existing indexed content, you must purge and rebuild the search index in System Console > Environment > Elasticsearch for the CJK analyzers to take effect on existing posts.

</div>
  1. Test the connection from Mattermost to Elasticsearch by running the following command:
sh
curl 172.31.80.220:9200

Configure Mattermost

Follow these steps to configure Mattermost to use your Elasticsearch server and to generate the post index:

  1. Go to System Console > Environment > Elasticsearch.
  2. Set Enable Elasticsearch Indexing to true to enable the other the settings on the page. Once the configuration is saved, new posts made to the database are automatically indexed on the Elasticsearch server.
  3. Ensure Backend type is set to elasticsearch.

<Inc0_common_configure_mattermost_for_enterprise_search /> :start-after: :nosearch: