欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  科技

elasticsearch启动常见问题

程序员文章站 2022-03-19 22:13:08
原文:https://blog.csdn.net/qq_22211217/article/details/80740873 一、Exception in thread "main" SettingsException[Failed to load settings from [elasticsear ......

原文:https://blog.csdn.net/qq_22211217/article/details/80740873

一、exception in thread "main" settingsexception[failed to load settings from [elasticsearch.yml]]; nested: elasticsearchparseexception[malformed, expected settings to start with 'object', instead was [value_string]];
原因:elasticsearch.yml文件错误
解决:参数与参数值等号间需要空格

node.name ="node"  ##错误
node.name = "node" ##正确

二、org.elasticsearch.bootstrap.startupexception: java.lang.runtimeexception: can not run elasticsearch as root

详细错误:

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 a
[2018-06-20t02:19:58,978][warn ][o.e.b.elasticsearchuncaughtexceptionhandler] [] uncaught exception in thread [main]
org.elasticsearch.bootstrap.startupexception: java.lang.runtimeexception: can not run elasticsearch as root
    at org.elasticsearch.bootstrap.elasticsearch.init(elasticsearch.java:140) ~[elasticsearch-6.3.0.jar:6.3.0]
    at org.elasticsearch.bootstrap.elasticsearch.execute(elasticsearch.java:127) ~[elasticsearch-6.3.0.jar:6.3.0]
    at org.elasticsearch.cli.environmentawarecommand.execute(environmentawarecommand.java:86) ~[elasticsearch-6.3.0.jar:6.3.0]
    at org.elasticsearch.cli.command.mainwithouterrorhandling(command.java:124) ~[elasticsearch-cli-6.3.0.jar:6.3.0]
    at org.elasticsearch.cli.command.main(command.java:90) ~[elasticsearch-cli-6.3.0.jar:6.3.0]
    at org.elasticsearch.bootstrap.elasticsearch.main(elasticsearch.java:93) ~[elasticsearch-6.3.0.jar:6.3.0]
    at org.elasticsearch.bootstrap.elasticsearch.main(elasticsearch.java:86) ~[elasticsearch-6.3.0.jar:6.3.0]
caused by: java.lang.runtimeexception: can not run elasticsearch as root
    at org.elasticsearch.bootstrap.bootstrap.initializenatives(bootstrap.java:104) ~[elasticsearch-6.3.0.jar:6.3.0]
    at org.elasticsearch.bootstrap.bootstrap.setup(bootstrap.java:171) ~[elasticsearch-6.3.0.jar:6.3.0]
    at org.elasticsearch.bootstrap.bootstrap.init(bootstrap.java:326) ~[elasticsearch-6.3.0.jar:6.3.0]
    at org.elasticsearch.bootstrap.elasticsearch.init(elasticsearch.java:136) ~[elasticsearch-6.3.0.jar:6.3.0]
    ... 6 more

原因:处于对root用户的安全保护,需要使用其他用户组进行授权启动
解决:
step1:用户组进行授权启动

    groupadd elsearch           
    useradd elsearch -g elsearch -p elasticsearch
    chown -r elsearch:elsearch  elasticsearch-6.3.0

    备注: 添加用户组 elsearch  
          添加用户 elsearch 密码为 elasticsearch 到用户组 elsearch
          将elsearch安装目录授权给 用户组:用户  即 elsearch:elsearch

step2: 重新启动

    su elsearch
    /elasticsearch-6.3.0/bin/elasticsearch

    备注:切换 elsearch 用户
          重新启动

三、openjdk 64-bit server vm warning: info: os::commit_memory(0x0000000085330000, 2060255232, 0) failed; error='cannot a ...'(errno=12);
原因:jvm要分配最大内存超出系统内存
解决:

step1:适当调整指定jvm内存
vi /home/elasticsearch-6.3.0/config/jvm.options 

备注:编辑elasticsearch jvm配置文件 修改如下 esc+:wq保存退出
## jvm configuration
 
################################################################
## important: jvm heap size
################################################################
##
## you should always set the min and max jvm heap
## size to the same value. for example, to set
## the heap to 4 gb, set:
##
## -xms4g
## -xmx4g
##
## see https://www.elastic.co/guide/en/elasticsearch/reference/current/heap-size.html
## for more information
##
################################################################
 
# xms represents the initial size of total heap space
# xmx represents the maximum size of total heap space
 
-xms512m
-xmx512m
备注:由于虚拟机内存制定1g,所以适当降低jvm内存指定
step2:重启
su elsearch
/elasticsearch-6.3.0/bin/elasticsearch

四、error: [3] bootstrap checks failed

详细错误:

[2018-06-20t02:35:47,152][info ][o.e.b.bootstrapchecks    ] [sucofrg] bound or publishing to a non-loopback address, enforcing bootstrap checks
error: [3] bootstrap checks failed
[1]: max file descriptors [4096] for elasticsearch process is too low, increase to at least [65536]
[2]: max number of threads [3802] for user [elsearch] is too low, increase to at least [4096]
[3]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
[2018-06-20t02:35:47,170][info ][o.e.n.node               ] [sucofrg] stopping ...
[2018-06-20t02:35:47,316][info ][o.e.n.node               ] [sucofrg] stopped
[2018-06-20t02:35:47,316][info ][o.e.n.node               ] [sucofrg] closing ...
[2018-06-20t02:35:47,336][info ][o.e.n.node               ] [sucofrg] closed

原因:虚拟机限制用户的执行内存
解决:
[1]: max file descriptors [4096] for elasticsearch process is too low, increase to at least [65536]
[2]: max number of threads [3802] for user [elsearch] is too low, increase to at least [4096]

step1:修改安全限制配置文件

    su root 
    vi /etc/security/limits.conf

    备注:使用最高权限 修改安全配置 在文件末尾加入

    # end of file
    elsearch       hard        nofile        65536 
    elsearch       soft        nofile        65536
    *               soft       nproc         4096
    *               hard       nproc         4096
    备注: elsearch为用户名 可以是使用*进行通配  
    nofile 最大打开文件数目
    nproc 最大打开线程数目

 

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

step2:修改系统配置文件
vi /etc/sysctl.conf 
备注:行末加上vm.max_map_count = 655360 ,esc +:wq保存退出
# sysctl settings are defined through files in
# /usr/lib/sysctl.d/, /run/sysctl.d/, and /etc/sysctl.d/.
#
# vendors settings live in /usr/lib/sysctl.d/.
# to override a whole file, create a new file with the same in
# /etc/sysctl.d/ and put new settings there. to override
# only specific settings, add a file with a lexically later
# name in /etc/sysctl.d/ and put new settings there.
#
# for more information, see sysctl.conf(5) and sysctl.d(5).
vm.max_map_count = 655360
备注:vm.max_map_count = 655360 值大于错误提示值
step3:重启
su elsearch
/elasticsearch-6.3.0/bin/elasticsearch

五、org.elasticsearch.bootstrap.startupexception: java.lang.illegalstateexception: failed to obtain node locks, tried [[/home/elasticsearch-6.3.0/data/elasticsearch]] with lock id [0]; maybe these locations are not writable or multiple nodes were started without increasing [node.max_local_storage_nodes] (was [1])?

详细报错:
[2018-06-20t04:23:25,003][warn ][o.e.b.elasticsearchuncaughtexceptionhandler] [] uncaught exception in thread [main]
org.elasticsearch.bootstrap.startupexception: java.lang.illegalstateexception: failed to obtain node locks, tried [[/home/elasticsearch-6.3.0/data/elasticsearch]] with lock id [0]; maybe these locations are not writable or multiple nodes were started without increasing [node.max_local_storage_nodes] (was [1])?
    at org.elasticsearch.bootstrap.elasticsearch.init(elasticsearch.java:140) ~[elasticsearch-6.3.0.jar:6.3.0]
    at org.elasticsearch.bootstrap.elasticsearch.execute(elasticsearch.java:127) ~[elasticsearch-6.3.0.jar:6.3.0]
    at org.elasticsearch.cli.environmentawarecommand.execute(environmentawarecommand.java:86) ~[elasticsearch-6.3.0.jar:6.3.0]
    at org.elasticsearch.cli.command.mainwithouterrorhandling(command.java:124) ~[elasticsearch-cli-6.3.0.jar:6.3.0]
    at org.elasticsearch.cli.command.main(command.java:90) ~[elasticsearch-cli-6.3.0.jar:6.3.0]
    at org.elasticsearch.bootstrap.elasticsearch.main(elasticsearch.java:93) ~[elasticsearch-6.3.0.jar:6.3.0]
    at org.elasticsearch.bootstrap.elasticsearch.main(elasticsearch.java:86) ~[elasticsearch-6.3.0.jar:6.3.0]
caused by: java.lang.illegalstateexception: failed to obtain node locks, tried [[/home/elasticsearch-6.3.0/data/elasticsearch]] with lock id [0]; maybe these locations are not writable or multiple nodes were started without increasing [node.max_local_storage_nodes] (was [1])?
    at org.elasticsearch.env.nodeenvironment.<init>(nodeenvironment.java:243) ~[elasticsearch-6.3.0.jar:6.3.0]
    at org.elasticsearch.node.node.<init>(node.java:270) ~[elasticsearch-6.3.0.jar:6.3.0]
    at org.elasticsearch.node.node.<init>(node.java:252) ~[elasticsearch-6.3.0.jar:6.3.0]
    at org.elasticsearch.bootstrap.bootstrap$5.<init>(bootstrap.java:213) ~[elasticsearch-6.3.0.jar:6.3.0]
    at org.elasticsearch.bootstrap.bootstrap.setup(bootstrap.java:213) ~[elasticsearch-6.3.0.jar:6.3.0]
    at org.elasticsearch.bootstrap.bootstrap.init(bootstrap.java:326) ~[elasticsearch-6.3.0.jar:6.3.0]
    at org.elasticsearch.bootstrap.elasticsearch.init(elasticsearch.java:136) ~[elasticsearch-6.3.0.jar:6.3.0]
    ... 6 more

原因:线程占用

解决:重新启动

step1:杀死elasticsearch线程
ps -ef | grep elastic
step2: 重启
su elsearch
/elasticsearch-6.3.0/bin/elasticsearch

原文:https://blog.csdn.net/qq_22211217/article/details/80740873