ElasticSearch启动报错汇总,ERROR: [2] bootstrap checks failed

文章目录

  • 报错1 can not run elasticsearch as root
    • 解决
  • 报错2 没有权限导致启动失败
    • 解决
  • 报错3 ERROR: [2] bootstrap checks failed
    • 解决

  • elasticsearch 使用版本7.6.2
  • kibana 使用版本7.6.2

报错1 can not run elasticsearch as root

future versions of Elasticsearch will require Java 11; your Java version from [/usr/local/jdk1.8.0_291/jre] does not meet this requirement
[2022-06-21T15:21:40,405][ERROR][o.e.b.ElasticsearchUncaughtExceptionHandler] [node-1] 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:174) ~[elasticsearch-7.6.2.jar:7.6.2]
        at org.elasticsearch.bootstrap.Elasticsearch.execute(Elasticsearch.java:161) ~[elasticsearch-7.6.2.jar:7.6.2]
        at org.elasticsearch.cli.EnvironmentAwareCommand.execute(EnvironmentAwareCommand.java:86) ~[elasticsearch-7.6.2.jar:7.6.2]
        at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:125) ~[elasticsearch-cli-7.6.2.jar:7.6.2]
        at org.elasticsearch.cli.Command.main(Command.java:90) ~[elasticsearch-cli-7.6.2.jar:7.6.2]
        at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:126) ~[elasticsearch-7.6.2.jar:7.6.2]
        at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:92) ~[elasticsearch-7.6.2.jar:7.6.2]
Caused by: java.lang.RuntimeException: can not run elasticsearch as root
        at org.elasticsearch.bootstrap.Bootstrap.initializeNatives(Bootstrap.java:105) ~[elasticsearch-7.6.2.jar:7.6.2]
        at org.elasticsearch.bootstrap.Bootstrap.setup(Bootstrap.java:172) ~[elasticsearch-7.6.2.jar:7.6.2]
        at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:349) ~[elasticsearch-7.6.2.jar:7.6.2]
        at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:170) ~[elasticsearch-7.6.2.jar:7.6.2]
        ... 6 more
uncaught exception in thread [main]

解决

# 添加分组
groupadd es
# 在es分组中添加es账户
useradd es -g es
# 设置es账户的密码
passwd es
# 切换到es 账户
su es
./elasticsearch -d # -d 后台启动

报错2 没有权限导致启动失败

future versions of Elasticsearch will require Java 11; your Java version from [/usr/local/jdk1.8.0_291/jre] does not meet this requirement
Exception in thread "main" java.nio.file.AccessDeniedException: /usr/local/elk/elasticsearch-7.6.2/config/jvm.options
        at sun.nio.fs.UnixException.translateToIOException(UnixException.java:84)
        at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:102)
        at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:107)
        at sun.nio.fs.UnixFileSystemProvider.newByteChannel(UnixFileSystemProvider.java:214)
        at java.nio.file.Files.newByteChannel(Files.java:361)
        at java.nio.file.Files.newByteChannel(Files.java:407)
        at java.nio.file.spi.FileSystemProvider.newInputStream(FileSystemProvider.java:384)
        at java.nio.file.Files.newInputStream(Files.java:152)
        at org.elasticsearch.tools.launchers.JvmOptionsParser.main(JvmOptionsParser.java:64)
原因是elasticsearch用户没有该文件夹的权限,执行命令

解决

#赋予root权限
sudo chown -R 用户名:用户名 /usr/local/elasticsearch-7.6.2/

报错3 ERROR: [2] bootstrap checks failed

ERROR: [2] bootstrap checks failed
[1]: max file descriptors [4096] for elasticsearch process is too low, increase to at least [65535]
[2]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]

解决

  • 问题 [1]: max file descriptors [4096] for elasticsearch process is too low, increase to at least [65535]
vim /etc/security/limits.conf 

添加如下内容

*		soft	nofile		65536
*		hard	nofile		131072

ElasticSearch启动报错汇总,ERROR: [2] bootstrap checks failed_第1张图片

  • 问题 [2]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
su root # 切换到root账户
vim /etc/sysctl.conf

添加vm.max_map_count=655360
ElasticSearch启动报错汇总,ERROR: [2] bootstrap checks failed_第2张图片

sysctl -p # 编辑完保存之后,执行该命令进行刷新
su es #切换回 es用户继续启动elasticsearch
./elasticsearch
[root@YDGY-AS12 ~]# curl 127.0.0.1:9200
{
  "name" : "YDGY-AS12",
  "cluster_name" : "elasticsearch",
  "cluster_uuid" : "s0qC8rTIR92LwjqC5m9BNQ",
  "version" : {
    "number" : "7.6.2",
    "build_flavor" : "default",
    "build_type" : "tar",
    "build_hash" : "ef48eb35cf30adf4db14086e8aabd07ef6fb113f",
    "build_date" : "2020-03-26T06:34:37.794943Z",
    "build_snapshot" : false,
    "lucene_version" : "8.4.0",
    "minimum_wire_compatibility_version" : "6.8.0",
    "minimum_index_compatibility_version" : "6.0.0-beta1"
  },
  "tagline" : "You Know, for Search"
}

你可能感兴趣的:(Elasticsearch,linux,elasticsearch,搜索引擎,linux)