본문 바로가기
Data/ELK

[2021.09.09] How to change the elastic cluster status from yellow to green?

by injekim97 2021. 9. 9.
반응형

[2021.09.09] How to change the elastic cluster status from yellow to green?  

 

 

 

해당 게시글은, elasticsearch를 실행한 상태에서, 상태 조회(아래 화면)를 하였을 때, yellow를 green으로 바꿔주기 위해 작성하였다.

 

 

curl -XGET -u admin:admin12 http://localhost:9200/_cluster/health?pretty

-> xpack을 사용하면 위와 같은 명령어를 사용해줘야 한다

 

 

curl -XGET http://localhost:9200/_cluster/health?pretty

-> xpack을 사용하지 않을 때 사용하면 된다.

 

 

ubuntu@ip-172-31-5-244:/usr/share/elasticsearch/bin$ curl -XGET -u admin:admin12 http://localhost:9200/_cluster/health?pretty
{
  "cluster_name" : "elasticsearch",
  "status" : "yellow",
  "timed_out" : false,
  "number_of_nodes" : 1,
  "number_of_data_nodes" : 1,
  "active_primary_shards" : 28,
  "active_shards" : 28,
  "relocating_shards" : 0,
  "initializing_shards" : 0,
  "unassigned_shards" : 16,
  "delayed_unassigned_shards" : 0,
  "number_of_pending_tasks" : 0,
  "number_of_in_flight_fetch" : 0,
  "task_max_waiting_in_queue_millis" : 0,
  "active_shards_percent_as_number" : 63.63636363636363
}

-> 보면 현재 status 상태가 yellow 이다. 이것을 green으로 바꿔보자

 

 

 

yellow -> green 으로 바꿔주기 위한 해결 명령어

curl -XPUT -u admin:admin12 'http://localhost:9200/_settings?pretty' -d '{"index":{"number_of_replicas": 0}}' -H 'Content-Type: application/json'

ubuntu@ip-172-31-5-244:/usr/share/elasticsearch/bin$ curl -XPUT -u admin:admin12 'http://localhost:9200/_settings?pretty' -d '{"index":{"number_of_replicas": 0}}' -H 'Content-Type: application/json'
{
  "acknowledged" : true
}

 

 

 

해당 명령어를 통해 status 가 yellow -> green 으로 변경되었다.

ubuntu@ip-172-31-5-244:/usr/share/elasticsearch/bin$ curl -XGET -u admin:admin12 http://localhost:9200/_cluster/health?pretty
{
  "cluster_name" : "elasticsearch",
  "status" : "green",
  "timed_out" : false,
  "number_of_nodes" : 1,
  "number_of_data_nodes" : 1,
  "active_primary_shards" : 28,
  "active_shards" : 28,
  "relocating_shards" : 0,
  "initializing_shards" : 0,
  "unassigned_shards" : 0,
  "delayed_unassigned_shards" : 0,
  "number_of_pending_tasks" : 0,
  "number_of_in_flight_fetch" : 0,
  "task_max_waiting_in_queue_millis" : 0,
  "active_shards_percent_as_number" : 100.0
}
반응형

댓글