Skip to content

OpenSearch Unassigned Shards Clearance

OpenSearch Unassigned Shards Clearance in OpenSearch Issues.

4 min read Updated SS RS

OpenSearch Unassigned Shards Clearance#

Currently, there is no permanent fix for unassigned shards in OpenSearch. However, the following steps can be taken to clear unassigned shards.

Solution: Clearing Unassigned Shards

  1. Identify unassigned shards with the following command:

    curl -sS -ku admin:admin -XGET "https://<opensearchip>:<opensearchport>/_cat/shards?v&h=index,state" | grep -i UNASSIGNED | grep heal | cut -d ' ' -f1 > /tmp/indices.txt
    
  2. Execute the following commands to clear unassigned shards for each identified index:

    for i in $(cat /tmp/indices.txt); do
    echo $i;
    curl -ku admin:admin -XPUT "https://<opensearchip>:<opensearchport>/${i}/_settings" -H 'Content-Type: application/json' -d'{ "index":{"number_of_replicas":0}}';
    done
    

OpenSearch Cluster Formation Issue#

OpenSearch cluster failed to form due to an inability to start all OpenSearch nodes (coordinator, master, kpi, JIM, txn).

Solution:

  1. Stop JIM and Txn OpenSearch Nodes: Stop all OpenSearch nodes, specifically JIM and Txn nodes, from the OpenSearch cluster for Heal version 2.3.0.
  2. Clear Data Directories: Clear the contents inside all the data directories located in the below path.

    /Appsone_Service/opensearch
    

    Note: Do not delete the data folder.

  3. Update Consul Key: Update the Consul key using the following command:

    consul kv put service/opensearch/nodesarray '"192.0.2.12:9310","192.0.2.12:9311","192.0.2.12:9300","192.0.2.12:9325","192.0.2.13:9310","192.0.2.13:9311","192.0.2.13:9300","192.0.2.13:9325","192.0.2.14:9310","192.0.2.14:9311","192.0.2.14:9300","192.0.2.14:9325"'
    

    Remove entries for the three JIM nodes from this Consul key.

    Obtain the IP and port information from the JIM Nomad file and exclude those entries.

  4. Start OpenSearch Nodes: Start OpenSearch nodes one by one in the following sequence:

    Master → Coordinator → KPI → Txn.

Migration to Multi-Instance OpenSearch with Zoning#

Migrate from a single instance of OpenSearch to a multi-instance setup with zoning for the customer. The goal is to host KPI and transaction data on server 157 and add three Jim OpenSearch instances on server 158.

This setup will include two separate zones: one for Jim data (Jim zone) and another for the rest of the data (Heal zone).

Pre-Migration Steps:

  1. Port Configuration: Ensure ports 9250, 9350, 9251, 9351, 9252, and 9352 are open between the servers and in the firewall settings.
  2. Snapshot Directory Creation: On both servers, create an OpenSearch snapshot directory using:

    mkdir /heal/appnomic/Appsone_Service/opensearch/opensearchsnapshot
    
  3. Data Snapshot: Take an OpenSearch snapshot of the necessary data following guidelines from the provided documentation.

  4. Backup Pipelines: Backup existing Jim ingest pipelines for restoration post-migration.

Server Preparation:

  1. Log and Data Directories: On server 158, create log folders and data directories for the Jim nodes and grant permissions:

    cd /heal/appnomic/centralized_logs/ && mkdir -p opensearch-jim-node1 opensearch-jim-node2 opensearch-jim-node3
    cd /heal/appnomic/Appsone_Service/opensearch && mkdir -p data-jim1 data-jim2 data-jim3 data-heal
    
  2. Nomad File Preparation: Transfer the provided Nomad files to the <a1nomad> path on both servers, ensuring compatibility with server specifics. Convert file formats using dos2unix, if necessary.

OpenSearch Configuration:

  1. Consul Keys Configuration: Add the specified Consul keys to define nodes, ports, and zones.
  2. YML Configuration: Place the provided YML configuration files in the OpenSearch config directory on both servers, adjusting parameters as needed.
  3. System Settings Adjustment: Increase max_map_count to enhance performance:

    sysctl -w vm.max_map_count=262144
    

Post-Migration Steps:

  1. Start OpenSearch Nodes: Initiate the OpenSearch nodes sequentially, verifying their status with:

    curl -ku admin:admin -XGET "http://192.0.2.15:9200/_cat/nodes?v"
    
  2. Load OpenSearch Templates: Execute the opensearch-curl.sh script to load all OpenSearch templates, excluding zoning templates.

    Apply zoning templates using the provided commands.

  3. Data Restoration: Perform an OpenSearch restore using the snapshot taken earlier to recover the data.

OpenSearch Cluster Down After Restart#

Master node logs show SSL handshake errors:

javax.net.ssl.SSLHandshakeException: Received fatal alert: certificate_unknown

RCA: The issue occurred due to tampered root CA certificates.

Solution :

  1. Configure the certificates for OpenSearch.
  2. Restart the service.

OpenSearch Index Deletion Issue#

UPI channels dashboard data from 06:00 to 21:00 (17.06.2024) is missing. This issue affects the ability to monitor and analyze UPI transactions effectively.

RCA: Raw transaction indexes are created before the actual date (e.g., tomorrow’s index was created at today’s noon).

Due to this, ISM policies delete the index after 2 days from the creation date.

Solution :

  1. Investigate the abnormal behavior where data is unavailable until 5:30 AM.
  2. Increase the ISM policy to 4 days to ensure data retention.

    For Example:

    [root@localhost ~]# curl -Ss -ku admin:<admin-password> https://203.0.113.5:9200/heal_raw_txn_app_2024.06.25/_settings | jq
    {
         "heal_raw_txn_app_2024.06.25": {
           "settings": {
             "index": {
               "codec": "best_compression",
               "routing": {
                            "allocation": {
                              "require": {
                                "zone": "txn"
                              }
                            }
                       },
                       "mapping": {
                          "total_fields": {
                            "limit": "10000"
                          }
                       },
                       "refresh_interval": "1s",
                       "number_of_shards": "3",
                       "translog": {
                          "sync_interval": "60s"
    
                     },
                     "provided_name": "heal_raw_txn_app_2024.06.25",
                     "merge": {
                        "scheduler": {
                          "max_thread_count": "1"
                          }
          },
          "creation_date": "1719230782158",               ====> creation time is
  backdated
          "number_of_replicas": "0",
                     "uuid": "_z3ASsbbRO2Ybs7YBaf4cA",
                     "version": {
                       "created": "135248427"
                     }
                 }
            }
  }