Restoring Green Status to Elasticsearch/Opensearch health checks in a vRealize Automation 7.x Single node or Multi-Node Cluster
- SSH into the master vRealize Automation appliance.
- Determine current health status:
curl http://localhost:9200/_cluster/health?pretty=true
Example:
{"cluster_name" : "horizon",
"status" : "red",
"timed_out" : false,
"number_of_nodes" : 1,
"number_of_data_nodes" : 1,
"active_primary_shards" : 10,
"active_shards" : 10,
"relocating_shards" : 0,
"initializing_shards" : 0,
"unassigned_shards" : 10,
"delayed_unassigned_shards" : 0,
"number_of_pending_tasks" : 0,
"number_of_in_flight_fetch" : 0}
Note: In the above command output, Elasticsearch/Opensearch cluster status can be: Red, Yellow, Green.
The health status will flag as Red, if there are a number of UNASSIGNED shards within the cluster.
Note: Elasticsearch/Opensearch logs are located at /opt/vmware/elasticsearch/logs/horizon.log
- Determine node name(s) registered within the cluster:
curl -s -XGET http://localhost:9200/_cat/nodes
Example: xxxx-xx-xx-xx.xx.xxx.com XX.0.0.XX X d * Red Skull II
- If the command output from step 2 details more than zero UNASSIGNED shards, curl for further details on ALL shards piped to only UNASSIGNED:
curl -XGET localhost:9200/_cat/shards?h=index,shard,prirep,state,unassigned.reason | grep UNASSIGNED
Example:
% Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed
100 980 100 980 0 0 54444 0 --:--:-- --:--:-- --:--:-- 54444
searchentities 2 r UNASSIGNED CLUSTER_RECOVERED
searchentities 0 r UNASSIGNED CLUSTER_RECOVERED
searchentities 3 r UNASSIGNED CLUSTER_RECOVERED
searchentities 1 r UNASSIGNED CLUSTER_RECOVERED
searchentities 4 r UNASSIGNED CLUSTER_RECOVERED
v3_2019-07-17 4 r UNASSIGNED INDEX_CREATED
v3_2019-07-17 0 r UNASSIGNED INDEX_CREATED
v3_2019-07-17 3 r UNASSIGNED INDEX_CREATED
v3_2019-07-17 1 r UNASSIGNED INDEX_CREATED
v3_2019-07-17 2 r UNASSIGNED INDEX_CREATED
- Determine if the UNASSIGNED shards can be assigned to another replica member with the Cluster Reroute function and allocate command:
curl -XPOST 'localhost:9200/_cluster/reroute' -d '{"commands":[{"allocate":{"index":"searchentities","shard":0,"node":"Red Skull II","allow_primary":"true"}}]}'
Note: The following response may occur if a valid copy of this shard already exists on the master:
shard cannot be allocated on same node [qAoqsUEITxuNbLXA6NASiA] it already exists on
- If shards are orphaned and cannot be rerouted, attempt to cancel the replica shard:
curl -XPOST 'localhost:9200/_cluster/reroute' -d '{"commands":[{"cancel":{"index":"searchentities","shard":0,"node":"Red Skull II","allow_primary":"true"}}]}'
- Determine if the UNASSIGNED shards fail to cancel and still persist by re-running Step #4.
- Continue to Step #9 only if there are UNASSIGNED shards after the previous Steps, #1-6.
- If the shards persist, delete them:
Note: The below command will DELETE all UNASSIGNED shards from the Elasticsearch/Opensearch cluster. It is recommended to first reallocate or cancel them first.
curl -XGET http://localhost:9200/_cat/shards | grep UNASSIGNED | awk {'print $1'} | xargs -i curl -XDELETE "http://localhost:9200/{}"
- Verify that all UNASSIGNED shards have been deleted by rerunning Step #4.
Example:
% Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
- Validate status returns "green":
curl http://localhost:9200/_cluster/health?pretty=true
Note: The output should be showing 0 value for unassigned shards
Example:
{
"cluster_name" : "horizon",
"status" : "green",
"timed_out" : false,
"number_of_nodes" : 1,
"number_of_data_nodes" : 1,
"active_primary_shards" : 0,
"active_shards" : 0,
"relocating_shards" : 0,
"initializing_shards" : 0,
"unassigned_shards" : 0,
"delayed_unassigned_shards" : 0,
"number_of_pending_tasks" : 0,
"number_of_in_flight_fetch" : 0
}