So I had the exact same issue as described in https://discuss.elastic.co/t/consistent-restarts-of-logstash-with-high-cpu-recorded/86597 :
I'm running Logstash as a service on Ubuntu. And I'm launching it by
sudo systemctl start logstash.service
My task was simple: import data from jdbc (MySQL) into Elasticsearch in a one shot manner (so no scheduling option. no cron timer). So as in the link above, I'm using a JDBC input filter. And the elasticsearch output filter.
I managed to get it to work well when I launched logstash directly through command line (logstash -f conf_file): logstash starts, imports the data and shutdown. Just as expected.
Now, when I tried to do the same when I was launching logstash as a service, it would keep importing the data and restarting over and over again.
The link above provide a solution but it's actually wrong. It says that when no "schedule" option is specified, a default 1 minute timer is used. This is in direct contradiction with what the documentation says here :
There is no schedule by default. If no schedule is given, then the statement is run exactly once.
Here is what I think is the explanation: when logstash is launched as a service and the config file has no "schedule" option, once it has finished importing the data, logstash simply shutdowns by itself. The problem is that because it was started as a service, the service manager (systemctl) detects that the service is offline and "resurrect it" over and over again.
When a schedule option is used, the service says alive and therefore, there is no issue.
还有一种情况:logstash conf文件没有正确写入时,logstash不断重启,所以如果你有这个问题,首先检查syntaxe是否正确
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.