请教下 supervisor 配置的问题

2017-04-15 00:45:39 +08:00
 MrMike

为了监控 elasticsearch 死掉后,能自动重启,网上查了下,supervisor 可以实现这个要求,以下是配置: [program=sticsearch] command=/usr/share/elasticsearch/bin/elasticsearch autostart=true autorestart=true stdout_logfile=/home/demoer/log/elasticsearch/elasticsearch-stdout.log stderr_logfile=/home/demoer/log/elasticsearch/elasticsearch-stderr.log startsecs=5

我把这个直接写在 supervisor.conf ,在启动 supervisorctl reload, reread, update,都说没有找到配置( No config updates to processes )。 我用 include_file 单独来引入,也是同样的结果。 请问下配置代码是否正确呢?

4287 次点击
所在节点    Python
29 条回复
MrMike
2017-04-15 22:22:52 +08:00
@zsz
@a128445

elasticsearch.con :

[program:elasticsearch]
command=/usr/share/elasticsearch/bin/elasticsearch
directory=/usr/share/elasticsearch
autostart=true
autorestart=true
startsecs=10
startretries=3
redirect_stderr=true
user=root
stdout_logfile=/home/demoer/log/elasticsearch/elasticsearch-stdout.log
stderr_logfile=/home/demoer/log/elasticsearch/elasticsearch-stderr.log


elasticsearch-stdout.log :

Exception in thread "main" ElasticsearchException[Failed to load logging configuration]; nested: NoSuchFileException[/usr/share/elasticsearch/config];
Likely root cause: java.nio.file.NoSuchFileException: /usr/share/elasticsearch/config
at sun.nio.fs.UnixException.translateToIOException(UnixException.java:86)
at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:102)
at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:107)
at sun.nio.fs.UnixFileAttributeViews$Basic.readAttributes(UnixFileAttributeViews.java:55)
at sun.nio.fs.UnixFileSystemProvider.readAttributes(UnixFileSystemProvider.java:144)
at sun.nio.fs.LinuxFileSystemProvider.readAttributes(LinuxFileSystemProvider.java:99)
at java.nio.file.Files.readAttributes(Files.java:1737)
at java.nio.file.FileTreeWalker.getAttributes(FileTreeWalker.java:225)
at java.nio.file.FileTreeWalker.visit(FileTreeWalker.java:276)
at java.nio.file.FileTreeWalker.walk(FileTreeWalker.java:322)
at java.nio.file.Files.walkFileTree(Files.java:2662)
at org.elasticsearch.common.logging.LogConfigurator.resolveConfig(LogConfigurator.java:150)
at org.elasticsearch.common.logging.LogConfigurator.configure(LogConfigurator.java:114)
at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:236)
at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:96)
at org.elasticsearch.bootstrap.Elasticsearch.execute(Elasticsearch.java:91)
at org.elasticsearch.cli.SettingCommand.execute(SettingCommand.java:54)
at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:91)
at org.elasticsearch.cli.Command.main(Command.java:53)
at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:70)
at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:63)
Refer to the log for complete error details.
Exception in thread "main" ElasticsearchException[Failed to load logging configuration]; nested: NoSuchFileException[/usr/share/elasticsearch/config];
Likely root cause: java.nio.file.NoSuchFileException: /usr/share/elasticsearch/config
at sun.nio.fs.UnixException.translateToIOException(UnixException.java:86)
at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:102)
at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:107)
at sun.nio.fs.UnixFileAttributeViews$Basic.readAttributes(UnixFileAttributeViews.java:55)
at sun.nio.fs.UnixFileSystemProvider.readAttributes(UnixFileSystemProvider.java:144)
at sun.nio.fs.LinuxFileSystemProvider.readAttributes(LinuxFileSystemProvider.java:99)
at java.nio.file.Files.readAttributes(Files.java:1737)
at java.nio.file.FileTreeWalker.getAttributes(FileTreeWalker.java:225)
at java.nio.file.FileTreeWalker.visit(FileTreeWalker.java:276)
at java.nio.file.FileTreeWalker.walk(FileTreeWalker.java:322)
at java.nio.file.Files.walkFileTree(Files.java:2662)
at org.elasticsearch.common.logging.LogConfigurator.resolveConfig(LogConfigurator.java:150)
at org.elasticsearch.common.logging.LogConfigurator.configure(LogConfigurator.java:114)
at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:236)
at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:96)
at org.elasticsearch.bootstrap.Elasticsearch.execute(Elasticsearch.java:91)
at org.elasticsearch.cli.SettingCommand.execute(SettingCommand.java:54)
at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:91)
at org.elasticsearch.cli.Command.main(Command.java:53)
at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:70)
at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:63)
Refer to the log for complete error details.
Exception in thread "main" ElasticsearchException[Failed to load logging configuration]; nested: NoSuchFileException[/usr/share/elasticsearch/config];
Likely root cause: java.nio.file.NoSuchFileException: /usr/share/elasticsearch/config
at sun.nio.fs.UnixException.translateToIOException(UnixException.java:86)
at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:102)
at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:107)
at sun.nio.fs.UnixFileAttributeViews$Basic.readAttributes(UnixFileAttributeViews.java:55)
at sun.nio.fs.UnixFileSystemProvider.readAttributes(UnixFileSystemProvider.java:144)
at sun.nio.fs.LinuxFileSystemProvider.readAttributes(LinuxFileSystemProvider.java:99)
at java.nio.file.Files.readAttributes(Files.java:1737)
at java.nio.file.FileTreeWalker.getAttributes(FileTreeWalker.java:225)
at java.nio.file.FileTreeWalker.visit(FileTreeWalker.java:276)
at java.nio.file.FileTreeWalker.walk(FileTreeWalker.java:322)
at java.nio.file.Files.walkFileTree(Files.java:2662)
at org.elasticsearch.common.logging.LogConfigurator.resolveConfig(LogConfigurator.java:150)
at org.elasticsearch.common.logging.LogConfigurator.configure(LogConfigurator.java:114)
at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:236)
at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:96)
at org.elasticsearch.bootstrap.Elasticsearch.execute(Elasticsearch.java:91)
at org.elasticsearch.cli.SettingCommand.execute(SettingCommand.java:54)
at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:91)
at org.elasticsearch.cli.Command.main(Command.java:53)
at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:70)
at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:63)
Refer to the log for complete error details.
Exception in thread "main" ElasticsearchException[Failed to load logging configuration]; nested: NoSuchFileException[/usr/share/elasticsearch/config];
Likely root cause: java.nio.file.NoSuchFileException: /usr/share/elasticsearch/config
at sun.nio.fs.UnixException.translateToIOException(UnixException.java:86)
at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:102)
at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:107)
at sun.nio.fs.UnixFileAttributeViews$Basic.readAttributes(UnixFileAttributeViews.java:55)
at sun.nio.fs.UnixFileSystemProvider.readAttributes(UnixFileSystemProvider.java:144)
at sun.nio.fs.LinuxFileSystemProvider.readAttributes(LinuxFileSystemProvider.java:99)
at java.nio.file.Files.readAttributes(Files.java:1737)
at java.nio.file.FileTreeWalker.getAttributes(FileTreeWalker.java:225)
at java.nio.file.FileTreeWalker.visit(FileTreeWalker.java:276)
at java.nio.file.FileTreeWalker.walk(FileTreeWalker.java:322)
at java.nio.file.Files.walkFileTree(Files.java:2662)
at org.elasticsearch.common.logging.LogConfigurator.resolveConfig(LogConfigurator.java:150)
at org.elasticsearch.common.logging.LogConfigurator.configure(LogConfigurator.java:114)
at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:236)
at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:96)
at org.elasticsearch.bootstrap.Elasticsearch.execute(Elasticsearch.java:91)
at org.elasticsearch.cli.SettingCommand.execute(SettingCommand.java:54)
at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:91)
at org.elasticsearch.cli.Command.main(Command.java:53)
at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:70)
at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:63)
Refer to the log for complete error details.


elasticsearch-stderr.log 内容为空。

我在重启 supervisor 后,进入 supervisorctl ,提示“ elasticsearch FATAL Exited too quickly (process log may have details)”
MrMike
2017-04-15 22:26:56 +08:00
elasticsearch 安装后,在 /usr/share/elasticsearch/就没有 config 这个文件的。
zsz
2017-04-15 22:35:35 +08:00
1. 你命令行成功启动过 es 么?
2.如果你只是在 systemd 中成功启动过,你的配置文件应该在系统级的目录下,找到他,先用命令行能启动,再把命令配置进去, es 在命令行可以指定配置文件的
MrMike
2017-04-15 22:45:04 +08:00
@zsz ES 是可以正常启动和关闭的。我再看看这个错误提示到底是咋回事。。
MrMike
2017-04-15 22:45:37 +08:00
@zsz 我试试用命令行启动下。
MrMike
2017-04-15 22:59:06 +08:00
@zsz
@a128445

配置文件改成这样的:

[program:elasticsearch]
command=/etc/init.d/elasticsearch start
directory=/usr/share/elasticsearch
autostart=true
autorestart=true
startsecs=10
startretries=3
redirect_stderr=true
user=root
stdout_logfile=/home/demoer/log/elasticsearch/elasticsearch-stdout.log
stderr_logfile=/home/demoer/log/elasticsearch/elasticsearch-stderr.log

我手动关闭 es 后,等了几秒钟 es 没有启动,就使用 supervisorctl restart elasticsearch 启动,
elasticsearch: ERROR (not running)
elasticsearch: ERROR (spawn error)

得到这样的错误提示,但是 es 却重新启动了。不能自动启动 es 呢。。
MrMike
2017-04-15 23:12:07 +08:00
@zsz stop es 后,我目前的配置,只能手动执行 supervisorctl reload ,才能再让 es 启动。
zsz
2017-04-15 23:16:06 +08:00
1. 上面我指出过 supervisor 中 command 不能使用 systemctl 或者 init.d 的方式,因为这两种是 daemon 运行,命令执行完就返回了
2. 你加我上面的发群我用 qq 跟你说,这样解释太慢了,非商业化的群,不用担心
MrMike
2017-04-15 23:34:39 +08:00
@zsz 加了,回你信息了

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/354995

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX