启动elasticsearch报错
could not find java; set JAVA_HOME or ensure java is in PATH
首先需要安装java
1、yum list installed |grep java 查看当前有没有装
有的话先卸载
yum -y remove java-1.8.0-openjdk* *表时卸载所有openjdk相关文件输入
yum -y remove tzdata-java.noarch 卸载tzdata-java
安装java
yum install java-1.8.0-openjdk java-1.8.0-openjdk-devel
启动
sudo -iu www-data /usr/local/elasticsearch/bin/elasticsearch -d #-d为后台启动
如果还有报错的话
Exception in thread "main" java.nio.file.AccessDeniedException: /usr/local/elasticsearch/config/jvm.
则要为当前用户添加权限
chown www-data /usr/local/elasticsearch -R
启动时,突然服务又停止的话,查看日志
max file descriptors [65535] for elasticsearch process is too low, increase to at least [65536]
解决方法:
1、vi /etc/sysctl.conf
设置fs.file-max=655350
保存之后sysctl -p使设置生效
2、vi /etc/security/limits.conf 新增
* soft nofile 655350
* hard nofile 655350
如报一下错误
max number of threads [3820] for user [www-data] is too low, increase to at least [4096]
修改如下:
1、修改配置文件/etc/security/limits.conf
* soft nproc 10240
* hard nproc 10240
* soft nofile 10240
* hard nofile 10240
2、然后重启即可
其中nofile对应open_files
nproc对应max_user_processes
通过 ulimit -a可以查看max_user_processes
搭建集群时,启动节点报错
[node-2] failed to send join request to master [{node-1}{EQwLRT_kSm6sI4KPwsMkKw}{ya57_AoaRaeQbCzJKShWMw}{172.16.100.199}{172.16.100.199:9300}], reason [RemoteTransportException[[node-1][172.16.100.199:9300][internal:discovery/zen/join]]; nested: IllegalArgumentException[can't add node {node-2}{EQwLRT_kSm6sI4KPwsMkKw}{DDv-R-CITnePbZNmPb_1Fw}{172.16.100.201}{172.16.100.201:9300}, found existing node {node-1}{EQwLRT_kSm6sI4KPwsMkKw}{ya57_AoaRaeQbCzJKShWMw}{172.16.100.199}{172.16.100.199:9300} with the same id but is a different node instance]; ]
解决方法如下,节点data文件下的文件清空。