Elasticsearch configuration service starts automatically
in Tutorial with 0 comment
Elasticsearch configuration service starts automatically
in Tutorial with 0 comment

The default elastic search yum installation mode, Elasticsearch.service does not have the function of automatic restart, that is, once the node OOM continues to run GC and then crashes, The elasticsearch service will not be restarted automatically. It needs to be started manually. The following is a tutorial to automatically start the Elastic search configuration service.

By default, you have installed elastic search through yum.

The default path of the systemd service file is /usr/lib/systemd/system/elasticsearch.service

1. Check the function of systemd

The centOS version is different, and the version of the built-in systemd is also different. For example, the systemd of centOS 7.1 is 208, but it is not systemctl edit and systemctl cat Function of

 systemctl -h

If any edit NAME... Edit one or more unit files , you can use systemctl edit To create override.conf , as follows:

 sudo systemctl edit elasticsearch.service

If not, you need to create it manually override.conf , as follows:

 mkdir /etc/systemd/system/elasticsearch.service.d/ touch /etc/systemd/system/elasticsearch.service.d/override.conf

2. Add content

open override.conf

 vim /etc/systemd/system/elasticsearch.service.d/override.conf

Add the following

 [Service] Restart=always

Save Exit

3. Refresh daemon

 sudo systemctl daemon-reload

4. Check whether the configuration is successful

 sudo systemctl status elasticsearch.service

The information is as follows:

 elasticsearch.service - Elasticsearch Loaded: loaded (/usr/lib/systemd/system/elasticsearch.service;  enabled) Drop-In: /etc/systemd/system/elasticsearch.service.d └─override.conf Active: active (running) since IV 2018-05-03 18:00:31 CST; 20h ago Docs:  http://www.elastic.co Main PID: 28105 (java) CGroup: /system.slice/elasticsearch.service

Found Drop-In: /etc/systemd/system/elasticsearch.service.d └─override.conf , indicating that the configuration is successful.

If only the server is powered on to start Elastic search, you only need to execute the following command

 sudo systemctl enable elasticsearch.service
Responses