# ELK란
ELK란 Elasticsearch + Logstash + Kibana 를 통한 모니터링을 뜻합니다.
보통 일반적으로 구조한다면 위와같은 구조로 진행하게 됩니다.
저는 아주 기본적으로 설치해보고 설정하는 작업을 진행해볼 예정입니다.
설치 진행은 elasticsearch - kibana - logstash - filebeat 순으로 진행할 예정입니다.
기본설치이므로 공식홈페이지를 참조해서 설치 진행하셔도 무방합니다.
Elasticsearch rpm 설치 공홈
https://www.elastic.co/guide/en/elasticsearch/reference/current/install-elasticsearch.html
Installing Elasticsearch | Elasticsearch Guide [8.12] | Elastic
To try out Elasticsearch on your own machine, we recommend using Docker and running both Elasticsearch and Kibana. For more information, see Run Elasticsearch locally.
www.elastic.co
Kibana rpm 설치 공홈
https://www.elastic.co/guide/en/kibana/current/rpm.html
Install Kibana with RPM | Kibana Guide [8.12] | Elastic
Install Kibana with RPMedit The RPM for Kibana can be downloaded from our website or from our RPM repository. It can be used to install Kibana on any RPM-based system such as OpenSuSE, SLES, Red Hat, and Oracle Enterprise. This package contains both free a
www.elastic.co
# 환경
AWS - EC2 2대
OS - Rocky Linux release 8.9 (Green Obsidian)
elasticsearch - elasticsearch-8.12.2-1.x86_64
kibana - kibana-8.12.2-1.x86_64
logstash - logstash-8.12.2-1.x86_64
filebeat - filebeat-8.12.2-1.x86_64
# ElasticSearch + Kibana 설치
ElasticSearch 설치
- GPG key 가져오기
# rpm --import https://artifacts.elastic.co/GPG-KEY-elasticsearch
- repository 등록
# vi /etc/yum.repos.d/elasticsearch.repo
[elasticsearch]
name=Elasticsearch repository for 8.x packages
baseurl=https://artifacts.elastic.co/packages/8.x/yum
gpgcheck=1
gpgkey=https://artifacts.elastic.co/GPG-KEY-elasticsearch
enabled=0
autorefresh=1
type=rpm-md
- elasticsearch 설치
# dnf install --enablerepo=elasticsearch elasticsearch
- elasticsearch.yml
# cat /etc/elasticsearch/elasticsearch.yml
path.data: /var/lib/elasticsearch
path.logs: /var/log/elasticsearch
xpack.security.enabled: true
xpack.security.enrollment.enabled: true
xpack.security.http.ssl:
enabled: true
keystore.path: certs/http.p12
xpack.security.transport.ssl:
enabled: true
verification_mode: certificate
keystore.path: certs/transport.p12
truststore.path: certs/transport.p12
cluster.initial_master_nodes: ["ec2_host_name"]
http.host: 0.0.0.0
path.data : data 저장 경로
path.logs : log 저장 경로
xpack.security.enabled : xpack.security를 활성화 할건지 여부 설정
xpack.security.enrollment.enabled : 클러스터에 노드를 등록하기 위한 보안 등록 활성화
xpack.security.http.ssl : http 통신에 ssl 설정
xpack.security.transport.ssl : 노드간 통신에 대한 SSL 설정
cluster.initial_master_nodes : 클러스터의 초기 마스터 노드 지정
http.host : http 접근을 허용할 ip (0.0.0.0 or 123.123.123.123) 전체 열거나 or ip 1개만 지정하거나 밖에 안됨.
위 설정들은 기본설정에 대한 값이므로 추가적으로 클러스터 구성할시 아래와 같은 설정을 할수도 있다.
조만간 알려줌
- elasticsearch 시작
systemctl start elasticsearch
- elastic 계정 패스워드 설정
/usr/share/elasticsearch/bin/elasticsearch-reset-password -u elastic -i
- 설치 확인
curl --cacert "ca인증서경로" -u 계정:계정패스워드 https://[ip or localhost]:9200
ex)
# curl --cacert /etc/elasticsearch/certs/http_ca.crt -u elastic:asdfqwer1234 https://localhost:9200
{
"name" : "ip-172-31-28-41.ap-northeast-2.compute.internal",
"cluster_name" : "elasticsearch",
"cluster_uuid" : "F6xRGkkMSmWtPboJKeztbg",
"version" : {
"number" : "8.12.2",
"build_flavor" : "default",
"build_type" : "rpm",
"build_hash" : "48a287ab9497e852de30327444b0809e55d46466",
"build_date" : "2024-02-19T10:04:32.774273190Z",
"build_snapshot" : false,
"lucene_version" : "9.9.2",
"minimum_wire_compatibility_version" : "7.17.0",
"minimum_index_compatibility_version" : "7.0.0"
},
"tagline" : "You Know, for Search"
}
위와같이 나온다면 ElasticSearch 설치 성공!
Kibana 설치
- PGP key 가져오기
# rpm --import https://artifacts.elastic.co/GPG-KEY-elasticsearch
- yum repository 등록
# vi /etc/yum.repos.d/kibana.repo
[kibana-8.x]
name=Kibana repository for 8.x packages
baseurl=https://artifacts.elastic.co/packages/8.x/yum
gpgcheck=1
gpgkey=https://artifacts.elastic.co/GPG-KEY-elasticsearch
enabled=1
autorefresh=1
type=rpm-md
- kibana 설치
dnf install kibana
- kibana.yml
server.port: 5601 # 주석제거
server.host: "0.0.0.0" # 주석제거 및 수정
logging:
appenders:
file:
type: file
fileName: /var/log/kibana/kibana.log
layout:
type: json
root:
appenders:
- default
- file
pid.file: /run/kibana/kibana.pid
server.port : 포트 지정
server.host : 접근을 허용할 ip 지정
- kibana 실행
systemctl start kibana
- kibana web 접근
http://[IP or 도메인]:5601
ex) http://15.165.15.16:5601/
- elasticsearch 서버 에서 kibana 토큰 생성
# /usr/share/elasticsearch/bin/elasticsearch-create-enrollment-token -s kibana
eyJ2ZXIiOiI4LjEyLjIiLCJhZHIiOlsiMTcyLjMxLjMuMjI5OjkyMDAiXSwiZmdyIjoiYjczNTQzYjI4MDIxNDQ5YmY2MDBjYThkYmVlODg4ZjIyMTUyZGY1MTk1NTFkZDk1NDlkYjVkZGU3YzU1Mzg0OSIsImtleSI6Iklib2ZGbzRCdVduX2tIR3J4Vmh2OlJKaDFQV0tzUjJXZU5HR3Vid3VpWEEifQ==
- 추출한 토큰값 입력
- kibana 서버 에서 verification-code 추출
# /usr/share/kibana/bin/kibana-verification-code
Your verification code is: 283 795
- 설치 진행
- 설치 완료 및 elastic 계정으로 로그인
- Kibana 설치 완료
위 작업으로 Elasticsearch와 kibana 설치가 완료되었습니다.
이후 Logstash와 filebeat 관련하여 가이드 하도록하겠습니다!
감사합니다.
'AWS > EC2' 카테고리의 다른 글
ELK(Elasticsearch + Logstash + Kibana + Filebeat)로그 모니터링 - 3 (0) | 2024.03.25 |
---|---|
ELK(Elasticsearch + Logstash + Kibana + Filebeat)로그 모니터링 - 2 (0) | 2024.03.25 |
Kibana process does not have enough permissions to write to config file (0) | 2024.02.28 |
ERROR: Failed to determine the health of the cluster. Unexpected http status [503], with exit code 65 (0) | 2024.02.21 |
EC2 키 페어 관리 (0) | 2024.02.01 |