배우고 있습니다/elastic-search

[Elastic search 시스템 환경설정] is too low, increase to at least..

유헤 2019. 3. 29. 15:13

안녕하세요. 오랜만에 글을 작성합니다.

최근에 엘라스틱 구동을 위해 시스템 환경설정을 하다가, 애를 먹은 적이 있어 자세히 기록해두고자 합니다.

그것은 바로!

 


1. [Elasticsearch] [1]: max number of threads [1024] for user [user-name] is too low, increase to at least [4096]


2. max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]


3. ERROR: bootstrap checks failed 
max file descriptors [4096] for elasticsearch process likely too low, increase to at least [65536] 


위 와 같은 에러가 발생하면서 엘라스틱 데몬이 기동 되지 않고 꺼집니다.

위와 같은 원인은 일단 elasticsearch.yml 파일의 network.host 0.0.0.0 으로 설정 되어 있기 때문입니다.

( 실제로 network.host 주석 처리할 경우 잘 동작 됨 )

 

기본적으로 ElasticSearch는 localhost ( 172.0.0.1 ) 로 동작할 경우에는 개발자 모드로 돌아가나,

외부와 통신하기 위해서는 상용 모드로 전환됩니다.

https://discuss.elastic.co/t/es5-2-cant-bind-to-0-0-0-0/77797

 

이때, 상용모드에 맞춰 파일 디스크립터를 수정해줘야하는데

https://www.elastic.co/guide/en/elasticsearch/reference/master/file-descriptors.html

 

이렇게만 보면 무슨 소리인지 잘 모르겠고, 뭔가를 수정하긴 해야하는구나 싶습니다.

 


1. 과 같은 경우는 ulimit -Sa 라는 명령어를 치게 되면,

 

와 같은 내용이 뜨는데, 여기서 수정해야 할 부분들이 있습니다.

 

open files / max user processes 등 

Thread는 max user processes가 변경되었는지 확인 하면 해결 됩니다.

 

vi /etc/security/limits.conf

로 들어가서 확인해보면

위와 같이 설정해주면 됩니다.

 

나는 * (모든계정) 으로 설정해서 root 권한에서 설정하면 될줄 알았는데,

root 밑 계정이 따로 있다면 ulimit 으로 확인해서 계정명으로도 위의 흰색 부분처럼 따로 설정을 해줘야합니다.

 


2.의 경우는 vm.max_map_count 가 65530 으로 되어있고,

최소한 262144로 설정해주어야 한다는 내용입니다.

 

sysctl -n vm.max_map_count 을 입력해보면 위 오류가 나는분들은 65530이거나

262144 미만일것 입니다.

 

sysctl -w vm.max_map_count=262144

로 설정을 해주면 해결이 가능합니다


3.의 경우는 bootstrap 설정과 관련하여 yml에 파일에 추가해주면 됩니다.

 

bootstrap.system_call_filter: false

https://www.elastic.co/blog/bootstrap_checks_annoying_instead_of_devastating

라고 설정해주시면 깔끔하게 해결 됩니다.

 

 

참고 자료

https://edkoon35.github.io/2017/08/02/install-elasticsearch/

https://www.starstory.us/?p=1016

https://sematext.com/opensee/m/ElasticSearch/TnrDODzm25eKnYE?subj=+Elasticsearch+1+max+number+of+threads+2048+for+user+elasticsearch+is+too+low+increase+to+at+least+4096+

http://blog.naver.com/PostView.nhn?blogId=hanajava&logNo=220910638850&categoryNo=0&parentCategoryNo=0&viewDate=&currentPage=1&postListTopCurrentPage=1&from=postView