今早在虛擬機剛裝了 ElasticSearch 7.10,我發現每次在重開機的時候,ElasticSearch 的服務會因為連線逾時而啟動失敗。
錯誤訊息
截圖:
完成的日誌記錄:
Warning: The unit file, source configuration file or drop-ins of elasticsearch.service changed on disk. Run 'systemctl daemon-reload' to reload units.
● elasticsearch.service - Elasticsearch
Loaded: loaded (/usr/lib/systemd/system/elasticsearch.service; enabled; vendor preset: enabled)
Active: failed (Result: timeout) since Tue 2020-12-08 09:18:55 CST; 24min ago
Docs: https://www.elastic.co
Process: 889 ExecStart=/usr/share/elasticsearch/bin/systemd-entrypoint -p ${PID_DIR}/elasticsearch.pid --quiet (code=killed, signal=TERM)
Main PID: 889 (code=killed, signal=TERM)
Tasks: 0 (limit: 3570)
CGroup: /system.slice/elasticsearch.service
Dec 08 09:17:40 terrylin systemd[1]: Starting Elasticsearch...
Dec 08 09:18:55 terrylin systemd[1]: elasticsearch.service: Start operation timed out. Terminating.
Dec 08 09:18:55 terrylin systemd[1]: elasticsearch.service: Failed with result 'timeout'.
Dec 08 09:18:55 terrylin systemd[1]: Failed to start Elasticsearch.
解決方法
修改 ElasticSearch 設定
編輯 ElasticSearch 服務的設定檔。
$ vi /usr/lib/systemd/system/elasticsearch.service
TimeoutStartSec
這個欄位設定了在啟始服務時所等待的時間,預設的時間是 90 秒,加大這個值適當的數字,以此例來說,我設為 500。
重啟 systemd
檔案存檔接著重啟 systemd 的組態設定。
$ systemctl daemon-reload
檢查開機時的 timeout 值。
$ systemctl show elasticsearch | grep ^Timeout
TimeoutStartUSec=8min 20s
TimeoutStopUSec=infinity
這樣問題就解決囉。
留言