Using the apt-get
package for ElasticSearh, how can I configure the service to restart itself automatically after crashing on Ubuntu?
Restart on failure option is missing in the default service of elasticsearch.
So, We can add Restart=always option in the service.
Edit elasticsearch service unit file using the command sudo systemctl edit elasticsearch.service
. This command will create a file /etc/systemd/system/elasticsearch.service.d/override.conf
.
Now, add the following lines in the unit file.
[Service]
Restart=always
sudo systemctl daemon-reload
sudo systemctl cat elasticsearch.service
.We can use Restart= always, on-abnormal, on-success, on-failure, etc based on the requirement. Reference.
Editing unit file - Reference
Auto restart elasticsearch services in 7.14.1:
Go to:
nano /usr/lib/systemd/system/elasticsearch.service
The location of the service file is changed in 7.14.1
Then add this line to the service file:
[Service]
Restart=always
After that save the file and restart the elasticsearch service.
Now you are good to go. (After this there won't be any crash)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With