【问题标题】:alternative to sudo /etc/init.d/elasticsearch start替代 sudo /etc/init.d/elasticsearch start
【发布时间】:2017-05-04 12:46:39
【问题描述】:

我正在尝试通过 supervisord 运行 elasticsearch。为此,我需要一个命令来启动 elasticsearch,而无需在后台运行它。我当前的 supervisord 脚本看起来像

[program:elasticsearch]
command=/etc/init.d/elasticsearch start
autostart=true
autorestart=true
startretries=3
user=root
stdout_logfile=/var/www/elasticsearch_std.log

但由于'/etc/init.d/elasticsearch start'命令在后台运行elasticsearch,一旦命令返回成功启动,它就会尝试再次启动elasticsearch,这导致

DEBG 'elasticsearch' stdout output:
 * Already running.
   ...done.

由于我告诉 supervisord 重启 3 次,它会在放弃之前执行 3 次。但是,这样做的目的当然是在崩溃的情况下,supervisord 应该重新启动 elasticsearch。 所以我需要一个在前台启动 elasticsearch 的命令。

编辑: 按照下面的建议和https://www.elastic.co/guide/en/elasticsearch/reference/current/settings.html 的弹性搜索指令,我尝试运行

/usr/share/elasticsearch/bin/elasticsearch -Epath.conf=/etc/elasticsearch -Epath.logs=/var/log/elasticsearch -Epath.data=/var/lib/elasticsearch
Error: encountered environment variables that are no longer supported
Use jvm.options or ES_JAVA_OPTS to configure the JVM
ES_HEAP_SIZE=256m: set -Xms256m and -Xmx256m in jvm.options or add "-Xms256m -Xmx256m" to ES_JAVA_OPTS

我不明白这个错误信息,因为我已经设置了

-Xms256m
-Xmx256m

在 /etc/elasticsearch/jvm.options 中

EDIT2:我也试过通过环境来设置这些参数,也不管用

ES_JAVA_OPTS="-Xms256m -Xmx256m" /usr/share/elasticsearch/bin/elasticsearch -Epath.conf=/etc/elasticsearch -Epath.logs=/var/log/elasticsearch -Epath.data=/var/lib/elasticsearch
Error: encountered environment variables that are no longer supported
Use jvm.options or ES_JAVA_OPTS to configure the JVM
ES_HEAP_SIZE=256m: set -Xms256m and -Xmx256m in jvm.options or add "-Xms256m -Xmx256m" to ES_JAVA_OPTS

/etc/default/elasticsearch 文件的所有行都被注释掉了,除了

ES_STARTUP_SLEEP_TIME=5

【问题讨论】:

    标签: elasticsearch supervisord


    【解决方案1】:

    直接使用bin/elasticsearch 启动elasticsearch。使用init文件会立即daemonize并退出,不适合supervisor。 相反,将命令属性设置为:

    command=/usr/share/elasticsearch/bin/elasticsearch
        -Edefault.path.conf=/etc/elasticsearch
        -Edefault.path.logs=/var/log/elasticsearch
        -Edefault.path.data=/var/lib/elasticsearch
    

    相应地替换路径。

    您还可以设置default.path.conf 并编辑其中的 YAML 文件以进行数据和日志设置(以及其他)。

    【讨论】:

    • 感谢您的帮助 fernandezcuesta...请查看我上面的编辑
    • /etc/default/elasticsearch 下的任何内容?您也可以尝试在您的 supervisord conf 的程序条目中添加environment=ES_JAVA_OPTS="-Xms256m -Xmx256m"。
    • 我在上面做了一些修改......设置环境变量似乎也可以工作
    猜你喜欢
    • 2012-07-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-03-23
    • 1970-01-01
    • 2014-02-16
    相关资源
    最近更新 更多