【问题标题】:how to auto restart elasticsearch search once crashed on linux server?一旦在 Linux 服务器上崩溃,如何自动重启 elasticsearch 搜索?
【发布时间】:2021-09-08 00:08:50
【问题描述】:

一旦我的 elasticsearch 在 linux 服务器上崩溃。它给了我以下错误:

Elasticsearch\Common\Exceptions\NoNodesAvailableException:/var/www/laravel/vendor/elasticsearch/elasticsearch/src/Elasticsearch/ConnectionPool/StaticNoPingConnectionPool.php:51 No alive nodes found in your cluster 

解决这个问题我需要重置整个服务器。

我想要解决方案,因为我的 elasticsearch 服务会在崩溃时自动重启。

我的服务器配置:

Linux name 3.10.0-514.21.1.el7.x86_64 #1 SMP Thu May 25 17:04:51 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux

如何在服务器上设置一些在崩溃时自动重启我的弹性搜索的东西。

【问题讨论】:

    标签: linux elasticsearch service server centos


    【解决方案1】:

    崩溃或宕机后自动重启elasticsearch服务的步骤:

    1) 使用以下命令编辑elasticsearch服务单元文件

    sudo systemctl edit elasticsearch.service 
    

    这个命令会创建一个文件

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

    2) 现在,在单元文件中添加以下行。

    [Service]
    Restart=always
    

    3) 保存文件。

    ctrl+x  > Y > Enter
    

    4) 使用命令刷新单元文件

    sudo systemctl daemon-reload
    

    5) 可以使用命令检查更改

    sudo systemctl cat elasticsearch.service
    

    【讨论】:

      【解决方案2】:

      在 7.14.1 中自动重启 elasticsearch 服务:

      转到:

      nano /usr/lib/systemd/system/elasticsearch.service 
      

      服务文件的位置在 7.14.1 中有所改变。

      然后将这一行添加到服务文件中:

      [Service]
      Restart=always
      

      然后保存文件并重启elasticsearch服务。

      现在你可以走了。 (在此之后不会有任何崩溃)

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2019-08-23
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2021-08-07
        相关资源
        最近更新 更多