0%

linux下elasticsearch启动问题

此篇文章用于收纳安装elasticsearch后启动遇到的一些问题。

问题1:can not run elasticsearch as root

直接用root用户启动会出现如下类似的错误:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
root@cc-server:/home/environment/elasticsearch-6.4.2# ./bin/elasticsearch
[2018-10-11T18:37:43,323][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.4.2.jar:6.4.2]
at org.elasticsearch.bootstrap.Elasticsearch.execute(Elasticsearch.java:127) ~[elasticsearch-6.4.2.jar:6.4.2]
at org.elasticsearch.cli.EnvironmentAwareCommand.execute(EnvironmentAwareCommand.java:86) ~[elasticsearch-6.4.2.jar:6.4.2]
at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:124) ~[elasticsearch-cli-6.4.2.jar:6.4.2]
at org.elasticsearch.cli.Command.main(Command.java:90) ~[elasticsearch-cli-6.4.2.jar:6.4.2]
at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:93) ~[elasticsearch-6.4.2.jar:6.4.2]
at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:86) ~[elasticsearch-6.4.2.jar:6.4.2]
Caused by: java.lang.RuntimeException: can not run elasticsearch as root
at org.elasticsearch.bootstrap.Bootstrap.initializeNatives(Bootstrap.java:104) ~[elasticsearch-6.4.2.jar:6.4.2]
at org.elasticsearch.bootstrap.Bootstrap.setup(Bootstrap.java:171) ~[elasticsearch-6.4.2.jar:6.4.2]
at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:326) ~[elasticsearch-6.4.2.jar:6.4.2]
at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:136) ~[elasticsearch-6.4.2.jar:6.4.2]
... 6 more

解决办法:

1
2
3
4
5
//添加用户
adduser elasticsearch
//为用户赋值权限目录
//chown -R [用户][所属组] 文件夹目录
chown -R elasticsearch:elasticsearch elasticsearch-6.4.2/

问题2:max file descriptors for elasticsearch process is too low

在es启动时可能出现类似ERROR信息如下:

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

使用如下命令查看当前限制:

1
ulimit -n

解决办法:

修改文件/etc/security/limits.conf

1
vim /etc/security/limits.conf

添加如下配置,配置值设为需要的值即可:

1
2
3
4
#<domain>   <type>  <item>  <value>
#四个元素的意义在该文件中均有详细描述
elasticsearch soft nofile 65536
elasticsearch hard nofile 65536

问题3:max virtual memory areas vm.max_map_count is too low

在es启动时可能出现类似ERROR信息如下:

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

解决办法:
root权限下修改/etc/sysctl.conf文件,

1
vim /etc/sysctl.conf

添加如下配置,配置值设为需要的值即可

1
vm.max_map_count=655360

然后执行如下命令

1
sysctl -p

问题4:failed to send join request to master

在es启动时可能出现ERROR信息如下:

1
failed to send join request to master.can't add node found existing node with the same id but is a different node instance.

分析:

如果es的data存储路径在es文件夹下,在拷贝已被启动过的es文件夹的时候,data路径下已生成了节点的信息。所以只需要删除配置的data路径下的东西即可。