---
title: How to Deploy OpenSearch as an Amazon OpenSearch Alternative
url: https://docs.vultr.com/how-to-deploy-opensearch-as-an-amazon-opensearch-alternative
description: Deploy a self-hosted three-node OpenSearch cluster on Vultr with TLS security, snapshots to Object Storage, index lifecycle policies, and migration steps.
publish_date: 2026-11-21T01:55:32.613944Z
last_updated: 2026-11-25T19:35:08.781467Z
author: Shivang Shandilya
header_image: https://docs.vultr.com/public/doc-assets/2676/0a823c86-69c8-4ef4-88aa-ef8ea436f66a.png
---

> Index of every Vultr Docs page in markdown: https://docs.vultr.com/llms.txt

[Amazon OpenSearch Service](https://docs.aws.amazon.com/opensearch-service/latest/developerguide/what-is.html) is a managed service from Amazon Web Services (AWS) that deploys, operates, and scales OpenSearch clusters, with AWS handling node provisioning, snapshots, software patching, and access control through AWS Identity and Access Management (IAM).

[OpenSearch](https://opensearch.org/) is a distributed search and analytics engine built on Apache Lucene, an open-source full-text search library. It enables you to store, search, analyze, and visualize large volumes of data, making it well suited for use cases such as log analytics, application monitoring, security analytics, and full-text search. It also includes OpenSearch Dashboards, a web-based interface for exploring data, analyzing results, and creating visualizations.

This article explains how to deploy OpenSearch as an alternative to Amazon OpenSearch Service. It covers preparing the host, securing the cluster with your own certificates and users, deploying a three-node cluster with OpenSearch Dashboards using Docker Compose, verifying the deployment, scheduling snapshots to S3-compatible Object Storage, managing index lifecycle policies, monitoring the cluster, and migrating from Amazon OpenSearch Service.

## Understanding the Architecture

Amazon OpenSearch Service wraps the OpenSearch engine with managed infrastructure and AWS-native access control. The following table maps each Amazon OpenSearch Service component to its self-hosted counterpart and notes where no equivalent exists.

| Amazon OpenSearch Service | Self-Hosted OpenSearch | Description |
|---|---|---|
| Managed domain | OpenSearch cluster | The set of nodes that stores indices and serves search and indexing requests over the OpenSearch REST API. |
| Query DSL, mappings, analyzers | Unchanged | The JSON-based query domain-specific language (DSL), index schema definitions, and text-analysis pipeline used to search and structure documents. |
| IAM policies + AWS Signature Version 4 (SigV4) request signing | Security plugin (basic auth, certificates, SAML, OpenID Connect) | Authenticates each request and authorizes it against roles scoped to indices, documents, and fields. |
| VPC-only endpoint | Your own network boundary and reverse proxy | Restricts which clients on the network can reach the cluster's REST API endpoint. On Amazon OpenSearch Service, the endpoint is reachable only from inside an Amazon Virtual Private Cloud (VPC). |
| UltraWarm storage tier | No managed equivalent | A lower-cost, Amazon S3-backed storage tier for read-only data that you query less often than hot-tier data. |
| Cold storage tier | No managed equivalent | The lowest-cost storage tier, backed by Amazon S3 with no compute attached. You must migrate an index back to UltraWarm before you can query it. |
| Automated snapshots to Amazon S3 | Snapshot Management policy writing to an S3-compatible repository | Point-in-time backups of indices and cluster state, stored in a snapshot repository and used to restore data or migrate between clusters. |
| Index State Management (ISM) | ISM plugin | Policies that automate index operations, such as rollover, shrink, migration between storage tiers, and deletion, based on index age, size, or document count. |
| Amazon CloudWatch metrics | Cluster APIs and the Alerting plugin | Node, heap, disk, and cluster health metrics, with monitors that notify you when a threshold is crossed. |
| Multi-AZ with Standby | Node placement and replica count you choose | Deploys the domain across three Availability Zones, each with a full copy of the data, and reserves the nodes in one zone as standby. If an active zone fails, the service activates the standby nodes automatically. |
| Managed version upgrades, off-peak maintenance windows | Upgrades you perform, on the release you choose | Schedules service software updates during a daily off-peak window you configure. Engine version upgrades run when you start them. |
| OpenSearch Dashboards | OpenSearch Dashboards | The bundled web UI for visualizing data, managing indices, and configuring the Security plugin. |

## Prerequisites

Before you begin, you need to:

* Have access to an Ubuntu 24.04 [Linux-based server](https://www.vultr.com/features/operating-systems/) (with at least 4 CPU cores and 8 GB of RAM) as a [non-root user with sudo privileges](https://docs.vultr.com/how-to-create-a-sudo-user-in-linux).
* [Install Docker and Docker Compose](https://docs.vultr.com/how-to-install-docker-on-ubuntu-24-04#install-docker).
* [Provision S3-compatible Object Storage](https://docs.vultr.com/products/storage/object-storage/provisioning) and [create a bucket](https://docs.vultr.com/products/storage/object-storage/management/manage-buckets) for snapshots. Note the hostname, access key, and secret key.

## Prepare the Host

OpenSearch memory-maps its index files and locks its Java heap in memory, so disable swap and raise the memory map limit on the host before the containers start.

1. Disable memory paging and swapping on the host to improve performance.

    ```console
    $ sudo swapoff -a
    ```

1. Comment out any swap entries in the file systems table so that swap stays disabled after a reboot.

    ```console
    $ sudo sed -i '/ swap / s/^/#/' /etc/fstab
    ```

1. Open the sysctl configuration file to raise `vm.max_map_count`, the maximum number of memory map areas a process can use.

    ```console
    $ sudo nano /etc/sysctl.conf
    ```

1. Add the following line, or change the value if the key exists.

    ```ini
    vm.max_map_count=262144
    ```

    Save and close the file.

1. Reload the kernel parameters.

    ```console
    $ sudo sysctl -p
    ```

1. Verify that the kernel applied the change.

    ```console
    $ cat /proc/sys/vm/max_map_count
    ```

    The output returns the value `262144`.

## Set Up the Directory Structure, Configuration, and Environment Variables

The project directory holds the environment file, the security configuration, the certificates, and the Docker Compose file. Docker Compose reads the environment file to fill in the image version, the domain name, and the Dashboards server password.

1. Create the project directory with subdirectories for certificates and the keystore.

    ```console
    $ mkdir -p ~/opensearch/certs ~/opensearch/keystore
    ```

1. Navigate to the project directory.

    ```console
    $ cd ~/opensearch
    ```

1. Create the environment file.

    ```console
    $ nano .env
    ```

1. Add the following configuration:

    ```ini
    # OpenSearch release
    OPENSEARCH_VERSION=3.10.0

    # Password OpenSearch Dashboards uses to connect to the cluster
    DASHBOARDS_SERVER_PASSWORD='DASHBOARDS_SERVER_PASSWORD'

    # Domain and TLS
    DASHBOARDS_DOMAIN=DASHBOARDS_DOMAIN_NAME
    LETSENCRYPT_EMAIL=EMAIL_ADDRESS
    ```

    Replace:

    * `DASHBOARDS_SERVER_PASSWORD` with a strong password for the internal `kibanaserver` user. Keep the single quotation marks so that Docker Compose does not interpret a `$` character in the password as a variable.
    * `DASHBOARDS_DOMAIN_NAME` with your domain name, for example `dashboards.example.com`.
    * `EMAIL_ADDRESS` with your email address for Let's Encrypt notifications.

    Save and close the file.

1. Restrict access to the environment file to your user, because it contains a password.

    ```console
    $ chmod 600 .env
    ```

## Configure Cluster Security

The OpenSearch image ships a demo security configuration with known certificates and default users. This deployment disables that demo setup and replaces it with a private certificate authority, node and administrator certificates, and internal users whose passwords only you know. Internal users are accounts stored in the Security plugin's own user database rather than in an external identity provider. Each node presents its node certificate to identify itself and encrypt traffic between nodes and on the REST API. The administrator certificate is a client certificate that authorizes changes to the security configuration.

1. Create a script that generates the certificate authority and the certificates.

    ```console
    $ nano generate-certs.sh
    ```

1. Add the following content:

    ```bash
    #!/bin/bash
    set -e
    cd ~/opensearch/certs

    # Root certificate authority
    openssl genrsa -out root-ca-key.pem 2048
    openssl req -new -x509 -sha256 -key root-ca-key.pem -subj "/O=EXAMPLE/CN=opensearch-root-ca" \
      -out root-ca.pem -days 730 \
      -addext 'basicConstraints = critical, CA:TRUE, pathlen:0' \
      -addext 'keyUsage = critical, keyCertSign, cRLSign' \
      -addext 'authorityKeyIdentifier = keyid'

    # Administrator certificate
    openssl genrsa -out admin-key-temp.pem 2048
    openssl pkcs8 -inform PEM -outform PEM -in admin-key-temp.pem -topk8 -nocrypt -v1 PBE-SHA1-3DES -out admin-key.pem
    openssl req -new -key admin-key.pem -subj "/O=EXAMPLE/CN=admin" -out admin.csr
    openssl x509 -req -in admin.csr -CA root-ca.pem -CAkey root-ca-key.pem -CAcreateserial -sha256 -out admin.pem -days 730

    # Node certificates
    for NODE in opensearch-node1 opensearch-node2 opensearch-node3; do
      openssl genrsa -out ${NODE}-key-temp.pem 2048
      openssl pkcs8 -inform PEM -outform PEM -in ${NODE}-key-temp.pem -topk8 -nocrypt -v1 PBE-SHA1-3DES -out ${NODE}-key.pem
      openssl req -new -key ${NODE}-key.pem -subj "/O=EXAMPLE/CN=${NODE}" -out ${NODE}.csr
      echo "subjectAltName=DNS:${NODE},DNS:localhost,IP:127.0.0.1" > ${NODE}.ext
      openssl x509 -req -in ${NODE}.csr -CA root-ca.pem -CAkey root-ca-key.pem -CAcreateserial -sha256 -out ${NODE}.pem -days 730 -extfile ${NODE}.ext
    done

    # Clean up intermediate files
    rm -f *-temp.pem *.csr *.ext
    ```

    Save and close the file.

    The script follows the [OpenSearch self-signed certificate procedure](https://docs.opensearch.org/latest/security/configuration/generate-certificates/):

    * `root-ca.pem`: The certificate authority that every node and client trusts. Keep `root-ca-key.pem` private, because anyone with it can issue certificates the cluster accepts.
    * `admin.pem`: The administrator certificate. Its distinguished name (DN) `CN=admin,O=EXAMPLE` is the only identity allowed to load the security configuration.
    * `opensearch-node1.pem` to `opensearch-node3.pem`: One certificate per node. The subject alternative names match the container name and `localhost`, so clients that verify hostnames accept them.
    * `-days 730`: Sets a two-year validity period. Renew the certificates before they expire.

1. Run the script.

    ```console
    $ bash generate-certs.sh
    ```

    The `certs` directory now contains `root-ca.pem`, `admin.pem`, `admin-key.pem`, and a certificate and key for each of the three nodes.

1. Restrict access to the private keys so that only the file owner can read them.

    ```console
    $ chmod 600 certs/*-key.pem
    ```

1. Give ownership of the `certs` directory to the user ID `1000` that OpenSearch runs as inside the container.

    ```console
    $ sudo chown -R 1000:1000 certs
    ```

1. Create the OpenSearch node configuration file.

    ```console
    $ nano opensearch.yml
    ```

1. Add the following configuration:

    ```yaml
    cluster.name: opensearch-cluster
    network.host: 0.0.0.0

    # TLS between nodes
    plugins.security.ssl.transport.pemcert_filepath: node.pem
    plugins.security.ssl.transport.pemkey_filepath: node-key.pem
    plugins.security.ssl.transport.pemtrustedcas_filepath: root-ca.pem
    plugins.security.ssl.transport.enforce_hostname_verification: false

    # TLS on the REST API
    plugins.security.ssl.http.enabled: true
    plugins.security.ssl.http.pemcert_filepath: node.pem
    plugins.security.ssl.http.pemkey_filepath: node-key.pem
    plugins.security.ssl.http.pemtrustedcas_filepath: root-ca.pem

    # Certificate identities
    plugins.security.authcz.admin_dn:
      - 'CN=admin,O=EXAMPLE'
    plugins.security.nodes_dn:
      - 'CN=opensearch-node1,O=EXAMPLE'
      - 'CN=opensearch-node2,O=EXAMPLE'
      - 'CN=opensearch-node3,O=EXAMPLE'
    plugins.security.restapi.roles_enabled: ["all_access", "security_rest_api_access"]

    # S3-compatible snapshot repository client
    s3.client.default.endpoint: OBJECT_STORAGE_HOSTNAME
    s3.client.default.region: us-east-1
    ```

    Replace `OBJECT_STORAGE_HOSTNAME` with the hostname shown in your Object Storage subscription details.

    Save and close the file.

    In the above configuration:

    * `node.pem` and `node-key.pem`: Generic file names that Docker Compose maps to each node's own certificate, so all three nodes share this file.
    * `plugins.security.ssl.transport.enforce_hostname_verification`: Turns off hostname checks between nodes, because containers reach each other by IP address. Nodes still have to present a certificate signed by your certificate authority with a DN listed in `plugins.security.nodes_dn`.
    * `plugins.security.authcz.admin_dn`: The DN of the administrator certificate.
    * `plugins.security.restapi.roles_enabled`: Lets users mapped to the `all_access` or `security_rest_api_access` role manage users, roles, and role mappings through the Security REST API.
    * `s3.client.default.region`: Required by the `repository-s3` plugin. For storage outside AWS, the value has no effect.

1. Generate a password hash for the `admin` user. The command runs the Security plugin's hashing tool in a temporary container.

    ```console
    $ docker run --rm opensearchproject/opensearch:3.10.0 /usr/share/opensearch/plugins/opensearch-security/tools/hash.sh -p 'ADMIN_PASSWORD'
    ```

    Replace `ADMIN_PASSWORD` with a strong password for the cluster administrator. The last line of the output is the bcrypt hash of the password. Copy it.

1. Generate a password hash for the `kibanaserver` user. Use the same password you set as `DASHBOARDS_SERVER_PASSWORD` in the `.env` file.

    ```console
    $ docker run --rm opensearchproject/opensearch:3.10.0 /usr/share/opensearch/plugins/opensearch-security/tools/hash.sh -p 'DASHBOARDS_SERVER_PASSWORD'
    ```

1. Create the internal users file.

    ```console
    $ nano internal_users.yml
    ```

1. Add the following configuration:

    ```yaml
    _meta:
      type: "internalusers"
      config_version: 2

    admin:
      hash: "ADMIN_PASSWORD_HASH"
      reserved: true
      backend_roles:
        - "admin"
      description: "Cluster administrator"

    kibanaserver:
      hash: "DASHBOARDS_SERVER_PASSWORD_HASH"
      reserved: true
      description: "OpenSearch Dashboards server user"
    ```

    Replace:

    * `ADMIN_PASSWORD_HASH` with the hash generated for the `admin` user.
    * `DASHBOARDS_SERVER_PASSWORD_HASH` with the hash generated for the `kibanaserver` user.

    Save and close the file.

    The file defines only these two users, which removes the demo users that ship with the image. A role defines a set of cluster and index permissions, and a role mapping assigns a role to users or backend roles. The default role mappings grant `all_access` to the `admin` backend role and the `kibana_server` role to the `kibanaserver` user.

## Build the OpenSearch Image with the S3 Repository Plugin

Snapshots to S3-compatible Object Storage require the S3 repository plugin, which the stock OpenSearch image does not include. A short Dockerfile adds the plugin, and a separate keystore file holds the Object Storage credentials so that they never become part of an image layer.

1. Create the Dockerfile.

    ```console
    $ nano Dockerfile
    ```

1. Add the following content:

    ```dockerfile
    ARG OPENSEARCH_VERSION
    FROM opensearchproject/opensearch:${OPENSEARCH_VERSION}
    RUN /usr/share/opensearch/bin/opensearch-plugin install --batch repository-s3
    ```

    Save and close the file.

1. Build the image.

    ```console
    $ docker build --build-arg OPENSEARCH_VERSION=3.10.0 -t opensearch-s3:3.10.0 .
    ```

    The build output ends with a line that names the image `opensearch-s3:3.10.0`. The version in this command, in the `hash.sh` and keystore commands, and in `OPENSEARCH_VERSION` in the `.env` file must match, because Docker Compose runs `opensearch-s3:${OPENSEARCH_VERSION}` and the Dashboards image uses the same variable.

1. Give ownership of the keystore directory to the user ID that OpenSearch runs as.

    ```console
    $ sudo chown 1000:1000 keystore
    ```

1. Create the keystore and add the Object Storage credentials. The command prompts for each value without echoing it.

    ```console
    $ docker run --rm -it -v "$HOME/opensearch/keystore:/keystore" opensearch-s3:3.10.0 bash -c \
        "/usr/share/opensearch/bin/opensearch-keystore create && \
        /usr/share/opensearch/bin/opensearch-keystore add s3.client.default.access_key && \
        /usr/share/opensearch/bin/opensearch-keystore add s3.client.default.secret_key && \
        cp /usr/share/opensearch/config/opensearch.keystore /keystore/"
    ```

    Enter your Object Storage access key and secret key when prompted.

1. Verify that the keystore file exists.

    ```console
    $ sudo ls -l keystore/opensearch.keystore
    ```

    The output lists the `opensearch.keystore` file owned by user ID `1000`.

## Deploy OpenSearch with Docker Compose

This deployment stack uses Docker Compose to run a three-node OpenSearch cluster alongside OpenSearch Dashboards. Traefik acts as a reverse proxy that provides HTTPS access to the Dashboards interface, and persistent volumes retain OpenSearch data across container restarts. The cluster manager node tracks cluster state, such as which nodes have joined, which indices exist, and where shards are allocated. Three cluster-manager-eligible nodes keep a quorum to elect a cluster manager if one node process stops. All three nodes run on one server, so this layout does not survive the loss of the server itself. For production high availability, run each node on a separate server connected through a private network.

Docker publishes container ports with its own firewall rules, which bypass Uncomplicated Firewall (UFW). The Compose file therefore binds the OpenSearch REST API to the loopback interface and publishes only the Traefik ports to the internet.

1. Create a DNS `A` record for your Dashboards domain, such as `dashboards.example.com`, that points to the public IP address of the server. For instructions, see [How to Manage DNS Records](https://docs.vultr.com/products/network/dns/management/manage-records).

1. Allow inbound HTTP traffic through the firewall. Traefik uses this port to redirect visitors to HTTPS.

    ```console
    $ sudo ufw allow 80/tcp
    ```

1. Allow inbound HTTPS traffic through the firewall. Traefik serves OpenSearch Dashboards and completes the Let's Encrypt certificate challenge on this port.

    ```console
    $ sudo ufw allow 443/tcp
    ```

1. Verify that UFW applied the firewall rules.

    ```console
    $ sudo ufw status
    ```

    The output lists ports `80/tcp` and `443/tcp` with the `ALLOW` action.

1. Create the Docker Compose file.

    ```console
    $ nano docker-compose.yml
    ```

1. Add the following configuration:

    ```yaml
    services:
      traefik:
        image: "traefik:v3.7.19"
        container_name: "traefik"
        restart: unless-stopped
        command:
          - "--log.level=INFO"
          - "--providers.docker=true"
          - "--providers.docker.exposedbydefault=false"
          - "--entrypoints.web.address=:80"
          - "--entrypoints.web.http.redirections.entrypoint.to=websecure"
          - "--entrypoints.web.http.redirections.entrypoint.scheme=https"
          - "--entrypoints.websecure.address=:443"
          - "--certificatesresolvers.myresolver.acme.tlschallenge=true"
          - "--certificatesresolvers.myresolver.acme.email=${LETSENCRYPT_EMAIL}"
          - "--certificatesresolvers.myresolver.acme.storage=/letsencrypt/acme.json"
        ports:
          - "80:80"
          - "443:443"
        volumes:
          - "./letsencrypt:/letsencrypt"
          - "/var/run/docker.sock:/var/run/docker.sock:ro"
        networks:
          - opensearch-net

      opensearch-node1:
        image: opensearch-s3:${OPENSEARCH_VERSION}
        container_name: opensearch-node1
        restart: unless-stopped
        environment:
          - node.name=opensearch-node1
          - discovery.seed_hosts=opensearch-node1,opensearch-node2,opensearch-node3
          - cluster.initial_cluster_manager_nodes=opensearch-node1,opensearch-node2,opensearch-node3
          - bootstrap.memory_lock=true
          - "OPENSEARCH_JAVA_OPTS=-Xms1g -Xmx1g"
          - DISABLE_INSTALL_DEMO_CONFIG=true
          - AWS_EC2_METADATA_DISABLED=true
        ulimits:
          memlock:
            soft: -1
            hard: -1
          nofile:
            soft: 65536
            hard: 65536
        volumes:
          - opensearch-data1:/usr/share/opensearch/data
          - ./opensearch.yml:/usr/share/opensearch/config/opensearch.yml:ro
          - ./internal_users.yml:/usr/share/opensearch/config/opensearch-security/internal_users.yml:ro
          - ./certs/root-ca.pem:/usr/share/opensearch/config/root-ca.pem:ro
          - ./certs/opensearch-node1.pem:/usr/share/opensearch/config/node.pem:ro
          - ./certs/opensearch-node1-key.pem:/usr/share/opensearch/config/node-key.pem:ro
          - ./certs/admin.pem:/usr/share/opensearch/config/admin.pem:ro
          - ./certs/admin-key.pem:/usr/share/opensearch/config/admin-key.pem:ro
          - ./keystore/opensearch.keystore:/usr/share/opensearch/config/opensearch.keystore
        ports:
          - "127.0.0.1:9200:9200"
        networks:
          - opensearch-net

      opensearch-node2:
        image: opensearch-s3:${OPENSEARCH_VERSION}
        container_name: opensearch-node2
        restart: unless-stopped
        environment:
          - node.name=opensearch-node2
          - discovery.seed_hosts=opensearch-node1,opensearch-node2,opensearch-node3
          - cluster.initial_cluster_manager_nodes=opensearch-node1,opensearch-node2,opensearch-node3
          - bootstrap.memory_lock=true
          - "OPENSEARCH_JAVA_OPTS=-Xms1g -Xmx1g"
          - DISABLE_INSTALL_DEMO_CONFIG=true
          - AWS_EC2_METADATA_DISABLED=true
        ulimits:
          memlock:
            soft: -1
            hard: -1
          nofile:
            soft: 65536
            hard: 65536
        volumes:
          - opensearch-data2:/usr/share/opensearch/data
          - ./opensearch.yml:/usr/share/opensearch/config/opensearch.yml:ro
          - ./internal_users.yml:/usr/share/opensearch/config/opensearch-security/internal_users.yml:ro
          - ./certs/root-ca.pem:/usr/share/opensearch/config/root-ca.pem:ro
          - ./certs/opensearch-node2.pem:/usr/share/opensearch/config/node.pem:ro
          - ./certs/opensearch-node2-key.pem:/usr/share/opensearch/config/node-key.pem:ro
          - ./keystore/opensearch.keystore:/usr/share/opensearch/config/opensearch.keystore
        networks:
          - opensearch-net

      opensearch-node3:
        image: opensearch-s3:${OPENSEARCH_VERSION}
        container_name: opensearch-node3
        restart: unless-stopped
        environment:
          - node.name=opensearch-node3
          - discovery.seed_hosts=opensearch-node1,opensearch-node2,opensearch-node3
          - cluster.initial_cluster_manager_nodes=opensearch-node1,opensearch-node2,opensearch-node3
          - bootstrap.memory_lock=true
          - "OPENSEARCH_JAVA_OPTS=-Xms1g -Xmx1g"
          - DISABLE_INSTALL_DEMO_CONFIG=true
          - AWS_EC2_METADATA_DISABLED=true
        ulimits:
          memlock:
            soft: -1
            hard: -1
          nofile:
            soft: 65536
            hard: 65536
        volumes:
          - opensearch-data3:/usr/share/opensearch/data
          - ./opensearch.yml:/usr/share/opensearch/config/opensearch.yml:ro
          - ./internal_users.yml:/usr/share/opensearch/config/opensearch-security/internal_users.yml:ro
          - ./certs/root-ca.pem:/usr/share/opensearch/config/root-ca.pem:ro
          - ./certs/opensearch-node3.pem:/usr/share/opensearch/config/node.pem:ro
          - ./certs/opensearch-node3-key.pem:/usr/share/opensearch/config/node-key.pem:ro
          - ./keystore/opensearch.keystore:/usr/share/opensearch/config/opensearch.keystore
        networks:
          - opensearch-net

      opensearch-dashboards:
        image: opensearchproject/opensearch-dashboards:${OPENSEARCH_VERSION}
        container_name: opensearch-dashboards
        restart: unless-stopped
        environment:
          - 'OPENSEARCH_HOSTS=["https://opensearch-node1:9200","https://opensearch-node2:9200","https://opensearch-node3:9200"]'
          - OPENSEARCH_USERNAME=kibanaserver
          - OPENSEARCH_PASSWORD=${DASHBOARDS_SERVER_PASSWORD}
          - OPENSEARCH_SSL_VERIFICATIONMODE=full
          - OPENSEARCH_SSL_CERTIFICATEAUTHORITIES=/usr/share/opensearch-dashboards/config/root-ca.pem
        volumes:
          - ./certs/root-ca.pem:/usr/share/opensearch-dashboards/config/root-ca.pem:ro
        labels:
          - "traefik.enable=true"
          - "traefik.http.routers.dashboards.rule=Host(`${DASHBOARDS_DOMAIN}`)"
          - "traefik.http.routers.dashboards.entrypoints=websecure"
          - "traefik.http.routers.dashboards.tls.certresolver=myresolver"
          - "traefik.http.services.dashboards.loadbalancer.server.port=5601"
        depends_on:
          - opensearch-node1
          - opensearch-node2
          - opensearch-node3
        networks:
          - opensearch-net

    volumes:
      opensearch-data1:
      opensearch-data2:
      opensearch-data3:

    networks:
      opensearch-net:
    ```

    Save and close the file.

    In the above configuration:

    * `discovery.seed_hosts` and `cluster.initial_cluster_manager_nodes`: List all three nodes so the cluster can form on first boot and elect a cluster manager by majority.
    * `bootstrap.memory_lock=true`: Combined with the `memlock` ulimit, prevents the Java virtual machine (JVM) heap from swapping to disk.
    * `OPENSEARCH_JAVA_OPTS`: Sets a fixed 1 GB heap per node, sized for three nodes and Dashboards on an 8 GB server. OpenSearch recommends a heap of about half the memory available to each node, with the rest left for the operating system's file cache. Keep the heap at or below 32 GB, the default upper limit on Amazon OpenSearch Service, so the JVM can keep using compressed object pointers. When you move each node to its own server, raise `-Xms` and `-Xmx` together to half of that server's memory.
    * `DISABLE_INSTALL_DEMO_CONFIG=true`: Stops the image from installing the demo certificates and users.
    * `AWS_EC2_METADATA_DISABLED=true`: Stops the `repository-s3` plugin from querying the AWS instance metadata service, which does not exist outside AWS.
    * `127.0.0.1:9200:9200`: Publishes the REST API of `opensearch-node1` on the loopback interface only. Applications on the same server and the commands in this article can reach it, but other hosts cannot. The Performance Analyzer port `9600` is not published.
    * `admin.pem` and `admin-key.pem`: Mounted on `opensearch-node1` only, because that is where you run the security administration tool.
    * `OPENSEARCH_SSL_VERIFICATIONMODE=full`: Makes Dashboards verify each node's certificate and hostname against your certificate authority.

1. Start the stack in detached mode.

    ```console
    $ docker compose up -d
    ```

1. Verify that the containers are running.

    ```console
    $ docker compose ps -a
    ```

    The output displays running containers for `traefik`, `opensearch-node1`, `opensearch-node2`, `opensearch-node3`, and `opensearch-dashboards`.

## Initialize the Security Plugin

With the demo configuration disabled, the Security plugin starts uninitialized, without users or roles, and rejects every request until you load the configuration files into the cluster. The security administration tool, `securityadmin.sh`, loads the files and authenticates with the administrator certificate. Run it again whenever you change a file in the security configuration directory.

1. Load the security configuration into the cluster.

    ```console
    $ docker compose exec opensearch-node1 /usr/share/opensearch/plugins/opensearch-security/tools/securityadmin.sh \
        -cd /usr/share/opensearch/config/opensearch-security/ \
        -icl -nhnv \
        -cacert /usr/share/opensearch/config/root-ca.pem \
        -cert /usr/share/opensearch/config/admin.pem \
        -key /usr/share/opensearch/config/admin-key.pem
    ```

    In the above command:

    * `-cd`: The directory that holds `internal_users.yml`, `roles.yml`, `roles_mapping.yml`, and the other security configuration files.
    * `-icl`: Ignores the cluster name check.
    * `-nhnv`: Skips hostname verification for the connection to `localhost`.
    * `-cacert`, `-cert`, and `-key`: The certificate authority, the administrator certificate, and its private key.

    The output ends with `Done with success`.

1. Verify that the `admin` user can authenticate.

    ```console
    $ curl --cacert certs/root-ca.pem -u 'admin:ADMIN_PASSWORD' https://localhost:9200/_plugins/_security/authinfo?pretty
    ```

    Replace `ADMIN_PASSWORD` with the password you hashed for the `admin` user. The output returns JSON with `"user_name" : "admin"` and `all_access` in the `roles` list.

## Verify the Deployment

The following checks confirm that the three-node cluster is healthy, that it can accept documents, that the indexed data can be retrieved, and that the REST API is not reachable from other hosts.

1. Verify cluster health. In this and the following commands, replace `ADMIN_PASSWORD` with the password of the `admin` user.

    ```console
    $ curl --cacert certs/root-ca.pem -u 'admin:ADMIN_PASSWORD' "https://localhost:9200/_cluster/health?pretty"
    ```

    The output returns JSON with `"status" : "green"` and `"number_of_nodes" : 3`.

1. Index a test document.

    ```console
    $ curl --cacert certs/root-ca.pem -u 'admin:ADMIN_PASSWORD' -X POST "https://localhost:9200/test-index/_doc" \
        -H "Content-Type: application/json" \
        -d '{"message": "hello opensearch"}'
    ```

    The output returns JSON with `"_index":"test-index"`, `"result":"created"`, and `"_shards":{"total":2,"successful":2,"failed":0}`.

1. Query the document back.

    ```console
    $ curl --cacert certs/root-ca.pem -u 'admin:ADMIN_PASSWORD' "https://localhost:9200/test-index/_search?pretty"
    ```

    The output returns your document in the `hits` array, with `_source` showing `"message" : "hello opensearch"`.

1. From your workstation or another machine, confirm that the REST API port is closed to the internet.

    ```console
    $ nc -zv SERVER_IP 9200
    ```

    Replace `SERVER_IP` with the public IP address of the server. The output reports that the connection was refused or timed out.

1. Open a web browser and navigate to your Dashboards domain, such as `https://dashboards.example.com`.

1. Sign in with the username `admin` and the password you set for the `admin` user.

After signing in, you can use OpenSearch Dashboards to search and explore data stored in the cluster, create visualizations and dashboards, and manage users, roles, and index policies from the web interface.

## Create a Least-Privilege Application User

Applications should not connect with the administrator account, which has full access to every index and the security configuration. The Security plugin lets you define a role limited to specific index patterns and actions, then map an internal user to it. The following steps create a role that can create indices with a given name prefix and read and write documents in them, and a user mapped to that role.

1. Create the role.

    ```console
    $ curl --cacert certs/root-ca.pem -u 'admin:ADMIN_PASSWORD' -X PUT "https://localhost:9200/_plugins/_security/api/roles/app_read_write" \
        -H "Content-Type: application/json" \
        -d '{
          "cluster_permissions": ["cluster_composite_ops"],
          "index_permissions": [{
            "index_patterns": ["app-*"],
            "allowed_actions": ["crud", "create_index"]
          }]
        }'
    ```

    In the above command:

    * `cluster_composite_ops`: Allows bulk requests, multi-get, multi-search, and alias lookups.
    * `crud`: Allows reading, writing, and deleting documents in matching indices.
    * `create_index`: Allows creating matching indices and their mappings.

    The output returns JSON with `"status":"CREATED"`.

1. Create the application user.

    ```console
    $ curl --cacert certs/root-ca.pem -u 'admin:ADMIN_PASSWORD' -X PUT "https://localhost:9200/_plugins/_security/api/internalusers/app_user" \
        -H "Content-Type: application/json" \
        -d '{"password": "APP_USER_PASSWORD"}'
    ```

    Replace `APP_USER_PASSWORD` with a strong password. The output returns JSON with `"status":"CREATED"`.

    > [!NOTE]
    > OpenSearch rejects weak passwords for users created through the REST API, using the **zxcvbn** password strength estimation library developed by Dropbox. To learn more about zxcvbn, see the [Dropbox zxcvbn blog post](https://dropbox.tech/security/zxcvbn-realistic-password-strength-estimation).

1. Map the user to the role.

    ```console
    $ curl --cacert certs/root-ca.pem -u 'admin:ADMIN_PASSWORD' -X PUT "https://localhost:9200/_plugins/_security/api/rolesmapping/app_read_write" \
        -H "Content-Type: application/json" \
        -d '{"users": ["app_user"]}'
    ```

    The output returns JSON with `"status":"CREATED"`.

1. Verify that the application user can write to an allowed index.

    ```console
    $ curl --cacert certs/root-ca.pem -u 'app_user:APP_USER_PASSWORD' -X POST "https://localhost:9200/app-orders/_doc" \
        -H "Content-Type: application/json" \
        -d '{"order_id": 1}'
    ```

    The output returns JSON with `"result":"created"`.

1. Verify that the application user cannot read an index outside its pattern.

    ```console
    $ curl --cacert certs/root-ca.pem -u 'app_user:APP_USER_PASSWORD' "https://localhost:9200/test-index/_search?pretty"
    ```

    The output returns a `security_exception` error with status `403`.

## Schedule Snapshots to Object Storage

Amazon OpenSearch Service takes automated snapshots for you. On a self-hosted cluster, you register a snapshot repository, a storage location where OpenSearch writes snapshot data, and create a Snapshot Management policy that takes and prunes snapshots on a schedule. The repository uses the S3 repository plugin and the credentials in the keystore to write to your Object Storage bucket.

1. Register the snapshot repository.

    ```console
    $ curl --cacert certs/root-ca.pem -u 'admin:ADMIN_PASSWORD' -X PUT "https://localhost:9200/_snapshot/object_storage_repo" \
        -H "Content-Type: application/json" \
        -d '{
          "type": "s3",
          "settings": {
            "bucket": "BUCKET_NAME",
            "base_path": "opensearch/snapshots"
          }
        }'
    ```

    Replace `BUCKET_NAME` with the name of your Object Storage bucket. OpenSearch verifies that every node can write to the bucket during registration. The output returns `{"acknowledged":true}`.

1. Create a Snapshot Management policy that takes a snapshot every day and keeps up to 30 days of snapshots.

    ```console
    $ curl --cacert certs/root-ca.pem -u 'admin:ADMIN_PASSWORD' -X POST "https://localhost:9200/_plugins/_sm/policies/daily_snapshots" \
        -H "Content-Type: application/json" \
        -d '{
          "description": "Daily snapshot of all indices",
          "creation": {
            "schedule": { "cron": { "expression": "0 2 * * *", "timezone": "UTC" } },
            "time_limit": "1h"
          },
          "deletion": {
            "schedule": { "cron": { "expression": "0 3 * * *", "timezone": "UTC" } },
            "condition": { "max_age": "30d", "max_count": 30, "min_count": 7 },
            "time_limit": "1h"
          },
          "snapshot_config": {
            "indices": "*,-.opendistro_security",
            "repository": "object_storage_repo",
            "ignore_unavailable": "true",
            "include_global_state": "false",
            "partial": "true"
          }
        }'
    ```

    In the above command:

    * `creation.schedule`: Takes a snapshot at 02:00 UTC every day.
    * `deletion.condition`: Deletes snapshots older than 30 days or beyond the 30 most recent, while always keeping at least 7.
    * `indices`: Includes all indices except the Security plugin index. Its configuration comes from the security files in the project directory, so keep a copy of those files with your backups.

    The output returns JSON with `"_id":"daily_snapshots-sm-policy"`.

1. Check the policy status.

    ```console
    $ curl --cacert certs/root-ca.pem -u 'admin:ADMIN_PASSWORD' "https://localhost:9200/_plugins/_sm/policies/daily_snapshots/_explain?pretty"
    ```

    The output shows the policy as enabled, with the next creation time in the `creation` section. After the first scheduled run, list the stored snapshots with `GET _snapshot/object_storage_repo/_all` to confirm that a snapshot reached the bucket.

## Manage Index Lifecycle with ISM

Amazon OpenSearch Service users often rely on ISM to delete or shrink old indices. The ISM plugin is part of the self-hosted distribution and works the same way. The following policy deletes log indices 30 days after creation, and its ISM template attaches the policy to every new matching index.

1. Create the ISM policy.

    ```console
    $ curl --cacert certs/root-ca.pem -u 'admin:ADMIN_PASSWORD' -X PUT "https://localhost:9200/_plugins/_ism/policies/logs_retention" \
        -H "Content-Type: application/json" \
        -d '{
          "policy": {
            "description": "Delete log indices after 30 days",
            "default_state": "hot",
            "states": [
              {
                "name": "hot",
                "actions": [],
                "transitions": [{ "state_name": "delete", "conditions": { "min_index_age": "30d" } }]
              },
              {
                "name": "delete",
                "actions": [{ "delete": {} }],
                "transitions": []
              }
            ],
            "ism_template": { "index_patterns": ["logs-*"], "priority": 100 }
          }
        }'
    ```

    The output returns JSON with `"_id":"logs_retention"` and the stored policy.

1. Create a test index that matches the pattern.

    ```console
    $ curl --cacert certs/root-ca.pem -u 'admin:ADMIN_PASSWORD' -X PUT "https://localhost:9200/logs-test"
    ```

    The output returns JSON with `"acknowledged":true` and `"index":"logs-test"`.

1. Check which policy manages the index.

    ```console
    $ curl --cacert certs/root-ca.pem -u 'admin:ADMIN_PASSWORD' "https://localhost:9200/_plugins/_ism/explain/logs-test?pretty"
    ```

    The output shows `"policy_id" : "logs_retention"` for the `logs-test` index.

Adjust the index pattern and the `min_index_age` value to match your own retention requirements. You can also manage ISM policies in OpenSearch Dashboards by navigating to **Index Management**.

## Monitor the Cluster

Amazon OpenSearch Service publishes cluster metrics to Amazon CloudWatch. A self-hosted cluster exposes the same information through its REST API, and the bundled Alerting plugin can watch those values and notify you. OpenSearch splits each index into primary shards and, by default, keeps one replica copy of each primary shard on a different node. Check node resources and disk use regularly, because a node that crosses the low disk watermark stops receiving new shards.

1. Check heap, memory, CPU, and roles for each node.

    ```console
    $ curl --cacert certs/root-ca.pem -u 'admin:ADMIN_PASSWORD' "https://localhost:9200/_cat/nodes?v"
    ```

    The output lists the three nodes with their `heap.percent`, `ram.percent`, and `cpu` values, and marks the elected cluster manager with `*`. Heap use that stays high across repeated checks indicates that the heap is too small for the workload.

1. Check disk use and shard counts for each node.

    ```console
    $ curl --cacert certs/root-ca.pem -u 'admin:ADMIN_PASSWORD' "https://localhost:9200/_cat/allocation?v"
    ```

    The output lists the shard count, disk used, disk available, and disk percentage for each node.

1. Review recent log entries from a node when health is not `green`.

    ```console
    $ docker compose logs --tail 50 opensearch-node1
    ```

To receive notifications, open OpenSearch Dashboards and navigate to **Alerting**, then create a per-cluster metrics monitor that checks the cluster health status and sends a message to a notification channel when the status is not `green`.

## Migrate from Amazon OpenSearch Service to Self-Hosted OpenSearch

Migrating from Amazon OpenSearch Service to a self-hosted cluster is a data and access-control migration rather than an application rewrite, because both sides speak the same REST API.

### Choose a Migration Path

* **Snapshot and restore**: Automated snapshots on Amazon OpenSearch Service are for recovery only and cannot move data to another cluster. Register a manual snapshot repository in an S3 bucket in your AWS account, which requires an IAM role that the service can assume, `iam:PassRole` permission for the user that registers it, and a SigV4-signed registration request. Take a manual snapshot, copy the snapshot files from the S3 bucket to your Object Storage bucket with a tool such as rclone, register that location on the self-hosted cluster as a repository with `"readonly": true`, and restore it. Each index must have been created by OpenSearch 2.x or later to restore on OpenSearch 3.x. Reindex indices created by OpenSearch 1.x or Elasticsearch 7.x on an intermediate cluster first. Exclude the Security plugin index `.opendistro_security` and the Dashboards indices `.kibana*` from the restore, and set `include_global_state` to `false`, so that the restore does not overwrite the users, roles, and saved objects of the new cluster.
* **Reindex from remote**: Copy documents from one cluster to another by having the destination cluster query the source cluster. Pull documents directly with `POST /_reindex` using `source.remote.host` pointed at the Amazon OpenSearch Service endpoint. Add the source host and port to `reindex.remote.allowlist` in `opensearch.yml` and restart the nodes, because the setting is static. The remote request authenticates with HTTP basic auth through `source.remote.username` and `source.remote.password`, so the source domain needs fine-grained access control with an internal user. Domains that accept only IAM-signed requests reject it. The self-hosted server must also be able to reach the domain endpoint, which rules out VPC-only domains without a network link.
* **OpenSearch Migration Assistant**: The [OpenSearch Migration Assistant](https://docs.opensearch.org/latest/migration-assistant/) lists Amazon OpenSearch Service and self-managed clusters as supported sources and targets. It runs on a Kubernetes cluster that you provide, backfills documents from a snapshot, and supports zero-downtime cutover only if you route client traffic through its capture proxy. It does not migrate ISM policies or the security configuration, so recreate those separately.

### Index and Mapping Migration

* Copy index templates, mappings, and settings across unchanged, because both sides run the same engine and accept the same mapping syntax.
* Confirm that the shard and replica counts suit the node count of the new cluster rather than the settings the managed domain used, because Amazon OpenSearch Service's default sizing assumes its own instance types.
* If any index uses approximate k-nearest neighbor (k-NN) search (`"index.knn": true`) that was migrated to UltraWarm or cold storage on the managed domain, restore it to hot storage on the self-hosted cluster before continuing, because there is no warm or cold tier to migrate it into.
* Recreate ISM policies and Snapshot Management policies on the new cluster, because none of the migration paths copies them reliably.

### Data Migration

* Restore from the snapshot repository, or pull indices with `POST /_reindex` using `source.remote.host` if you chose the reindex path.
* Compare document counts per index between the source domain and the destination cluster with `GET /INDEX_NAME/_count` after the transfer completes.

### Application Migration

* Change the application's endpoint from the Amazon OpenSearch Service domain endpoint to your self-hosted cluster's address: the internal Docker network hostname (`opensearch-node1`) for applications running alongside it, or a private network address for applications elsewhere. For remote applications, bind port `9200` to the server's private network address instead of `127.0.0.1`, and do not expose it on the public interface.
* Replace AWS SigV4 request signing with the authentication method configured on your Security plugin: basic auth with a least-privilege internal user, mutual TLS with a client certificate, or one of the supported single sign-on (SSO) protocols.
* Remove any AWS SDK signing middleware (such as `aws-sigv4` interceptors used with the low-level OpenSearch clients) from the application code, because a self-hosted cluster authenticates over standard HTTP basic auth or TLS client certificates instead.
* Configure clients to trust your certificate authority by passing `root-ca.pem`, instead of turning off certificate verification.

### Data Storage Considerations

* **Disk sizing**: Amazon OpenSearch Service sizes Amazon Elastic Block Store (EBS) volumes per node. On a self-hosted cluster, each node's data lives in a Docker volume on the server's disk. Size the disk for primary data multiplied by one plus the replica count, plus headroom for merges and the disk watermarks. By default, OpenSearch stops allocating new shards to a node at 85% disk use, moves shards away from it at 90%, and blocks writes to its indices at 95%.
* **Block storage**: To grow storage independently of compute, mount a block storage volume and point the Docker data volumes at it.
* **No warm or cold tier**: UltraWarm and cold storage indices become regular hot indices. Use ISM to delete aged data, and keep long-term copies in Object Storage snapshots instead of on the cluster.
* **Snapshot storage**: Snapshots are incremental, but the bucket grows with every changed segment. Set the Snapshot Management deletion conditions to match your recovery point objectives and storage budget.

### Things to Take Care During Migration

The following considerations affect the scope and sequencing of an Amazon OpenSearch Service to self-hosted migration.

* **OpenSearch Serverless**: OpenSearch Serverless collections scale in OpenSearch Compute Units (OCUs), and a self-hosted cluster has no equivalent. You size and provision fixed node capacity instead.
* **Snapshots and Version Upgrades**: Both become your responsibility. Confirm that the Snapshot Management policy runs, test a restore, and test each OpenSearch upgrade before applying it.
* **Multi-AZ with Standby**: Recreate equivalent availability by placing nodes on separate servers in different locations and setting replica counts accordingly. The self-hosted cluster does not manage this automatically.
* **Fine-Grained Access Control**: Amazon OpenSearch Service's fine-grained access control is built on the same OpenSearch Security plugin, so roles, role mappings, and index, document, and field-level permissions carry over conceptually. Anything tied to IAM does not carry over. IAM-backed role mappings and SigV4-authenticated requests have no direct equivalent, so rebuild them as internal users, certificates, or SSO group mappings.
* **Cost Model Change**: Amazon OpenSearch Service bills per instance-hour, EBS storage, UltraWarm and cold storage, and OCUs where applicable. A self-hosted cluster's cost is infrastructure-based: compute, storage, and the operational time spent on upgrades, backups, and tuning. Calculate the total cost of ownership before cutover.
* **Cutover Sequencing**: Run the migration with the source domain still serving production traffic, validate document counts and query results against the new cluster, then redirect application traffic and decommission the Amazon OpenSearch Service domain.

## Conclusion

You have deployed a three-node OpenSearch cluster with OpenSearch Dashboards on Docker Compose, replaced the demo security configuration with your own certificates and users, created a least-privilege application user, scheduled snapshots to Object Storage, added an index retention policy, and verified the deployment end to end. The migration section outlines how to move an existing Amazon OpenSearch Service domain to the self-hosted cluster when a cutover is required. For additional configuration options and API references, see the [official OpenSearch documentation](https://docs.opensearch.org/latest/).
