검색결과 리스트
검색에 해당되는 글 7건
- 2016.06.26 elasticsearch 2.3 에 plugins 설치하기 (1)
- 2015.12.26 elasticsearch - mapping 확인하기
- 2015.07.23 elasticsearch - failed to delete index
- 2015.01.25 [elasticsearch] open / close /delete index
- 2015.01.12 [ 엘라스틱서치] HTTP content length exceeded 104857600 bytes.
- 2014.07.22 elasticsearch 에러 - FileNotFoundException, too many open file (열린 파일이 너무 많음)]; "}}, (1)
- 2014.06.29 리눅스에서 elasticsearch 1.2.1 설치하기
글
elasticsearch 2.3 에 plugins 설치하기
환경 : Ubuntu 14.04
elasticsearch version: 2.3.2
설치할 plugin : head, hq, kopf, 한국어 형태소 분석기 (은전한닢)
elasticsearch 2.3을 신규 설치하여 plugin도 새로 설치해야 한다.
엘라스틱 검색이 2로 업그레이 되면서 아쉬운것은 bigdesk plugin을 사용 못한다는 것 ㅠㅠ
아쉬운 대로 hq와 kopf를 대신 설치하려고 한다.
일단 plugin 기본 설치 문법은 아래와 같다.
// elastic core plugin
sudo bin/plugin install [plugin_name]
// community and non-core plugin
sudo bin/plugin install [org]/[user|component]/[version]
// custom URL of file system
sudo bin/plugin install [url]
sudo bin/plugin install file:///path/to/plugin.zip
아래는 실제 설치 명령어 리스트이다.
// kopf 설치하기
sudo bin/plugin install lmenezes/elasticsearch-kopf
// head 설치하기
sudo bin/plugin install mobz/elasticsearch-head
// hq 설치하기
sudo bin/plugin install royrusso/elasticsearch-HQ
// 한국어 형태소 분석기(은전한닢) 설치하기
sudo bin/plugin install org.bitbucket.eunjeon/elasticsearch-analysis-seunjeon/2.3.2.1
참고: https://www.elastic.co/guide/en/elasticsearch/plugins/2.3/installation.html
https://www.elastic.co/guide/en/elasticsearch/plugins/2.3/management.html#_community_contributed_management_and_site_plugins
http://eunjeon.blogspot.kr/
설정
트랙백
댓글
글
elasticsearch - mapping 확인하기
엘라스틱 검색에서 현재 mapping을 확인하고 변경하는 방법을 정리해보았다.
현재 mapping 확인하기
- web browser에서 확인하기
http://(localhost or ip):(port)/indexname/_mapping/typename/
예시 )
http://localhost:9200/test/_mapping/companyname1/
- linux 에서 확인하기
curl -XGET 'http://(localhost or ip):(port)/indexname/_mapping/typename?pretty'
예시)
curl -XGET 'http://125.456.789.01:9200/test/_mapping?pretty'
curl -XGET 'http://125.456.789.01:9200/test/_mapping/companyname1?pretty' > current_mapping.json
예시) mapping 저장 결과
{
"test" : {
"mappings" : {
"companyname1" : {
"properties" : {
" 분기경상이익" : {
"type" : "string"
},
...
"news_line" : {
"type" : "string"
},
참고:
https://www.elastic.co/guide/en/elasticsearch/reference/current/analysis-cjk-bigram-tokenfilter.html
설정
트랙백
댓글
글
elasticsearch - failed to delete index
엘라스틱검색을 하면서 전체 인덱스를 아래와 같이 삭제하였는데
이상하게 head plugin에는 일부 인덱스들이 남아있다.
curl -XDELETE localhost:9200/_all
{"acknowledged":true}
로그를 확인해보니 아래와 같이 30초 타임아웃에 걸려서 인덱스 삭제를 실패했다는 메세지가 있다.
[2015-07-23 19:59:15,769][DEBUG][action.admin.indices.delete] [Illyana Rasputin] [2014-10-31] failed to delete index
org.elasticsearch.cluster.metadata.ProcessClusterEventTimeoutException: failed to process cluster event (delete-index [2014-10-31]) within 30s
at org.elasticsearch.cluster.service.InternalClusterService$2$1.run(InternalClusterService.java:278)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
검색해보니 timeout 시간을 늘리면 된다고 한다.
다만 인덱스를 삭제하는데 3초 이상이 걸리는것은 클러스터가 오버로드를 보여주는 것이라 주의가 필요할 것 같다.
I know this is a late reply, but in case anyone else sees this:
Curator timed out its connection after waiting for 30 seconds. You can increase the value with --timeout should something like this happen to you.
Truthfully, though, a delete operation that takes longer than even 3 seconds is indicative of an overloaded cluster.
이번엔 설정도 변경 안 하고 그냥 한번더 delete 명령어를 실행하니 남아있는 인덱스들도 깨끗이 사라졌다.
같은 문제가 반복되면 최적화 문제를 생각해봐야겠다.
그리고 삭제가 다 안되었는데도 삭제 성공 메세지가 나오는 것은 문제인 것 같아 확인해보니
이미 등록되어 오픈되어 있는 이슈인 듯하다.
진행중 이슈: https://github.com/elastic/elasticsearch/issues/7295
참조: http://elasticsearch-users.115913.n3.nabble.com/Failed-to-delete-index-using-curator-td4059905.html
설정
트랙백
댓글
글
[elasticsearch] open / close /delete index
자주 사용하는 API라 그냥 본인 참고용으로 정리.
elasticsearch는 특정 인덱스를 지정하여 열고 닫는것이 가능한데
더이상 사용하지 않는 인덱스가 있으면 검색서버 성능을 고려해서 닫거나 삭제해 주는 것이 좋다.
이렇게 닫혀진 인덱스는 클러스터에 overhead를 주지 않으며 이렇게 닫혀진 인덱스 내용을 읽고 쓰는 것은 불가능하다.
다시 인덱스를 읽고 싶으면 언제든지 다시 인덱스를 열어줄 수 있다.
- 특정 인덱스를 열거나 닫을 떄
curl -XPOST 'localhost:9200/my_index/_close'
curl -XPOST 'localhost:9200/my_index/_open'
- 전체 인덱스 열고 닫기
전체 인덱스를 닫거나 열 때는 인덱스 이름으로 _all 이나 * 를 사용한다.
curl -XPOST 'localhost:9200/*/_close'
curl -XPOST 'localhost:9200/_all/_close'
- 특정 인덱스 삭제
curl -XDELETE 'localhost:9200/my_index/'
- 전체 인덱스 삭제
전체 인덱스를 닫을 때와 동일하게 인덱스 이름으로 _all 이나 * 를 사용한다.
리눅스 - curl -XDELETE 'http://localhost:9200/_all/'
윈도우 - curl -XDELETE localhost:9200/_all
한번 삭제된 인덱스는 복구가 불가능하니 삭제 작업을 하기 전에 충분히 생각하고 진행하자.
그 외 자주 쓰는 명령어
- 전체 node shutdown
curl -XPOST 'http://localhost:9200/_shutdown'
참고:
http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/indices-open-close.html
http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/indices-delete-index.html
설정
트랙백
댓글
글
[ 엘라스틱서치] HTTP content length exceeded 104857600 bytes.
엘라스틱 서치 bulk index 를 하다 아래와 같이 에러가 나면서 색인이 되지 않았을 경우
org.elasticsearch.common.netty.handler.codec.frame.TooLongFrameException: HTTP content length exceeded 104857600 bytes.
at org.elasticsearch.common.netty.handler.codec.http.HttpChunkAggregator.messageReceived(HttpChunkAggregator.java:169)
at org.elasticsearch.common.netty.channel.SimpleChannelUpstreamHandler.handleUpstream(SimpleChannelUpstreamHandler.java:70)
at org.elasticsearch.common.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:564)
conf/elasticsearch.yml을 열어 아래 부분을 주석을 풀고 자신이 원하는 사이즈대로 수정해 주면 된다.
#
#http.max_content_length: 100mb
예시 ) 1024mb로 사이즈 증가시킴
# Set a custom allowed content length:
#
http.max_content_length: 1024mb
http.max_content_length 는 HTTP request로 처리할 수 있는 최대 값이고 기본적으로 100mb으로 설정되어 있다.
색인하려고 하는 bulk index 파일 사이즈보다 큰 값을 설정하고 elasticsearch를 재시작하면 반영 완료.
참고로 설정할수 있는 값은 최대 2기가이며 2기가 이상의 값을 설정하면
로그에 아래와 같은 메세지가 찍히면서 변경값이 적용이 되지 않는다.
[2015-07-23 00:21:16,350][WARN ][http.netty ] [Magdalena] maxContentLength[2.9gb] set to high value, resetting it to [100mb]
설정
트랙백
댓글
글
elasticsearch 에러 - FileNotFoundException, too many open file (열린 파일이 너무 많음)]; "}},
elasticsearch를 깔고 bulk 색인을 돌렸는데 아래와 같은 색인 에러가 나타났습니다.
{"index":{"_index":"a001470","_type":"2014","_id":"5","status":500,"error":"IndexFailedEngineException[[a001470][1] Index failed for [2014#5]]; nested: FileNotFoundException[/elasticsearch-1.2.1/data/elasticsearch/nodes/0/indices/a001470/1/index/_0.fdx (열린 파일이 너무 많음)]; "}},
검색해보니 elasticsearch의 open file의 개수가 작아서 생기는 일인 것 같습니다.
elasticsearch의 max_file_descriptors( open file )개수를 확인해 보니 1024라니 확실히 작네요 -_-;
#curl localhost:9200/_nodes/process?pretty
{
"cluster_name" : "elasticsearch",
"nodes" : {
"h68AFCOMQT-PF4tejfDCrA" : {
"name" : "Crooked Man",
"version" : "1.2.1",
"build" : "6c95b75",
"process" : {
"refresh_interval_in_millis" : 1000,
"id" : 20860,
"max_file_descriptors" : 1024,
"mlockall" : false
}
}
}
}
리눅스 기본 설정도 확인해보았습니다.
ulimit는 쉘이 실행한 프로세스에 대하여 시스템 상의 사용 자원을 설정할 수 있도록 해주는 명령어 입니다.
# ulimit -a
core file size (blocks, -c) 0
data seg size (kbytes, -d) unlimited
scheduling priority (-e) 0
file size (blocks, -f) unlimited
pending signals (-i) 4095
max locked memory (kbytes, -l) 32
max memory size (kbytes, -m) unlimited
open files (-n) 1024
pipe size (512 bytes, -p) 8
POSIX message queues (bytes, -q) 819200
real-time priority (-r) 0
stack size (kbytes, -s) 10240
cpu time (seconds, -t) unlimited
max user processes (-u) 4095
virtual memory (kbytes, -v) unlimited
file locks (-x) unlimited
기본 open file 세팅도 1024로 되어있으니 일단 ulimit -n32000 명령어를 주어 프로세스 당 open file개수를 변경합니다.
http://www.elasticsearch.org/guide/reference/setup/installation/
엘라스틱 서치에서는 기본적으로 오픈 파일 값을 32K나 64K 로 설정하는 것을 권장하고 있습니다.
Make sure to increase the number of open files descriptors on the machine (or for the user running elasticsearch). Setting it to 32k or even 64k is recommended.
In order to test how many open files the process can open, start it with -Des.max-open-files
set to true
. This will print the number of open files the process can open on startup.
제대로 설정이 되었는지 확인해 봅니다.
#ulimit -a
core file size (blocks, -c) 0
data seg size (kbytes, -d) unlimited
scheduling priority (-e) 0
file size (blocks, -f) unlimited
pending signals (-i) 4095
max locked memory (kbytes, -l) 32
max memory size (kbytes, -m) unlimited
open files (-n) 32000
pipe size (512 bytes, -p) 8
POSIX message queues (bytes, -q) 819200
real-time priority (-r) 0
stack size (kbytes, -s) 10240
cpu time (seconds, -t) unlimited
max user processes (-u) 4095
virtual memory (kbytes, -v) unlimited
file locks (-x) unlimited
ulimit -n의 변경값은 일시적이기 때문에 이 값을 계속 유지하고 싶으면 /etc/security/limits.conf 파일의 내용을 수정해야 합니다..
nofile은 해당 사용자(그룹)이 오픈할 수 있는 최대 파일 개수를 의미합니다.
/etc/security/limits.conf 값은 새로운 session 부터 영향을 끼치기 때문에
파일 설정을 변경하고 재로그인을하거나 새로운 세션으로 다시 접속하면 해당 설정이 변경된 것을 확인할 수 있습니다.
# 전체 user에게 같은 설정을 하려면 * 을 사용한다
* hard nofile 64000
* soft nofile 64000
# 특정 user (예: mysql)에기만 설정을 하려면
mysql hard nofile 64000
mysql soft nofile 64000
이제 엘라스틱 서치 실행시 해당 설정이 반영될 수 있도록 시작 스크립트를 아래와 같이 수정합니다.
참고로 위의 설정을 변경한 쉘에서 스크립트 실행을 해야 변경 사항이 반영이 됩니다.
./elasticsearch -Des.max-open-files=true -d
마지막으로 엘라스틱 서치에 해당 설정이 반영되었나 다시 한번 확인해 봅니다.
정상적으로 max_file_descriptors 설정이 변경된 것을 확인할 수 있습니다.
curl localhost:9200/_nodes/process?pretty
{
"cluster_name" : "elasticsearch",
"nodes" : {
"l4v0yXMrRbON7YY2AU9NGg" : {
"name" : "Khaos",
"version" : "1.2.1",
"build" : "6c95b75",
"process" : {
"refresh_interval_in_millis" : 1000,
"id" : 22055,
"max_file_descriptors" : 32000,
"mlockall" : false
}
}
}
}
만약 위와 같이 수정했는데도 ulimit -a에서 변경되지 않았다면
limits.conf는 pam_limits.so에 의해 읽히기 때문에 이 모듈이 enable되었는지 확인해 보자.
/etc/pam.d/su 에서 pam_limits.so가 아래와 같이 주석처리 되어있으면 주석 처리를 제거한다.
# Sets up user limits, please uncomment and read /etc/security/limits.conf
# to enable this functionality.
# (Replaces the use of /etc/limits in old login)
# session required pam_limits.so
참고:
http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/setup-configuration.html
http://stackoverflow.com/questions/15903105/too-many-open-files-warning-from-elasticsearch
설정
트랙백
댓글
글
리눅스에서 elasticsearch 1.2.1 설치하기
리눅스에서 elasticsearch 1.2.1 설치하기
1. elasticsearch 다운로드
http://www.elasticsearch.org/overview/elkdownloads/
링크주소를 복사해서 wget으로 받는다
wget https://download.elasticsearch.org/elasticsearch/elasticsearch/elasticsearch-1.2.1.tar.gz
다운로드 받은 파일 압축 푼다
tar -xvf elasticsearch-1.2.1.tar.gz
현재 다운로드되는 버전은 1.2.1이다.
설치 매뉴얼을 확인한다.
http://www.elasticsearch.org/guide/en/elasticsearch/guide/current/_installing_elasticsearch.html
2. plugin 설치
일단 기본적인 플러그인인 bigdesk, head를 설치한다.
출처: http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/modules-plugins.html
bin/plugin --install mobz/elasticsearch-head
bin/plugin --install lukas-vlcek/bigdesk
3. 플러그인 설치가 끝나면 bin 폴더의 elasticsearch를 실행한다.
-d 옵션을 주어 백그라운드로 실행하게 한다.
./bin/elasticsearch -d
ps afx | grep elastic 으로 제대로 실행되었는지 확인한다.
curl 'http://localhost:9200/?pretty' 를 입력해서 결과가 제대로 오는지 체크한다.
# curl 'http://localhost:9200/?pretty'
{
"status" : 200,
"name" : "Douglock",
"version" : {
"number" : "1.2.1",
"build_hash" : "6c95b759f9e7ef0f8e17f77d850da43ce8a4b364",
"build_timestamp" : "2014-06-03T15:02:52Z",
"build_snapshot" : false,
"lucene_version" : "4.8"
},
"tagline" : "You Know, for Search"
}
4. 마지막으로 설치된 플러그인을 확인한다.
http://localhost:9200/_plugin/head/
http://localhost:9200/_plugin/bigdesk/
localhost 주소에 elasticsearch가 실행되고 있는 서버 ip나 url을 적어줘도 된다.
아래와 같은 화면이 나온다면 플러그인까지 성공적으로 설치 완료!
알찬 정보 좋네요~