본문 바로가기
WIKI 기술 지식 베이스

OpenSearch CLI

원문 보기 위키 갱신

출처: 문서

본문

OpenSearch CLI

OpenSearch CLI 명령줄 인터페이스(opensearch-cli)를 사용하면 명령줄에서 OpenSearch 클러스터를 관리하고 작업을 자동화할 수 있어요.

opensearch-cli는 Anomaly Detection 플러그인과 k-NN 플러그인, 그리고 임의의 REST API 경로를 지원해요. 이 외에도 opensearch-cli를 사용해 detector를 생성·삭제하고, 시작·중지하며, k-NN 통계를 확인할 수 있어요.

프로파일을 사용하면 다른 클러스터에 쉽게 접근하거나 서로 다른 자격 증명으로 요청에 서명할 수 있어요. opensearch-cli는 인증되지 않은 요청, HTTP basic 서명, Amazon Web Services용 IAM 서명을 지원해요.

다음 예제는 detector(ecommerce-count-quantity)를 스테이징 클러스터에서 프로덕션 클러스터로 옮기는 방법이에요:

opensearch-cli ad get ecommerce-count-quantity --profile staging > ecommerce-count-quantity.json
opensearch-cli ad create ecommerce-count-quantity.json --profile production
opensearch-cli ad start ecommerce-count-quantity.json --profile production
opensearch-cli ad stop ecommerce-count-quantity --profile staging
opensearch-cli ad delete ecommerce-count-quantity --profile staging

설치

  1. 컴퓨터에 맞는 설치 패키지를 다운로드{:target='_blank'}하고 압축을 풀어요.

  2. opensearch-cli 파일을 실행 가능한 상태로 만들어요:

    chmod +x ./opensearch-cli
    
  3. 명령어를 경로에 추가해요:

    export PATH=$PATH:$(pwd)
    
  4. CLI가 제대로 작동하는지 확인해요:

    opensearch-cli --version
    

프로파일

프로파일을 사용하면 서로 다른 클러스터와 사용자 자격 증명 사이를 쉽게 전환할 수 있어요. 시작하려면 --auth-type, --endpoint, --name 옵션과 함께 opensearch-cli profile create를 실행해요:

opensearch-cli profile create --auth-type basic --endpoint https://localhost:9200 --name docker-local

또는 설정 파일을 ~/.opensearch-cli/config.yaml에 저장해도 돼요:

profiles:
    - name: docker-local
      endpoint: https://localhost:9200
      user: admin
      password: foobar
    - name: aws
      endpoint: https://some-cluster.us-east-1.es.amazonaws.com
      aws_iam:
        profile: ""
        service: es

사용 방법

opensearch-cli 명령어는 다음 문법을 사용해요:

opensearch-cli <command> <subcommand> <flags>

예를 들어 다음 명령어는 detector에 대한 정보를 조회해요:

opensearch-cli ad get my-detector --profile docker-local

OpenSearch CAT API에 요청하려면 다음 명령어를 사용해 보세요:

opensearch-cli curl get --path _cat/plugins --profile aws

-h 또는 --help 플래그를 사용하면 지원되는 모든 명령어와 서브커맨드, 특정 명령어의 사용법을 확인할 수 있어요:

opensearch-cli -h
opensearch-cli ad -h
opensearch-cli ad get -h

더 알아보기 (Learn more)