• elasticsearch 一些错误及解决


    elasticsearch : which: no java in (/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin)

    查看 elasticsearch 服务状态是,报出以下错误

    [root@elk-node1 ~]# systemctl status elasticsearch.service
    ● elasticsearch.service - Elasticsearch
    Loaded: loaded (/usr/lib/systemd/system/elasticsearch.service; disabled; vendor preset: disabled)
    Active: failed (Result: exit-code) since 五 2020-04-10 23:51:54 CST; 5min ago
    Docs: http://www.elastic.co
    Main PID: 1253 (code=exited, status=1/FAILURE)

    4月 10 23:51:54 elk-node1 systemd[1]: Starting Elasticsearch...
    4月 10 23:51:54 elk-node1 systemd[1]: Started Elasticsearch.
    4月 10 23:51:54 elk-node1 elasticsearch[1253]: which: no java in (/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin)
    4月 10 23:51:54 elk-node1 systemd[1]: elasticsearch.service: main process exited, code=exited, status=1/FAILURE
    4月 10 23:51:54 elk-node1 systemd[1]: Unit elasticsearch.service entered failed state.
    4月 10 23:51:54 elk-node1 systemd[1]: elasticsearch.service failed.

    解决方法:

    方法一:

    查看 java 安装位置

    [root@elk-node1 ~]# which java
    /usr/local/java/jdk1.8.0_191/bin/java

    建立软连接

    [root@elk-node1 ~]# ln -s /usr/local/java/jdk1.8.0_191/bin/java /usr/bin/java  

    方法二:

    在 /etc/sysconfig/elasticsearch 中添加 JAVA_HOME 环境变量的配置

    vim /etc/sysconfig/elasticsearch

    文件部分展示:

    ################################
    # Elasticsearch
    ################################

    # Elasticsearch home directory
    ES_HOME=/usr/share/elasticsearch

    # Elasticsearch Java path
    JAVA_HOME=/usr/local/java/jdk1.8.0_191

    Process: 2000 ExecStart=/usr/share/elasticsearch/bin/elasticsearch -p ${PID_DIR}/elasticsearch.pid --quiet -Edefault.path.logs=${LOG_DIR} -Edefault.path.data=${DATA_DIR} -Edefault.path.conf=${CONF_DIR} (code=exited, status=1/FAILURE)
    Process: 1999 ExecStartPre=/usr/share/elasticsearch/bin/elasticsearch-systemd-pre-exec (code=exited, status=0/SUCCESS)
    Main PID: 2000 (code=exited, status=1/FAILURE)

    查看 elasticsearch 服务器状态,如下:

    [root@elk-node1 ~]# systemctl status elasticsearch.service
    ● elasticsearch.service - Elasticsearch
    Loaded: loaded (/usr/lib/systemd/system/elasticsearch.service; disabled; vendor preset: disabled)
    Active: failed (Result: exit-code) since 六 2020-04-11 11:26:09 CST; 2s ago
    Docs: http://www.elastic.co
    Process: 2107 ExecStart=/usr/share/elasticsearch/bin/elasticsearch -p ${PID_DIR}/elasticsearch.pid --quiet -Edefault.path.logs=${LOG_DIR} -Edefault.path.data=${DATA_DIR} -Edefault.path.conf=${CONF_DIR} (code=exited, status=1/FAILURE)
    Process: 2106 ExecStartPre=/usr/share/elasticsearch/bin/elasticsearch-systemd-pre-exec (code=exited, status=0/SUCCESS)
    Main PID: 2107 (code=exited, status=1/FAILURE)

    4月 11 11:26:06 elk-node1 systemd[1]: Starting Elasticsearch...
    4月 11 11:26:06 elk-node1 systemd[1]: Started Elasticsearch.
    4月 11 11:26:09 elk-node1 elasticsearch[2107]: Exception in thread ...
    4月 11 11:26:09 elk-node1 systemd[1]: elasticsearch.service: main ...E
    4月 11 11:26:09 elk-node1 systemd[1]: Unit elasticsearch.service e....
    4月 11 11:26:09 elk-node1 systemd[1]: elasticsearch.service failed.
    Hint: Some lines were ellipsized, use -l to show in full.

    解决方法:

    在 /etc/sysconfig/elasticsearch 中配置环境

    vim /etc/sysconfig/elasticsearch

    文件部分展示:

    ################################
    # Elasticsearch
    ################################

    # Elasticsearch home directory
    ES_HOME=/usr/share/elasticsearch

    # Elasticsearch Java path
    JAVA_HOME=/usr/local/java/jdk1.8.0_191

    # Elasticsearch configuration directory
    CONF_DIR=/etc/elasticsearch

    # Elasticsearch data directory
    DATA_DIR=/data/elk_data

    # Elasticsearch logs directory
    LOG_DIR=/var/log/elasticsearch

    # Elasticsearch PID directory
    PID_DIR=/var/run/elasticsearch

  • 相关阅读:
    HTML 5 标准属性
    启程
    【Java】自定义登陆拦截器
    【Java】将List中的实体按照某个字段进行分组的算法
    SpringBoot + MultipartFile 实现文件上传以及文件转移的功能以及配置全局捕获上传文件过大异常
    MySQL查询两门及两门以上不及格的学生,显示姓名
    java中可以用==来比较两个字符串是否相等吗
    自己动手Jquery插件
    10个可以直接拿来用的JQuery代码片段
    linux 安装python
  • 原文地址:https://www.cnblogs.com/2567xl/p/12677334.html
Copyright © 2020-2023  润新知