SaevOps
[ELK] ElasticSearch 설치 본문
반응형
helm 설치
curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3
chmod 700 get_helm.sh
./get_helm.sh
- k8s 이미지 저장소인 helm을 통하여 편하고 쉽게 Elastic Search 설치
Elastic Search 설치
# 헬름 레포지토리 추가
helm repo add bitnami https://charts.bitnami.com/bitnami
# 헬름 레포지토리 업데이트
helm repo update
# elasticsearch 설치가능 버전 확인
helm search repo -l bitnami/elasticsearch | head
# values.yaml 파일 다운로드
wget https://raw.githubusercontent.com/bitnami/charts/master/bitnami/elasticsearch/values.yaml
# wget 명령어 없을시
yum install -y wget
네임스페이스 생성 / 쿠버네티스에 설치
# elk 라는 이름의 네임스페이스 생성
kubectl create namespace elk
# helm을 이용하여 values.yaml파일을 기반으로 elasticsearch 설치
# myapp이라는 이름의 애플리케이션 생성
helm install myapp -f values.yaml --set sysctlImage.enabled=true -n elk bitnami/elasticsearch
정상 설치시 뜨는 코드
[root@m-k8s ~]# helm install myapp -f values.yaml --set sysctlImage.enabled=true -n elk bitnami/elasticsearch
NAME: myapp
LAST DEPLOYED: Wed Sep 27 11:40:31 2023
NAMESPACE: elk
STATUS: deployed
REVISION: 1
TEST SUITE: None
NOTES:
CHART NAME: elasticsearch
CHART VERSION: 19.11.3
APP VERSION: 8.10.0
-------------------------------------------------------------------------------
WARNING
Elasticsearch requires some changes in the kernel of the host machine to
work as expected. If those values are not set in the underlying operating
system, the ES containers fail to boot with ERROR messages.
More information about these requirements can be found in the links below:
https://www.elastic.co/guide/en/elasticsearch/reference/current/file-descriptors.html
https://www.elastic.co/guide/en/elasticsearch/reference/current/vm-max-map-count.html
This chart uses a privileged initContainer to change those settings in the Kernel
by running: sysctl -w vm.max_map_count=262144 && sysctl -w fs.file-max=65536
** Please be patient while the chart is being deployed **
Elasticsearch can be accessed within the cluster on port 9200 at myapp-elasticsearch.elk.svc.cluster.local
To access from outside the cluster execute the following commands:
kubectl port-forward --namespace elk svc/myapp-elasticsearch 9200:9200 &
curl http://127.0.0.1:9200/
파드 상태 확인
[root@m-k8s ~]# kubectl get pod -n elk
NAME READY STATUS RESTARTS AGE
myapp-elasticsearch-coordinating-0 0/1 Running 0 5m4s
myapp-elasticsearch-coordinating-1 0/1 Running 0 5m3s
myapp-elasticsearch-data-0 0/1 Pending 0 5m3s
myapp-elasticsearch-data-1 0/1 Pending 0 5m3s
myapp-elasticsearch-ingest-0 0/1 Running 0 5m4s
myapp-elasticsearch-ingest-1 0/1 Running 0 5m3s
myapp-elasticsearch-master-0 0/1 Pending 0 5m3s
myapp-elasticsearch-master-1 0/1 Pending 0 5m3s
포트 포워딩
kubectl port-forward --namespace elk svc/myapp-elasticsearch 9200:9200
Forwarding from 127.0.0.1:9200 -> 9200
포트포워딩 및 정상 작동 확인
# 백그라운드로 포트 포워딩
[root@m-k8s ~]# kubectl port-forward -n elk svc/myapp-elasticsearch 9200:9200 &
[1] 26671
[root@m-k8s ~]# Forwarding from 127.0.0.1:9200 -> 9200
# 정상 작동 확인 / 에러발생코드 -> 수정중
[root@m-k8s ~]# curl localhost:9200
Handling connection for 9200
E0927 11:59:37.173811 26671 portforward.go:400] an error occurred forwarding 9200 -> 9200: error forwarding port 9200 to pod 17d1cbe2c07b702f50079c6cd8a17811dd1380dd03b43a2708af119f2aa6f51a, uid : exit status 1: 2023/09/27 11:59:37 socat[11507] E connect(5, AF=2 127.0.0.1:9200, 16): Connection refused
curl: (52) Empty reply from server
에러 원인분석
에러 메시지 출력을 보면 pv가 정상적으로 연결되지 않아 생긴 문제로 보인다.
yaml 파일을 수정하여 노드 개수에 맞게 설정하면 될 것 같으나, 여러가지 시도해봐도 정상적으로 되지 않는다.
- 좀 더 추가적으로 테스트 후 글 완성 할 것 (2023.10.17)
반응형
'클라우드 > Kubernetes' 카테고리의 다른 글
[RKE2] KTCloud 서버 ElasticSearch 설치 (1) | 2024.12.31 |
---|---|
[k8s] Kubernetes에 ELK(Elasticsearch+Kibana) 구축하기 (2) | 2024.03.27 |
[k8s] 명령어 자동 완성 / 별칭 / 약어 정리 (0) | 2023.02.16 |
[OCI] OKE 구성 (0) | 2022.11.25 |
[쿠버네티스] 아키텍처 및 구성도 (0) | 2022.11.23 |
Comments