laravel scout elasticsearch错误500“所有碎片失败”

vcudknz3  于 2021-06-10  发布在  ElasticSearch
关注(0)|答案(1)|浏览(358)

每当我试图通过laravel的scout包使用elasticsearch时,就会出现这个错误。
一切都可以在本地主机上运行,因为我不必为ElasticSearch设置任何节点或任何东西,但当我尝试在远程服务器上执行相同的操作时,这就是我得到的结果。

{
  "message": "{\"error\":{\"root_cause\":[],\"type\":\"search_phase_execution_exception\",\"reason\":\"all shards failed\",\"phase\":\"query\",\"grouped\":true,\"failed_shards\":[]},\"status\":503}",
  "exception": "Elasticsearch\\Common\\Exceptions\\ServerErrorResponseException",
  "file": "/home/mydomain/domains/api.mydomain.dev/public_html/myproject/vendor/elasticsearch/elasticsearch/src/Elasticsearch/Connections/Connection.php",
  "line": 671,
  "trace": [
    {
      "file": "/home/mydomain/domains/api.mydomain.dev/public_html/myproject/vendor/elasticsearch/elasticsearch/src/Elasticsearch/Connections/Connection.php",
      "line": 330,
      "function": "process5xxError",
      "class": "Elasticsearch\\Connections\\Connection",
      "type": "->"
    },
    {
      "file": "/home/mydomain/domains/api.mydomain.dev/public_html/myproject/vendor/react/promise/src/FulfilledPromise.php",
      "line": 28,
      "function": "Elasticsearch\\Connections\\{closure}",
      "class": "Elasticsearch\\Connections\\Connection",
      "type": "->"
    },
    {
      "file": "/home/mydomain/domains/api.mydomain.dev/public_html/myproject/vendor/ezimuel/ringphp/src/Future/CompletedFutureValue.php",
      "line": 55,
      "function": "then",
      "class": "React\\Promise\\FulfilledPromise",
      "type": "->"
    },
    {
      "file": "/home/mydomain/domains/api.mydomain.dev/public_html/myproject/vendor/ezimuel/ringphp/src/Core.php",
      "line": 341,
      "function": "then",
      "class": "GuzzleHttp\\Ring\\Future\\CompletedFutureValue",
      "type": "->"
    },
    {
      "file": "/home/mydomain/domains/api.mydomain.dev/public_html/myproject/vendor/elasticsearch/elasticsearch/src/Elasticsearch/Connections/Connection.php",
      "line": 339,
      "function": "proxy",
      "class": "GuzzleHttp\\Ring\\Core",
      "type": "::"
    },
    {
      "file": "/home/mydomain/domains/api.mydomain.dev/public_html/myproject/vendor/elasticsearch/elasticsearch/src/Elasticsearch/Connections/Connection.php",
      "line": 235,
      "function": "Elasticsearch\\Connections\\{closure}",
      "class": "Elasticsearch\\Connections\\Connection",
      "type": "->"
    },
    {
      "file": "/home/mydomain/domains/api.mydomain.dev/public_html/myproject/vendor/elasticsearch/elasticsearch/src/Elasticsearch/Transport.php",
      "line": 115,
      "function": "performRequest",
      "class": "Elasticsearch\\Connections\\Connection",
      "type": "->"
    },
    {
      "file": "/home/mydomain/domains/api.mydomain.dev/public_html/myproject/vendor/elasticsearch/elasticsearch/src/Elasticsearch/Client.php",
      "line": 1587,
      "function": "performRequest",
      "class": "Elasticsearch\\Transport",
      "type": "->"
    },
    {
      "file": "/home/mydomain/domains/api.mydomain.dev/public_html/myproject/vendor/elasticsearch/elasticsearch/src/Elasticsearch/Client.php",
      "line": 1212,
      "function": "performRequest",
      "class": "Elasticsearch\\Client",
      "type": "->"
    },
    {
      "file": "/home/mydomain/domains/api.mydomain.dev/public_html/myproject/vendor/tamayo/laravel-scout-elastic/src/Engines/ElasticsearchEngine.php",
      "line": 168,
      "function": "search",
      "class": "Elasticsearch\\Client",
      "type": "->"
    },
    {
      "file": "/home/mydomain/domains/api.mydomain.dev/public_html/myproject/vendor/tamayo/laravel-scout-elastic/src/Engines/ElasticsearchEngine.php",
      "line": 94,
      "function": "performSearch",
      "class": "Tamayo\\LaravelScoutElastic\\Engines\\ElasticsearchEngine",
      "type": "->"
    },
    {
      "file": "/home/mydomain/domains/api.mydomain.dev/public_html/myproject/vendor/laravel/scout/src/Engines/Engine.php",
      "line": 97,
      "function": "search",
      "class": "Tamayo\\LaravelScoutElastic\\Engines\\ElasticsearchEngine",
      "type": "->"
    },
    {
      "file": "/home/mydomain/domains/api.mydomain.dev/public_html/myproject/vendor/laravel/scout/src/Builder.php",
      "line": 251,
      "function": "get",
      "class": "Laravel\\Scout\\Engines\\Engine",
      "type": "->"
    },
    {
      "file": "/home/mydomain/domains/api.mydomain.dev/public_html/myproject/app/Http/Controllers/ProductController.php",
      "line": 15,
      "function": "get",
      "class": "Laravel\\Scout\\Builder",
      "type": "->"
    },
    {
      "file": "/home/mydomain/domains/api.mydomain.dev/public_html/myproject/vendor/laravel/framework/src/Illuminate/Routing/Controller.php",
      "line": 54,
      "function": "search",
      "class": "App\\Http\\Controllers\\ProductController",
      "type": "->"
    },
    {
      "file": "/home/mydomain/domains/api.mydomain.dev/public_html/myproject/vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php",
      "line": 45,
      "function": "callAction",
      "class": "Illuminate\\Routing\\Controller",
      "type": "->"
    },
    {
      "file": "/home/mydomain/domains/api.mydomain.dev/public_html/myproject/vendor/laravel/framework/src/Illuminate/Routing/Route.php",
      "line": 239,
      "function": "dispatch",
      "class": "Illuminate\\Routing\\ControllerDispatcher",
      "type": "->"
    },
    {
      "file": "/home/mydomain/domains/api.mydomain.dev/public_html/myproject/vendor/laravel/framework/src/Illuminate/Routing/Route.php",
      "line": 196,
      "function": "runController",
      "class": "Illuminate\\Routing\\Route",
      "type": "->"
    },
    {
      "file": "/home/mydomain/domains/api.mydomain.dev/public_html/myproject/vendor/laravel/framework/src/Illuminate/Routing/Router.php",
      "line": 685,
      "function": "run",
      "class": "Illuminate\\Routing\\Route",
      "type": "->"
    },
    {
      "file": "/home/mydomain/domains/api.mydomain.dev/public_html/myproject/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php",
      "line": 128,
      "function": "Illuminate\\Routing\\{closure}",
      "class": "Illuminate\\Routing\\Router",
      "type": "->"
    },
    {
      "file": "/home/mydomain/domains/api.mydomain.dev/public_html/myproject/vendor/laravel/framework/src/Illuminate/Routing/Middleware/SubstituteBindings.php",
      "line": 41,
      "function": "Illuminate\\Pipeline\\{closure}",
      "class": "Illuminate\\Pipeline\\Pipeline",
      "type": "->"
    },
    {
      "file": "/home/mydomain/domains/api.mydomain.dev/public_html/myproject/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php",
      "line": 167,
      "function": "handle",
      "class": "Illuminate\\Routing\\Middleware\\SubstituteBindings",
      "type": "->"
    },
    {
      "file": "/home/mydomain/domains/api.mydomain.dev/public_html/myproject/vendor/laravel/framework/src/Illuminate/Routing/Middleware/ThrottleRequests.php",
      "line": 59,
      "function": "Illuminate\\Pipeline\\{closure}",
      "class": "Illuminate\\Pipeline\\Pipeline",
      "type": "->"
    },
    {
      "file": "/home/mydomain/domains/api.mydomain.dev/public_html/myproject/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php",
      "line": 167,
      "function": "handle",
      "class": "Illuminate\\Routing\\Middleware\\ThrottleRequests",
      "type": "->"
    },
    {
      "file": "/home/mydomain/domains/api.mydomain.dev/public_html/myproject/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php",
      "line": 103,
      "function": "Illuminate\\Pipeline\\{closure}",
      "class": "Illuminate\\Pipeline\\Pipeline",
      "type": "->"
    },
    {
      "file": "/home/mydomain/domains/api.mydomain.dev/public_html/myproject/vendor/laravel/framework/src/Illuminate/Routing/Router.php",
      "line": 687,
      "function": "then",
      "class": "Illuminate\\Pipeline\\Pipeline",
      "type": "->"
    },
    {
      "file": "/home/mydomain/domains/api.mydomain.dev/public_html/myproject/vendor/laravel/framework/src/Illuminate/Routing/Router.php",
      "line": 662,
      "function": "runRouteWithinStack",
      "class": "Illuminate\\Routing\\Router",
      "type": "->"
    },
    {
      "file": "/home/mydomain/domains/api.mydomain.dev/public_html/myproject/vendor/laravel/framework/src/Illuminate/Routing/Router.php",
      "line": 628,
      "function": "runRoute",
      "class": "Illuminate\\Routing\\Router",
      "type": "->"
    },
    {
      "file": "/home/mydomain/domains/api.mydomain.dev/public_html/myproject/vendor/laravel/framework/src/Illuminate/Routing/Router.php",
      "line": 617,
      "function": "dispatchToRoute",
      "class": "Illuminate\\Routing\\Router",
      "type": "->"
    },
    {
      "file": "/home/mydomain/domains/api.mydomain.dev/public_html/myproject/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php",
      "line": 165,
      "function": "dispatch",
      "class": "Illuminate\\Routing\\Router",
      "type": "->"
    },
    {
      "file": "/home/mydomain/domains/api.mydomain.dev/public_html/myproject/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php",
      "line": 128,
      "function": "Illuminate\\Foundation\\Http\\{closure}",
      "class": "Illuminate\\Foundation\\Http\\Kernel",
      "type": "->"
    },
    {
      "file": "/home/mydomain/domains/api.mydomain.dev/public_html/myproject/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php",
      "line": 21,
      "function": "Illuminate\\Pipeline\\{closure}",
      "class": "Illuminate\\Pipeline\\Pipeline",
      "type": "->"
    },
    {
      "file": "/home/mydomain/domains/api.mydomain.dev/public_html/myproject/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php",
      "line": 167,
      "function": "handle",
      "class": "Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest",
      "type": "->"
    },
    {
      "file": "/home/mydomain/domains/api.mydomain.dev/public_html/myproject/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php",
      "line": 21,
      "function": "Illuminate\\Pipeline\\{closure}",
      "class": "Illuminate\\Pipeline\\Pipeline",
      "type": "->"
    },
    {
      "file": "/home/mydomain/domains/api.mydomain.dev/public_html/myproject/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php",
      "line": 167,
      "function": "handle",
      "class": "Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest",
      "type": "->"
    },
    {
      "file": "/home/mydomain/domains/api.mydomain.dev/public_html/myproject/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/ValidatePostSize.php",
      "line": 27,
      "function": "Illuminate\\Pipeline\\{closure}",
      "class": "Illuminate\\Pipeline\\Pipeline",
      "type": "->"
    },
    {
      "file": "/home/mydomain/domains/api.mydomain.dev/public_html/myproject/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php",
      "line": 167,
      "function": "handle",
      "class": "Illuminate\\Foundation\\Http\\Middleware\\ValidatePostSize",
      "type": "->"
    },
    {
      "file": "/home/mydomain/domains/api.mydomain.dev/public_html/myproject/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/CheckForMaintenanceMode.php",
      "line": 63,
      "function": "Illuminate\\Pipeline\\{closure}",
      "class": "Illuminate\\Pipeline\\Pipeline",
      "type": "->"
    },
    {
      "file": "/home/mydomain/domains/api.mydomain.dev/public_html/myproject/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php",
      "line": 167,
      "function": "handle",
      "class": "Illuminate\\Foundation\\Http\\Middleware\\CheckForMaintenanceMode",
      "type": "->"
    },
    {
      "file": "/home/mydomain/domains/api.mydomain.dev/public_html/myproject/vendor/fruitcake/laravel-cors/src/HandleCors.php",
      "line": 57,
      "function": "Illuminate\\Pipeline\\{closure}",
      "class": "Illuminate\\Pipeline\\Pipeline",
      "type": "->"
    },
    {
      "file": "/home/mydomain/domains/api.mydomain.dev/public_html/myproject/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php",
      "line": 167,
      "function": "handle",
      "class": "Fruitcake\\Cors\\HandleCors",
      "type": "->"
    },
    {
      "file": "/home/mydomain/domains/api.mydomain.dev/public_html/myproject/vendor/fideloper/proxy/src/TrustProxies.php",
      "line": 57,
      "function": "Illuminate\\Pipeline\\{closure}",
      "class": "Illuminate\\Pipeline\\Pipeline",
      "type": "->"
    },
    {
      "file": "/home/mydomain/domains/api.mydomain.dev/public_html/myproject/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php",
      "line": 167,
      "function": "handle",
      "class": "Fideloper\\Proxy\\TrustProxies",
      "type": "->"
    },
    {
      "file": "/home/mydomain/domains/api.mydomain.dev/public_html/myproject/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php",
      "line": 103,
      "function": "Illuminate\\Pipeline\\{closure}",
      "class": "Illuminate\\Pipeline\\Pipeline",
      "type": "->"
    },
    {
      "file": "/home/mydomain/domains/api.mydomain.dev/public_html/myproject/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php",
      "line": 140,
      "function": "then",
      "class": "Illuminate\\Pipeline\\Pipeline",
      "type": "->"
    },
    {
      "file": "/home/mydomain/domains/api.mydomain.dev/public_html/myproject/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php",
      "line": 109,
      "function": "sendRequestThroughRouter",
      "class": "Illuminate\\Foundation\\Http\\Kernel",
      "type": "->"
    },
    {
      "file": "/home/mydomain/domains/api.mydomain.dev/public_html/myproject/public/index.php",
      "line": 55,
      "function": "handle",
      "class": "Illuminate\\Foundation\\Http\\Kernel",
      "type": "->"
    }
  ]
}

下面是我检索结果的方法

public function search(Request $request)
    {
        $products = Product::search($request->get('label'))->get();

        return response()->json($products);
    }

我通过导入产品的表数据 php artisan scout:import 'App\Models\Products' 它给了我一个成功的信息。所以一切似乎都是正确的。 GET /_cluster/allocation/explain?pretty 给了我

{
  "index": "products",
  "shard": 0,
  "primary": false,
  "current_state": "unassigned",
  "unassigned_info": {
    "reason": "INDEX_CREATED",
    "at": "2020-11-07T17:32:11.894Z",
    "last_allocation_status": "no_attempt"
  },
  "can_allocate": "no",
  "allocate_explanation": "cannot allocate because allocation is not permitted to any of the nodes"
}

“得到/簇/健康?漂亮”给了我

{
  "cluster_name": "myCluster",
  "status": "red",
  "timed_out": false,
  "number_of_nodes": 1,
  "number_of_data_nodes": 0,
  "active_primary_shards": 0,
  "active_shards": 0,
  "relocating_shards": 0,
  "initializing_shards": 0,
  "unassigned_shards": 2,
  "delayed_unassigned_shards": 0,
  "number_of_pending_tasks": 0,
  "number_of_in_flight_fetch": 0,
  "task_max_waiting_in_queue_millis": 0,
  "active_shards_percent_as_number": 0.0
}

所有的东西都可以在windows上运行,因为我需要做的就是 .\bin\elasticsearch.bat 但是centos让我头疼。

6tdlim6h

6tdlim6h1#

结果 /_cluster/health 显示单个节点未配置为数据节点。

"number_of_data_nodes": 0,

看看你在上一个问题中的配置,你有 node.roles: [master] ,因此这使您的节点作为 master 仅节点,若要摄取数据,需要具有角色的节点 data .
因为只有一个节点,所以没有理由设置 node.roles 选项。
注解这行并重新启动elasticsearch,它将执行节点可以执行的所有角色。
也可以设置为 master 以及 data 只在你需要的时候。

node.roles: [master, data]

相关问题