... ES 해야함.
참고문서 두개 번갈아가면서 봄.
한글 5.4 https://www.elastic.co/guide/kr/elasticsearch/reference/current/gs-installation.html
영문 6.3 https://www.elastic.co/guide/en/elasticsearch/reference/current/_installation.html
- 서버 하나 vm으로 받음. (다음번엔 여러대 클러스터 작업엔 엔씨블로...)
- 1.8 깔려있다. 감사합니다. 근데 java_home이 없음.
vi ~/.bash_profile 에다가 등록함. - es tar 다운
curl -L -O https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-6.3.0.tar.gz
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
29 87.1M 29 25.4M 0 0 318k 0 0:04:40 0:01:21 0:03:19 378k
용량이 좀 있네..- 압축 풀고.
tar -xvf elasticsearch-6.3.0.tar.gz
cd elasticsearch-6.3.0/bin
디렉토리 이동.
bin]$ ./elasticsearch
노드랑 싱글 클러스터 실행 가능하다고 함.OpenJDK 64-Bit Server VM warning: If the number of processors is expected to increase from one, then you should configure the number of parallel GC threads appropriately using -XX:ParallelGCThreads=N
시작부터 이런게 뜨네 ..... 알아서 구성 해줄것이지..ㅠㅠ
나머지 맥은 홈브류로, 윈도우는 인스톨러가 있는듯. 안중요하니 넘김../elasticsearch -Ecluster.name=my_cluster_name -Enode.name=my_node_name
실행 시 클러스터 이름, 노드 이름 지정가능.음... 9200번 포트를 사용해서 rest API를 제공하나봄.(퍼블리쉬_어드레스) ... 9300 번은 뭔지 ? (바운스 어드레스)
일단 넘어감.REST API 로 거의 모든것을 할 수 있는거 같은 느낌을 줬음.
클러스터, 노드, 헬스체크, CURD 뭐 여러가지 등등... 고급작업까지 라고 적혀있음.외부에서(맥북) 해당서버 ip로 curl 날리니 안되고... 흠...? 다른사람들도 이런가.
설치 된 서버 내부에서 localhost 콘솔로 날려봄.
~]$ curl -X GET "localhost:9200/_cat/health?v"
epoch timestamp cluster status node.total node.data shards pri relo init unassign pending_tasks max_task_wait_time active_shards_percent
1529253972 01:46:12 elasticsearch green 1 1 0 0 0 0 0 0 - 100.0%
그 외에도 키바나 콘솔에서 다음 api를 날릴 수 있다고함.
... 그냥도 날릴 수 있었음. 언젠가 키바ㄴㅏ 사용법을 다음엔 알아봐야겠다. elk니까...
일단 정상이라 그린임.
노랑은 모든 데이터 사용가능하지만 일부 리플리카가 미배정된 상태.
레드는 비정상. 부분동작.~]$ curl -X GET "localhost:9200/_cat/nodes?v"
ip heap.percent ram.percent cpu load_1m load_5m load_15m node.role master name
127.0.0.1 9 93 4 0.00 0.01 0.06 mdi * 7EmJiq_
노드목록은 ㅇㅣ렇게 체크 가능한것 같다. ... 짠한 유일노드.~]$ curl -X GET "localhost:9200/_cat/indices?v"
health status index uuid pri rep docs.count docs.deleted store.size pri.store.size
모든 색인(indices) 나열 이라고 하는데. 없ㄷㅏ.색인 ... index 생성. 'customer' 라는걸 만들고 색인을 나열한다고...
curl -X PUT "localhost:9200/customer?pretty"
~]$ curl -X PUT "localhost:9200/customer?pretty"
{
"acknowledged" : true,
"shards_acknowledged" : true,
"index" : "customer"
}
curl -X GET "localhost:9200/_cat/indices?v"
~]$ curl -X GET "localhost:9200/_cat/indices?v"
health status index uuid pri rep docs.count docs.deleted store.size pri.store.size
yellow open customer axCGidU6Qy2D7Eercp5ATw 5 1 0 0 460b 460b
아... rep가 1이라서 옐로인가봄.
싱글 노드라서.'customer' index 에다가 뭘 집어넣으려고 한다...
curl -X PUT "localhost:9200/customer/_doc/1?pretty" -H 'Content-Type: application/json' -d'
{
"name": "John Doe"
}
'
유형이 어떤지 알려줘야 한다고... 위에처럼 넣고나면.
{
"_index" : "customer",
"_type" : "_doc",
"_id" : "1",
"_version" : 1,
"result" : "created",
"_shards" : {
"total" : 2,
"successful" : 1,
"failed" : 0
},
"_seq_no" : 0,
"_primary_term" : 1
}
이렇게 응답이 오고.
내부 id는 1, 타입은 doc... 뭐 등등 정보가 있음.~]$ curl -X GET "localhost:9200/customer/_doc/1?pretty"
{
"_index" : "customer",
"_type" : "_doc",
"_id" : "1",
"_version" : 1,
"found" : true,
"_source" : {
"name" : "John Doe"
}
}
found 필드? - 찾았다고 알려주는 필드. source 는 앞에 넣은 json 문서네.삭제 후 확인
curl -X DELETE "localhost:9200/customer?pretty"
~]$ curl -X DELETE "localhost:9200/customer?pretty"
{
"acknowledged" : true
}
curl -X GET "localhost:9200/_cat/indices?v"
~]$ curl -X GET "localhost:9200/_cat/indices?v"
health status index uuid pri rep docs.count docs.deleted store.size pri.store.size
... 인덱스 날아감.<REST Verb> /<Index>/<Type>/<ID>
이런 패턴이 있는걸 익혀두라함.
일단 여기까지.
'몰라그거무서운거 > elk or kafka' 카테고리의 다른 글
Elasticsearch linux 설정 조각 (0) | 2021.01.14 |
---|---|
ES 6.x 노드를 메인터넌스 보내야할 때. (0) | 2021.01.07 |
엘라스틱서치 6.3 무따기(3) (0) | 2018.07.02 |
엘라스틱서치 6.3 무따기(2) (0) | 2018.07.02 |