Linux 環(huán)境下安裝 Elasticsearch 5.x、6.x 問題匯總

can not run elasticsearch as root

[o.e.b.ElasticsearchUncaughtExceptionHandler] [] uncaught exception in thread [main]
org.elasticsearch.bootstrap.StartupException: java.lang.RuntimeException: can not run elasticsearch as root

解決方案:
因為安全問題 elasticsearch 不讓用 root 用戶直接運行,建議創(chuàng)建一個單獨的用戶用來運行
elasticsearch。我們可以創(chuàng)建 elsearch 用戶組及 elsearch 用戶,然后用這個用戶來啟動 elasticsearch。

groupadd elsearch
useradd elsearch -g elsearch -p elasticsearch

access denied

main ERROR Could not register mbeans java.security.AccessControlException: access denied ("javax.management.MBeanTrustPermission" "register")

解決方案:
root 用戶下,改變 elasticsearch-5.1.1 文件夾所有者給 elasticsearch 啟動用戶:

sudo chown -R elsearch:elsearch elasticsearch-5.1.1

There is insufficient memory for the Java Runtime Environment to continue

Cannot allocate memory
Java HotSpot(TM) 64-Bit Server VM warning: INFO: os::commit_memory(0x0000000085330000, 2060255232, 0) failed; error='Cannot allocate memory' (errno=12)
There is insufficient memory for the Java Runtime Environment to continue.

解決方案:
修改 config/jvm.options,2g改成1g,也可以更小

-Xmx2g => -Xmx1g


unable to install syscall filter

unable to install syscall filter:
java.lang.UnsupportedOperationException: seccomp unavailable: requires kernel 3.5+ with CONFIG_SECCOMP and CONFIG_SECCOMP_FILTER compiled in
at org.elasticsearch.bootstrap.Seccomp.linuxImpl(Seccomp.java:349) ~[elasticsearch-5.0.0.jar:5.0.0]
at org.elasticsearch.bootstrap.Seccomp.init(Seccomp.java:630) ~[elasticsearch-5.0.0.jar:5.0.0]

報了一大串錯誤,其實只是一個警告。

解決方案:
使用最新 Linux 版本,就不會出現(xiàn)此類問題了,可用忽略。


max number of threads [1024] for user [lish] likely too low, increase to at least [2048]

解決方案:
root 用戶下,進(jìn)入 limits.d 目錄下修改配置文件:

vim /etc/security/limits.d/90-nproc.conf

修改 soft nproc:

soft nproc 2048

max file descriptors for elasticsearch process likely too low

ERROR: bootstrap checks failed
max file descriptors [4096] for elasticsearch process likely too low, increase to at least [65536]
max number of threads [1024] for user [lishang] likely too low, increase to at least [2048]

解決方案:
root 用戶下,編輯 limits.conf:

vim /etc/security/limits.conf

添加如下內(nèi)容:

* soft nofile 65536
* hard nofile 65536
* soft nproc 2048
* hard nproc 4096

system call filters failed to install

ERROR: bootstrap checks failed
system call filters failed to install; check the logs and fix your configuration or disable system call filters at your own risk
解決方案:
修改 elasticsearch 配置文件:

vim config/elasticsearch.yml

增加配置:

bootstrap.system_call_filter: false

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

解決方案:
root 用戶下,修改配置 sysctl.conf

vim /etc/sysctl.conf

添加下面配置:

vm.max_map_count=655360

執(zhí)行命令:

sysctl -p

重新啟動 elasticsearch


最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容