Elasticsearch 6.0.0 安装问题

环境

centos 7

配置文件路径

./config/elasticsearch.yml

启动错误

以下错误,执行完解决方法后,部分需要重新登录账号使配置生效

bound or publishing to a non-loopback or non-link-local address, enforcing bootstrap checks
ERROR: [2] bootstrap checks failed

1.root账号无法启动elasticsearch

[2017-12-08T16:25:43,072][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:134) ~[elasticsearch-6.0.0.jar:6.0.0]
    at org.elasticsearch.bootstrap.Elasticsearch.execute(Elasticsearch.java:121) ~[elasticsearch-6.0.0.jar:6.0.0]
    at org.elasticsearch.cli.EnvironmentAwareCommand.execute(EnvironmentAwareCommand.java:69) ~[elasticsearch-6.0.0.jar:6.0.0]
    at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:134) ~[elasticsearch-6.0.0.jar:6.0.0]
    at org.elasticsearch.cli.Command.main(Command.java:90) ~[elasticsearch-6.0.0.jar:6.0.0]
    at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:92) ~[elasticsearch-6.0.0.jar:6.0.0]
    at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:85) ~[elasticsearch-6.0.0.jar:6.0.0]
Caused by: java.lang.RuntimeException: can not run elasticsearch as root
    at org.elasticsearch.bootstrap.Bootstrap.initializeNatives(Bootstrap.java:104) ~[elasticsearch-6.0.0.jar:6.0.0]
    at org.elasticsearch.bootstrap.Bootstrap.setup(Bootstrap.java:171) ~[elasticsearch-6.0.0.jar:6.0.0]
    at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:322) ~[elasticsearch-6.0.0.jar:6.0.0]
    at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:130) ~[elasticsearch-6.0.0.jar:6.0.0]
    ... 6 more

解决方法

  • 创建用户组:groupadd [你的用户组名]
  • 创建用户并加入指定组:useradd [用户名] -g [用户组名] -p [密码,可以不加]
  • 分配目录到指定用户和组:chown -R [用户名]:[用户组] [elasticsearch地址]
  • 切换用户:su [用户名]
  • 启动:./bin/elasticsearch

2.文件句柄不足

max file descriptors [4096] for elasticsearch process is too low, increase to at least [65536]

解决方法

  • 切换到root用户下
  • 修改limits.conf文件,并添加以下内容:vi /etc/security/limits.conf
* soft nofile 65536
* hard nofile 131072
* soft nproc 2048
* hard nproc 4096

3.启动最大线程数限制

max number of threads [2048] for user [chenyn] is too low, increase to at least [4096]

解决方法

  • 切换到root用户下
  • 修改20-nproc.conf(系统不同文件名有变化):vi /etc/security/limits.d/20-nproc.conf
* soft nproc 4096

4.设定虚存不足

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

解决方法

  • 切换到root用户下
  • 修改sysctl.conf文件:vi /etc/sysctl.conf,并添加
vm.max_map_count=262144
  • 使配置生效:sysctl -p

你可能感兴趣的:(elasticsearch)