Table of Contents
1. Introduction
In production environment in might happened that elasticsearch process will take way to long to start and therefore you as admin will see error
Job for elasticsearch.service failed because a timeout was exceeded.
This can be easily fixed by increasing timeout value.
2. Check default values
Before changing anything please have a look at current probably default values.
grep Timeout /usr/lib/systemd/system/elasticsearch.service
Above will return “TimeoutStartSec=900” or other value. In the past it was 180 seconds, now it is 900. That value can be overwritten through configuration file “/etc/systemd/system/elasticsearch.service.d/elasticsearch.conf”
3. Reproduce issue
To change that values and cause timeout intentionally put below values inside /etc/systemd/system/elasticsearch.service.d/elasticsearch.conf
TimeoutStartSec=15
ExecStartPre=/bin/sleep 15
Or just TimeoutStartSec=1 as elasticsearch will not start so quickly. Then run commands to start
systemctl daemon-reload
service elasticsearch start
4. Increase value
To fix timeout issue finally set value high enough. 15 minutes for startup is more that enough and in healthy cluster should not cause any issue but for time being it is easier and cheaper for sure to increase timeout instead adding more nodes to cluster. So set
TimeoutStartSec=15
and start again
systemctl daemon-reload
service elasticsearch start
5. Systemd version greater than 238
Although I found in docs that version of systemd greater than 238 should support the timeout extension mechanism, it is fact that for me default timeout equal 900 was causing error if I put sleep command of 15 minutes. It means timeout was not automatically extended. To check your current version of systemd run
yum info systemd
# or
systemctl --version
6. Summary
In below article you have read how to increase timeout for elasticsearch process and therefore how to fix this kind of issues in future. Hope it was helpful for you.