반응형
Elasticsearch와 Kibana를 Docker를 사용하여 single-node로 실행하는 방법
1. Docker 설치
Docker를 설치합니다. Docker를 설치하려면 Docker 공식 웹사이트에서 설치 지침을 따릅니다.
2. Elasticsearch Docker 컨테이너 실행
Elasticsearch를 실행하는 Docker 컨테이너를 실행합니다.
docker run -d --name elasticsearch --net esnet -p 9200:9200 -p 9300:9300 -e ES_JAVA_OPTS="-Xms1g -Xmx1g" docker.elastic.co/elasticsearch/elasticsearch:8.2.1; docker logs -f elasticsearch
Elasticsearch 컨테이너 진입
docker exec -it elasticsearch bash
elastic 사용자의 비밀번호 변경
bin/elasticsearch-reset-password -u elastic
elasticsearch@80e1f1b11d73:~$ bin/elasticsearch-reset-password -u elastic
WARNING: Owner of file [/usr/share/elasticsearch/config/users] used to be [root], but now is [elasticsearch]
WARNING: Owner of file [/usr/share/elasticsearch/config/users_roles] used to be [root], but now is [elasticsearch]
This tool will reset the password of the [elastic] user to an autogenerated value.
The password will be printed in the console.
Please confirm that you would like to continue [y/N]y
Password for the [elastic] user successfully reset.
New value: YKZ8+3xdcrXmYtniNa8C
Elasticsearch 정보 확인
curl -Ss --insecure -u elastic:YKZ8+3xdcrXmYtniNa8C https://localhost:9200 | jq .
$ curl -Ss --insecure -u elastic:YKZ8+3xdcrXmYtniNa8C https://localhost:9200 | jq .
{
"name": "80e1f1b11d73",
"cluster_name": "docker-cluster",
"cluster_uuid": "KCKYA0XuSmyQUqlIAWtbww",
"version": {
"number": "8.2.1",
"build_flavor": "default",
"build_type": "docker",
"build_hash": "db223507a0bd08f8e84a93e329764cc39b0043b9",
"build_date": "2022-05-19T16:34:08.043347449Z",
"build_snapshot": false,
"lucene_version": "9.1.0",
"minimum_wire_compatibility_version": "7.17.0",
"minimum_index_compatibility_version": "7.0.0"
},
"tagline": "You Know, for Search"
}
ca 인증서 복사(Elasticsearch 컨테이너에서 로컬 호스트로 복사)
docker cp elasticsearch:/usr/share/elasticsearch/config/certs/http_ca.crt .
$ ls -l http_ca.crt
-rw-rw---- 1 root root 1915 May 26 20:13 http_ca.crt
인증서를 이용하여 Elasticsearch 정보 확인
curl -Ss -XGET --cacert ./http_ca.crt -u elastic:YKZ8+3xdcrXmYtniNa8C https://localhost:9200 | jq .
$ curl -Ss -XGET --cacert ./http_ca.crt -u elastic:YKZ8+3xdcrXmYtniNa8C https://localhost:9200 | jq .
{
"name": "80e1f1b11d73",
"cluster_name": "docker-cluster",
"cluster_uuid": "KCKYA0XuSmyQUqlIAWtbww",
"version": {
"number": "8.2.1",
"build_flavor": "default",
"build_type": "docker",
"build_hash": "db223507a0bd08f8e84a93e329764cc39b0043b9",
"build_date": "2022-05-19T16:34:08.043347449Z",
"build_snapshot": false,
"lucene_version": "9.1.0",
"minimum_wire_compatibility_version": "7.17.0",
"minimum_index_compatibility_version": "7.0.0"
},
"tagline": "You Know, for Search"
}
Elasticsearch node 확인
curl --insecure --user elastic:YKZ8+3xdcrXmYtniNa8C https://localhost:9200/_cat/nodes
$ curl --insecure --user elastic:YKZ8+3xdcrXmYtniNa8C https://localhost:9200/_cat/nodes
192.168.160.2 55 69 2 0.01 0.26 0.26 cdfhilmrstw * 80e1f1b11d73
3. Kibana Docker 컨테이너 실행
Kibana를 실행하는 Docker 컨테이너를 실행합니다.
docker run -d --add-host="kibana.sangchul.kr:11.11.11.22" -e SERVER_PUBLICBASE_URL="http://kibana.sangchul.kr:5601" --name kibana --net esnet -p 5601:5601 docker.elastic.co/kibana/kibana:8.2.1
Kibana 컨테이너의 로그 확인
docker logs -f kibana
$ docker logs -f kibana
[2022-05-26T11:19:41.339+00:00][INFO ][plugins-service] Plugin "cloudSecurityPosture" is disabled.
[2022-05-26T11:19:41.370+00:00][INFO ][plugins-service] Plugin "metricsEntities" is disabled.
[2022-05-26T11:19:41.487+00:00][INFO ][http.server.Preboot] http server running at http://0.0.0.0:5601
[2022-05-26T11:19:41.550+00:00][INFO ][plugins-system.preboot] Setting up [1] plugins: [interactiveSetup]
[2022-05-26T11:19:41.553+00:00][INFO ][preboot] "interactiveSetup" plugin is holding setup: Validating Elasticsearch connection configuration…
[2022-05-26T11:19:41.597+00:00][INFO ][root] Holding setup until preboot stage is completed.
i Kibana has not been configured.
Go to http://0.0.0.0:5601/?code=965875 to get started.
728x90
웹 브라우저 접속
http://kibana.sangchul.kr:5601/?code=965875
Elasticsearch 컨테이너 진입
docker exec -it elasticsearch bash
토큰 확인
bin/elasticsearch-create-enrollment-token -s kibana --url "https://localhost:9200"
elasticsearch@80e1f1b11d73:~$ bin/elasticsearch-create-enrollment-token -s kibana --url "https://localhost:9200"
eyJ2ZXIiOiI4LjIuMSIsImFkciI6WyIxOTIuMTY4LjE2MC4yOjkyMDAiXSwiZmdyIjoiNGYyZDVmM2Q2YWJiMzgwMzc4NWQ2MzI2YmFjOTZjYmRmNzc3MGRhYTkwYzg1MzNmOWI3Y2IxYmI1NzE2NzMxYiIsImtleSI6InZnNGJBSUVCbkNYLXZyMWMxbWJFOmIwNjA1TkM2UjlHYXhzUzFlWFltM3cifQ==
웹 브라우저 접속
kibana 컨테이너 로그 확인
docker logs -f kibana
$ docker logs -f kibana
[2022-05-26T11:19:41.339+00:00][INFO ][plugins-service] Plugin "cloudSecurityPosture" is disabled.
[2022-05-26T11:19:41.370+00:00][INFO ][plugins-service] Plugin "metricsEntities" is disabled.
[2022-05-26T11:19:41.487+00:00][INFO ][http.server.Preboot] http server running at http://0.0.0.0:5601
[2022-05-26T11:19:41.550+00:00][INFO ][plugins-system.preboot] Setting up [1] plugins: [interactiveSetup]
[2022-05-26T11:19:41.553+00:00][INFO ][preboot] "interactiveSetup" plugin is holding setup: Validating Elasticsearch connection configuration…
[2022-05-26T11:19:41.597+00:00][INFO ][root] Holding setup until preboot stage is completed.
i Kibana has not been configured.
Go to http://0.0.0.0:5601/?code=965875 to get started.
Your verification code is: 965 875
kibana 컨테이너 진입
docker exec -it kibana bash
코드 확인
bin/kibana-verification-code
kibana@4b76a98c53b7:~$ bin/kibana-verification-code
Your verification code is: 965 875
웹 브라우저 접속
웹 브라우저 접속
http://localhost:9200
- 참고
- Elasticsearch : http://localhost:9200를 사용하여 Elasticsearch에 액세스할 수 있습니다.
- Kibana : http://localhost:5601를 사용하여 Kibana에 액세스할 수 있습니다.
이제 Elasticsearch와 Kibana가 Docker 컨테이너에서 실행됩니다. Elasticsearch는 single-node로 설정되어 있으며, Kibana는 Elasticsearch와 연결되어 데이터 시각화 및 검색을 수행할 수 있습니다. 필요한 경우 버전 및 설정을 조정하여 Elasticsearch 및 Kibana를 사용자 정의할 수 있습니다.
728x90
반응형
'리눅스' 카테고리의 다른 글
mongodb와 mongo-express를 Docker Compose를 사용하여 실행하는 방법 (0) | 2022.06.09 |
---|---|
Elasticsearch 클러스터와 Kibana를 Docker를 사용하여 실행하는 방법(elasticsearch cluster) (0) | 2022.05.26 |
growpart 명령어 (0) | 2022.05.25 |
우분투에 Composer를 설치하고 사용하는 방법 (0) | 2022.05.25 |
우분투에 laravel 9을 설치하는 방법 (0) | 2022.05.22 |