OpenSearch Clusters: Get Started with Install and Configuration

OpenSearch Clusters

Our first tutorial gave a general introduction to OpenSearch installation and configuration. We recently also published a comparative introduction for OpenSearch queries (and how they parallel or contrast with Elasticsearch). Now, we’ll continue that series with an intro to OpenSearch clusters. This is a very simple tutorial with straight-forward examples, but we will try to cover some detail and common advanced settings.

The directions to install and configure OpenSearch are going to remain in place for sometime. With that in mind, this tutorial is meant to help you get started with installation and configuration of OpenSearch clusters.

Where we left off was the deployment of a cluster. Technically, even a 1-node deployment is a cluster. Our previous OpenSearch tutorial deployed a two-node cluster, but obviously there is need for something more complex. We’ll deploy a four-node cluster here to give you some more insight into what happens when you go down the multi-node rabbit hole with OpenSearch. You’ll find similarities with Elasticsearch, but a couple of differences.

Again, create a new docker-compose.yml file. I recommend for this tutorial you just take this template as is. Save the file where you’d like:

version: '3'
services:
  opensearch-nodeA:
    image: opensearchproject/opensearch:latest
    container_name: opensearch-nodeA
    environment:
      - cluster.name=opensearch-cluster
      - node.name=opensearch-node1
      - discovery.seed_hosts=opensearch-nodeA,opensearch-nodeB,opensearch-nodeC,opensearch-nodeD
      - cluster.initial_master_nodes=opensearch-nodeA,opensearch-nodeB
      - bootstrap.memory_lock=true # along with the memlock settings below, disables swapping
      - "OPENSEARCH_JAVA_OPTS=-Xms512m -Xmx512m" # minimum and maximum Java heap size, recommend setting both to 50% of system RAM
    ulimits:
      memlock:
        soft: -1
        hard: -1
      nofile:
        soft: 65536 # maximum number of open files for the OpenSearch user, set to at least 65536 on modern systems
        hard: 65536
    volumes:
      - opensearch-data1:/usr/share/opensearch/data
    ports:
      - 9200:9200
      - 9600:9600 # required for Performance Analyzer
    networks:
      - opensearch-net
  opensearch-nodeB:
    image: opensearchproject/opensearch:latest
    container_name: opensearch-nodeB
    environment:
      - cluster.name=opensearch-cluster
      - node.name=opensearch-nodeB
      - discovery.seed_hosts=opensearch-nodeA,opensearch-nodeB,opensearch-nodeC,opensearch-nodeD
      - cluster.initial_master_nodes=oopensearch-nodeA,opensearch-nodeB
      - bootstrap.memory_lock=true
      - "OPENSEARCH_JAVA_OPTS=-Xms512m -Xmx512m"
    ulimits:
      memlock:
        soft: -1
        hard: -1
      nofile:
        soft: 65536
        hard: 65536
    volumes:
      - opensearch-data2:/usr/share/opensearch/data
    networks:
      - opensearch-net
  opensearch-nodeC:
    image: opensearchproject/opensearch:latest
    container_name: opensearch-nodeC
    environment:
      - cluster.name=opensearch-cluster
      - node.name=opensearch-nodeC
      - discovery.seed_hosts=opensearch-nodeA,opensearch-nodeB,opensearch-nodeC,opensearch-nodeD
      - cluster.initial_master_nodes=opensearch-nodeA,opensearch-nodeB
      - bootstrap.memory_lock=true # along with the memlock settings below, disables swapping
      - "OPENSEARCH_JAVA_OPTS=-Xms512m -Xmx512m" # minimum and maximum Java heap size, recommend setting both to 50% of system RAM
    ulimits:
      memlock:
        soft: -1
        hard: -1
      nofile:
        soft: 65536 # maximum number of open files for the OpenSearch user, set to at least 65536 on modern systems
        hard: 65536
    volumes:
      - opensearch-data1:/usr/share/opensearch/data
    ports:
      - 9200:9200
      - 9600:9600 # required for Performance Analyzer
    networks:
      - opensearch-net
  opensearch-nodeD:
    image: opensearchproject/opensearch:latest
    container_name: opensearch-nodeD
    environment:
      - cluster.name=opensearch-cluster
      - node.name=opensearch-nodeD
      - discovery.seed_hosts=opensearch-nodeA,opensearch-nodeB,opensearch-nodeC,opensearch-nodeD
      - cluster.initial_master_nodes=opensearch-nodeA,opensearch-nodeB
      - bootstrap.memory_lock=true # along with the memlock settings below, disables swapping
      - "OPENSEARCH_JAVA_OPTS=-Xms512m -Xmx512m" # minimum and maximum Java heap size, recommend setting both to 50% of system RAM
    ulimits:
      memlock:
        soft: -1
        hard: -1
      nofile:
        soft: 65536 # maximum number of open files for the OpenSearch user, set to at least 65536 on modern systems
        hard: 65536
    volumes:
      - opensearch-data1:/usr/share/opensearch/data
    ports:
      - 9200:9200
      - 9600:9600 # required for Performance Analyzer
    networks:
      - opensearch-net
  opensearch-dashboards:
    image: opensearchproject/opensearch-dashboards:latest
    container_name: opensearch-dashboards
    ports:
      - 5601:5601
    expose:
      - "5601"
    environment:
      OPENSEARCH_HOSTS: '["https://opensearch-node1:9200","https://opensearch-node2:9200"]'
    networks:
      - opensearch-net
 
volumes:
  opensearch-data1:
  opensearch-data2:
 
networks:
  opensearch-net:

Our four-node cluster will eventually look the diagram below, but to get it into this architecture you’ll need to configure OpenSearch.

OpenSearch Clusters: Configuration

There are five types of nodes in OpenSearch:

  1. Master
  2. Master-eligible
  3. Data
  4. Ingest
  5. Coordinating

With the exception of Master status, all the nodes you create will have all of these statuses by default. To configure the cluster nodes – and everything else – you need to enter the docker-compose.yml file.

Once there, you can add parameters for each node to explicitly declare them master-eligible, data nodes, or ingest nodes.

node.master: true
node.data: false
node.ingest: false

You can explicitly declare something the master node, although all nodes will be eligible by default. By setting the parameter to true, you can go through your settings more quickly. Also, obviously, you can declare which ones won’t be master-eligible with false:

node.master: true
node.data: false
node.ingest: false

As mentioned before, all nodes are data nodes, ingest nodes, and coordinating nodes by default. You can set them to solely be coordinating nodes by declaring all the parameters false:

node.master: false
node.data: false
node.ingest: false

Advanced Features for OpenSearch Clusters

Cross-Cluster Search in OpenSearch

Cross-cluster search is a feature that carries over from Elasticsearch. This lets you execute a search from a node in a first cluster against any other remote cluster, so long as you have the following permissions for that remote cluster defined in your roles.yml file:

indices:admin/shards/search_shards

To initiate multiple clusters, simply identify different cluster names in a docker-compose.yml file; for example:

version: '3'
services:
  opensearch-nodeX:
    image: opensearchproject/opensearch:latest
    container_name: opensearch-nodeA
    environment:
      - cluster.name=opensearch-cluster1
      - node.name=opensearch-node1
      - discovery.seed_hosts=opensearch-nodeA,opensearch-nodeB,opensearch-nodeC,opensearch-nodeD
      - cluster.initial_master_nodes=opensearch-nodeA,opensearch-nodeB
      - bootstrap.memory_lock=true # along with the memlock settings below, disables swapping
      - "OPENSEARCH_JAVA_OPTS=-Xms512m -Xmx512m" # minimum and maximum Java heap size, recommend setting both to 50% of system RAM
    ulimits:
      memlock:
        soft: -1
        hard: -1
      nofile:
        soft: 65536 # maximum number of open files for the OpenSearch user, set to at least 65536 on modern systems
        hard: 65536
    volumes:
      - opensearch-data1:/usr/share/opensearch/data
    ports:
      - 9200:9200
      - 9600:9600 # required for Performance Analyzer
    networks:
      - opensearch-net
  opensearch-nodeY:
    image: opensearchproject/opensearch:latest
    container_name: opensearch-nodeB
    environment:
      - cluster.name=opensearch-cluster2
      - node.name=opensearch-nodeB
      - discovery.seed_hosts=opensearch-nodeA,opensearch-nodeB,opensearch-nodeC,opensearch-nodeD
      - cluster.initial_master_nodes=oopensearch-nodeA,opensearch-nodeB
      - bootstrap.memory_lock=true
      - "OPENSEARCH_JAVA_OPTS=-Xms512m -Xmx512m"
    ulimits:
      memlock:
        soft: -1
        hard: -1
      nofile:
        soft: 65536
        hard: 65536
    volumes:
      - opensearch-data2:/usr/share/opensearch/data
    networks:
      - opensearch-net

More to Come

This is only a simple introduction to clusters in OpenSearch. For more tutorials and examples on OpenSearch and further news on Open Source projects, subscribe to the Logz.io blog.

Get started for free

Completely free for 14 days, no strings attached.