docs/main/administration-guide/scale/opensearch-setup.mdx
import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem';
import Inc0_common_configure_mattermost_for_enterprise_search from './common-configure-mattermost-for-enterprise-search.mdx';
<PlanAvailability slug="ent-plus" />AWS OpenSearch Service 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 OpenSearch server. The post index is stored on the OpenSearch 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 AWS OpenSearch includes the following two steps: setting up AWS OpenSearch, and configuring Mattermost.
From Mattermost v9.11, beta support is available for AWS OpenSearch v1.x and v2.x. This document covers both on‑premises and AWS OpenSearch setup, including manual steps and Terraform examples.
We highly recommend that you set up an AWS OpenSearch server on a separate machine from the Mattermost server.
<Tabs> <TabItem value="on-premises-opensearch" label="On-Premises OpenSearch">shsudo apt update sudo apt install -y openjdk-11-jdk java -version
shwget https://artifacts.opensearch.org/releases/bundle/opensearch/2.9.0/opensearch-2.9.0-linux-x64.tar.gz tar -xzf opensearch-2.9.0-linux-x64.tar.gz sudo mv opensearch-2.9.0 /usr/share/opensearch
shsudo useradd --no-create-home --shell /bin/false opensearch sudo chown -R opensearch:opensearch /usr/share/opensearch
sh[Unit] Description=OpenSearch Wants=network-online.target After=network-online.target [Service] Type=notify User=opensearch Group=opensearch ExecStart=/usr/share/opensearch/bin/opensearch Restart=on-failure LimitNOFILE=65536 LimitNPROC=4096 [Install] WantedBy=multi-user.target
opensearch.yml to include the following:yaml<div class="note"> <div class="title">cluster.name: mattermost-cluster node.name: node-1 path.data: /var/lib/opensearch path.logs: /var/log/opensearch network.host: 0.0.0.0 discovery.seed_hosts: ["<other-node-ip>"] cluster.initial_master_nodes: ["node-1", "node-2"]Note
</div>Ensure
path.dataandpath.logsdirectories exist and are owned by theopensearchuser before starting the service:sh</div>sudo mkdir -p /var/lib/opensearch /var/log/opensearch sudo chown -R opensearch:opensearch /var/lib/opensearch /var/log/opensearch
shsudo systemctl daemon-reload sudo systemctl enable opensearch sudo systemctl start opensearch sudo systemctl status opensearch
/usr/share/opensearch/plugins directory by running the following command:shsudo /usr/share/opensearch/bin/opensearch-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).
shsudo /usr/share/opensearch/bin/opensearch-plugin install analysis-nori sudo /usr/share/opensearch/bin/opensearch-plugin install analysis-kuromoji sudo /usr/share/opensearch/bin/opensearch-plugin install analysis-smartcn
After installing the CJK plugins, restart OpenSearch to load them:
shsudo systemctl restart opensearch
Then enable the EnableCJKAnalyzers configuration setting. See Enabling Chinese, Japanese, and Korean Search for additional CJK search configuration options.
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.
provider "docker" {
host = "unix:///var/run/docker.sock"
}
resource "docker_image" "opensearch" {
name = "opensearchproject/opensearch:2.9.0"
}
resource "docker_container" "opensearch" {
name = "opensearch"
image = docker_image.opensearch.latest
ports {
internal = 9200
external = 9200
}
ports {
internal = 9600
external = 9600
}
env = [
"cluster.name=mattermost-cluster",
"network.host=0.0.0.0",
"discovery.type=single-node", # remove for multi-node
]
restart = "unless-stopped"
}
resource "null_resource" "install_icu_plugin" {
depends_on = [docker_container.opensearch]
provisioner "local-exec" {
command = "docker exec opensearch /usr/share/opensearch/bin/opensearch-plugin install analysis-icu && docker restart opensearch"
}
}
- Domain name:
mattermost-os- Engine version:
OpenSearch 2.x.
- instance type:
r6g.xlarge.search- data nodes: 2
- master nodes: 2
- storage: EBS gp3 (1536 GiB, 4608 IOPS, 250 MiB/s)
443.Port 9200 is commonly used for local or on-premise OpenSearch. The AWS OpenSearch domain only supports HTTPS over port 443.
</Note>sh{ "Version": "2012-10-17", "Statement": [{ "Effect": "Allow", "Principal": { "AWS": "arn:aws:iam::123456789012:role/MattermostAppRole" }, "Action": "es:*", "Resource": "arn:aws:es:us-east-1:123456789012:domain/mattermost-os/*" }] }
sh{ "action.destructive_requires_name": "false", "rest.action.multi.allow_explicit_index": "true", "indices.query.bool.max_clause_count": "1024", "indices.fielddata.cache.size": "20" }
shcurl https://mattermost-os-xxxxxxxxxxx.us-east-1.es.amazonaws.com
</TabItem> </Tabs>shprovider "aws" { region = "us-east-1" } resource "aws_iam_role" "os_service_role" { name = "OSServiceRole" assume_role_policy = <<EOF { "Version": "2012-10-17", "Statement": [{ "Action": "sts:AssumeRole", "Effect": "Allow", "Principal": { "Service": "es.amazonaws.com" } }] } EOF } resource "aws_opensearch_domain" "mattermost" { domain_name = "mattermost-os" engine_version = "OpenSearch_2.9" cluster_config { instance_type = "r6g.xlarge.search" instance_count = 2 dedicated_master_enabled = true dedicated_master_type = "r6g.xlarge.search" dedicated_master_count = 2 zone_awareness_enabled = true } ebs_options { ebs_enabled = true volume_type = "gp3" volume_size = 1536 iops = 4608 } vpc_options { subnet_ids = ["subnet-blah1", "subnet-blah2"] security_group_ids = ["sg-1234567890"] } advanced_options = { "rest.action.multi.allow_explicit_index" = "true" "indices.query.bool.max_clause_count" = "1024" "indices.fielddata.cache.size" = "20" "action.destructive_requires_name" = "false" } access_policies = <<POLICY { "Version": "2012-10-17", "Statement": [{ "Effect": "Allow", "Principal": { "AWS": "arn:aws:iam::123456789012:role/MattermostAppRole" }, "Action": "es:*", "Resource": "arn:aws:es:us-east-1:123456789012:domain/mattermost-os/*" }] } POLICY service_software_options { automated_snapshot_start_hour = 23 } domain_endpoint_options { enforce_https = true } }
Follow these steps to configure Mattermost to use your AWS OpenSearch server and to generate the post index:
true to enable the other the settings on the page.opensearch.curl https://mattermost-os-xxxxx.us-east-1.es.amazonaws.com/_cluster/health<Inc0_common_configure_mattermost_for_enterprise_search />