mingming

ElaticSearch - cluster 설정 및 role 본문

ELK

ElaticSearch - cluster 설정 및 role

mingming_96 2023. 12. 9. 01:25

elasticsearch.yml 

Cluster

# ---------------------------------- Cluster -----------------------------------
#
# Use a descriptive name for your cluster:
#
#cluster.name: my-application
cluster.initial_master_nodes: ["node-1"]

cluster.name : ElasticSearch 클러스터를 식별하는데 사용되는 이름을 지정하는 필드입니다. 여러 클러스터를 운영중일 때 클러스터 이름으로 서로를 구분합니다. 

 

Node

# ------------------------------------ Node ------------------------------------
#
# Use a descriptive name for the node:
#
#node.name: node-1
#
# Add custom attributes to the node:
#
#node.attr.rack: r1
node.name: node-1

node.name : Elasticsearch 노드에 대한 고유한 이름을 지정하며, 클러스터 내에서 고유해야 합니다.

node.attr.rack : 해당 노드가 어떤 물리적인 위치에 위치해있는지 표시하는 속성입니다. 

 

Paths

# ----------------------------------- Paths ------------------------------------
#
# Path to directory where to store the data (separate multiple locations by comma):
#
path.data: /var/lib/elasticsearch
#
# Path to log files:
#
path.logs: /var/log/elasticsearch

path.data : 실제 데이터를 저장할 디렉터리의 경로를 지정합니다. 

path.logs : Elasticsesarch의 로그 파일이 기록될 경로를 지정합니다.

 

Memory

# ----------------------------------- Memory -----------------------------------
#
# Lock the memory on startup:
#
#bootstrap.memory_lock: true
#
# Make sure that the heap size is set to about half the memory available
# on the system and that the owner of the process is allowed to use this
# limit.
#
# Elasticsearch performs poorly when the system is swapping the memory.

bootstrap.memory_lock : Elasitcsesarch가 사용하는 메모리가 스왑으로 이동하지 못하도록 Lock을 수행하는 옵션입니다. 

 

Network

# ---------------------------------- Network -----------------------------------
#
# Set the bind address to a specific IP (IPv4 or IPv6):
#
network.host: 0.0.0.0
#
# Set a custom port for HTTP:
#
#http.port: 9200
#
# For more information, consult the network module documentation.

network.host : Elasticsearch가 바인딩할 네트워크 인터페이스 주소입니다. 0.0.0.0 으로 설정할 경우 모든 네트워크 인터페이스를 통해 들어오는 연결을 수락하도록 합니다. 

http.port : Elasticsesarch HTTP API 가 리스닝하는 포트를 지정합니다. 기본적으로 9200 포트를 사용하도록 되어 있습니다.

 

Discovery

# --------------------------------- Discovery ----------------------------------
#
# Pass an initial list of hosts to perform discovery when this node is started:
# The default list of hosts is ["127.0.0.1", "[::1]"]
#
#discovery.seed_hosts: ["host1", "host2"]
#
# Bootstrap the cluster using an initial set of master-eligible nodes:
#
#cluster.initial_master_nodes: ["node-1", "node-2"]
#
# For more information, consult the discovery and cluster formation module documentation.

discovery.seed_hosts : Elasticsearch 클러스터가 해당 목록에 있는 호스트를 발견하고 클러스터에 조인시킵니다.

cluster.initial_master_nodes : 클러스터의 초기 마스터노드를 설정하는 부분입니다. 마스터 후보들의 리스트를 정의합니다. 만약 마스터노드가 다운되면 리스트에 있는 노드가 그 역할을 대신 수행합니다. 

 

Gateway

# ---------------------------------- Gateway -----------------------------------
#
# Block initial recovery after a full cluster restart until N nodes are started:
#
#gateway.recover_after_nodes: 3
#
# For more information, consult the gateway module documentation.

gateway.recover_after_nodes : 전체 클러스터가 복구되기전에 기다려야 하는 노드의 최소 개수를 지정합니다. 일반적으로 전체 노드의 개수의 절반값으로 설정합니다. 

 

roles.yaml

─
   1   │ # The default roles file is empty as the preferred method of defining roles is
   2   │ # through the API/UI. File based roles are useful in error scenarios when the
   3   │ # API based roles may not be available.

 

Elasticsearch 에서 롤을 정의하는 방법에대해 정의하고 있습니다. 기본적인 롤 파일은 비어있으며 권한 설정을 위해선 API 혹은 UI 를 통해 롤을 정의하는 것이라고 설명합니다. 

 

role 정의

role 은 json 형태로 구성되어 있습니다. 

{
  "run_as": [ ... ], 
  "cluster": [ ... ], 
  "global": { ... }, 
  "indices": [ ... ], 
  "applications": [ ... ], 
  "remote_indices": [ ... ] 
}

 

run_as : 특정 role을 소유한 사용자가 다른 사용자로서 행동할 수 있는 권한을 제공하는 설정입니다. 

cluster : cluster 수준의 권한을 정의합니다. 수행 가능한 작업과 권한을 설정합니다. 

global : global 권한은 일반적인 cluster 권한과 달리 요청안에 있는 매개변수 까지 고려하여 인가를 결정합니다.  

indices : index 수준의 권한을 지정합니다. 만약 값을 설정하지 않는다면 어떤 권한도 적용되지 않습니다.

applications : 어플리케이션 수준의 권한을 관리하는 필드입니다. ~> 사실 뭔지 잘 모르겠습니당,, 

remote_indices : API 키 기반 모델로 구성된 원격 클러스터의 인덱스에 대한 권한을 지정합니다. 

 

Incides Privileges 

Incides Privileges 는 다음과 같은 구조로 되어있습니다. 

{
  "names": [ ... ], 
  "privileges": [ ... ], 
  "field_security" : { ... }, 
  "query": "...", 
  "allow_restricted_indices": false 
}

names : 권한이 적용 될 데이터 스트림, 인덱스 및 별칭의 리스트 입니다. 

privileges : names 필드에 정의된 리스트에 적용될 인덱스수준의 권한입니다.  | read, write, execute, delete 

field_security : filed 보안에 관한 설정을 지정합니다.

query : 특정 역할의 소유자들이 읽기 엑세스 권한을 가진 문서들을 정의하는 검색 쿼리에 관한 필드 입니다.

 

EXAMPLE 

역을 생성하는 요청을 하는 API 요청의 예시입니다.

curl -X POST "localhost:9200/_security/role/clicks_admin?pretty" -H 'Content-Type: application/json' -d'
{
  "run_as": [ "clicks_watcher_1" ],
  "cluster": [ "monitor" ],
  "indices": [
    {
      "names": [ "events-*" ],
      "privileges": [ "read" ],
      "field_security" : {
        "grant" : [ "category", "@timestamp", "message" ]
      },
      "query": "{\"match\": {\"category\": \"click\"}}"
    }
  ]
}
'

 

 

 

 

'ELK' 카테고리의 다른 글

Apache Tomcat & ELK Stack  (1) 2024.02.08
ElasticSearch - REST API  (1) 2023.12.09
ELK on Kubernetes - Kibana  (0) 2023.12.07
ELK on Kubernetes - Logstash  (4) 2023.12.07
ELK on Kubernetes - ElasticSearch  (2) 2023.12.06