티스토리 뷰

Study

Elasticsearch(엘라스틱서치) 관련

메디츠 2024. 2. 18. 09:56
반응형

17년 7월 기준.

 

Logstash

// 입출력 도구. input > filter > output의 pipeline구조

 

wget https://artifacts.elastic.co/downloads/logstash/logstash-5.4.3.tar.gz

// wget 다운

tar -xvzf logstash-5.4.3.tar.gz

// 압축 풀기

 

bin/logstash -f userconf/logstash.conf

// 시작. root로 실행해야 함.

--config.reload.automatic

// 설정파일 변경시 자동 적용

 

logstash.conf

input {

stdin {

codec => json

}

}

 

output {

#elasticsearch {

# index => "test"

#}

stdout {

codec => rubydebug { }

}

}

// index로 index pattern 설정

 

Elasticsearch

http://192.168.100.239:9200/

 

[1]: max file descriptors [4096] for elasticsearch process is too low, increase to at least [65536]

[2]: max number of threads [1024] for user [elasticsearch] is too low, increase to at least [2048]

// ulimit으로 max file, max number of threads을 늘려야 한다

 

[1]: max number of threads [1024] for user [elasticsearch] is too low, increase to at least [2048]

ulimit -u 2048

[2]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]

sysctl -w vm.max_map_count=262144

[3]: system call filters failed to install; check the logs and fix your configuration or disable system call filters at your own risk

// root로 설정후에 elasticsearch 로그인. ulimit은 user별 설정이기 때문에 elasticsearch에서 설정.

 

/etc/security/limits.conf

* hard nofile 65536

// limit conf 자체를 설정

 

wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-5.4.3.tar.gz

// wget으로 다운

 

head, bigdesk 플러그인 사용 불가

// X-Pack으로 대체

 

bin/elasticsearch

// elasticsearch 실행. java 1.8 필요. elasticsearch계정 필요.

 

config/elasticsearch.yml

network.host: 0.0.0.0

// 외부에서 접속 가능하게 설정.

cluster.name: es-cluster

node.name: es-node-1

unable to install syscall filter

// CentOS 6 버전 seccomp 미지원 문제. config/elasticsearch.yml에 bootstrap.system_call_filter: false

action.auto_create_index: .security,.monitoring*,.watches,.triggered_watches,.watcher-history*

// 인덱스 자동생성 설정

 

logs/elasticsearch.log

// 로그 경로

 

curl -XPUT http://localhost:9200/log-2017-07-07/hadoop/1

curl -XGET http://localhost:9200/log-2017-07-07/hadoop/1

curl -XDELETE http://localhost:9200/log-2017-07-07/hadoop/1

// 생성, 확인, 삭제

 

curl -XGET http://localhost:9200/log-2017-07-07/hadoop/_search

curl -XGET http://localhost:9200/log-2017-07-07/_search

curl -XGET http://localhost:9200/_search

// 검색

 

curl -XGET http://localhost:9200/log-2017-07-07/_status

// 상태

 

--user elastic:changeme

// 계정정보 추가

 

curl --user elastic:changeme -XPUT http://localhost:9200/log-2017-07-07/hadoop/1 -d '{ "projectName" : "hadoop", "logType": "hadoop-log", "logSource": "namenode", "logTime":"2017-07-07T02:33:02", "host": "host1", "body": "org.apache.hadoop.hdfs.server.namenode.FSNamesystem" }'

 

http://192.168.100.74:9200/log-2017-07-07/_search?pretty

// ?pretty를 사용하면 보기좋게 보여줌

http://192.168.100.74:9200/log-2017-07-07/_search?pretty&format=yaml

// yaml포맷으로 가져옴

 

Kibana

http://192.168.100.239:5601/

 

wget https://artifacts.elastic.co/downloads/kibana/kibana-5.4.3-linux-x86_64.tar.gz

// wget

 

config/kibana.yml

server.host: "192.168.100.74"

// server host 설정.

elasticsearch.url: "http://192.168.100.74:9200"

// 디폴트 localhost

 

bin/kibana

// 실행

 

Management-Advanced Settings-dateFormat:tz에서 timezone 설정.

 

X-Pack

bin/elasticsearch-plugin install x-pack

// elasticsearch에 x-pack 설치

bin/elasticsearch

// elasticsearch 실행

bin/kibana-plugin install x-pack

// kibana에 x-pack 설치

bin/kibana

// kibana 실행

 

elastic/changeme

// elasticsearch 인증 필요.

 

config/kibana.yml

elasticsearch.username: "test"

elasticsearch.password: "test"

// kibana 인증. 필요시 설정.

 

bin/x-pack/useradd test -r admin

// user 추가

bin/x-pack/users list

// user 확인

 

bin/elasticsearch-plugin list

// 플러그인 확인

 

bin/elasticsearch-plugin remove x-pack

// 플러그인 삭제

 

kibana Elasticsearch is still initializing the kibana index

// curl -XDELETE http://localhost:9200/.kibana 실행.

 

Index Patterns의 Time-field 활성화

// kibana 계정은 Administrator가 아니므로 설정이 안됨. elastic으로 로그인해서 설정.

 

Filebeat

// logstash forwarder(deprecated) 의 경량(lightweight) 버전

wget https://artifacts.elastic.co/downloads/beats/filebeat/filebeat-5.5.0-linux-x86_64.tar.gz

tar -xvzf filebeat-5.5.0-linux-x86_64.tar.gz

Edit the filebeat.yml configuration file

- input_type: log

# Paths that should be crawled and fetched. Glob based paths.

paths:

- /usr/local/etc/calllog/*.log

#output.elasticsearch:

# Array of hosts to connect to.

#hosts: ["localhost:9200"]

output.logstash:

# The Logstash hosts

hosts: ["192.168.100.239:5044"]

sudo ./filebeat -e -c filebeat.yml

// filebeat 시작

logstash.conf

input {

beats {

port => 5044

}

}

 

kibana로 다른 서버 연결

192.168.100.239 kibana에서 192.168.100.74 elasticsearch 연결

server.host: "192.168.100.239"

// 서비스하는 포트이므로 그대로 설정.

elasticsearch.url: "http://192.168.100.74:9200"

// 74번의 elasticsearch를 설정

elasticsearch.username: "elastic"

elasticsearch.password: "changeme"

// 74번에 인증을 위해 인증정보 삽입. x-pack설치시 로그인으로 대체가능.

 

Error: listen EADDRNOTAVAIL 192.168.100.74:5601

// server.host를 listen하는 것으로 설정했을때 에러. 서비스포트이며, elastic.url을 설정해야 한다.

 

74번의 elasticsearch에 있던 Index Patterns으로 설정되어있다. 관련 설정은 elasticsearch에 종속되는 것으로 보인다. kibana는 단지 보여주기만 하며, 관련 설정을 저장하지 않는 듯 하다.

 

Curator

index 관리 툴

 

반응형
댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
TAG
more
«   2025/05   »
1 2 3
4 5 6 7 8 9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28 29 30 31
글 보관함