elasticsearch - 弹性搜索“master_not_discovered_exception”centos
问题描述
删除 /var/lib/elasticseach 后:在此处更正
我不得不删除它,因为我在尝试从索引中搜索时遇到了一些错误,并且一些 stackoverflow 答案表明最好删除数据路径并重新启动 elasticsearch。
我在 centos 上,我试图为 laravel scout 配置它。
当我尝试做任何事情PUT /index
时GET /_cluster/health?pretty
{
"error": {
"root_cause": [
{
"type": "master_not_discovered_exception",
"reason": null
}
],
"type": "master_not_discovered_exception",
"reason": null
},
"status": 503
}
这是我的 elasticsearch.yml
# ======================== Elasticsearch Configuration =========================
#
# NOTE: Elasticsearch comes with reasonable defaults for most settings.
# Before you set out to tweak and tune the configuration, make sure you
# understand what are you trying to accomplish and the consequences.
#
# The primary way of configuring a node is via this file. This template lists
# the most important settings you may want to configure for a production cluster.
#
# Please consult the documentation for further information on configuration options:
# https://www.elastic.co/guide/en/elasticsearch/reference/index.html
#
# ---------------------------------- Cluster -----------------------------------
#
# Use a descriptive name for your cluster:
#
cluster.name: myCluster
#
# ------------------------------------ Node ------------------------------------
#
# Use a descriptive name for the node:
#
node.name: myNode
node.roles: [master]
#
# Add custom attributes to the node:
#
#node.attr.rack: r1
#
# ----------------------------------- Paths ------------------------------------
#
# Path to directory where to store the data (separate multiple locations by comma):
#
path.data: /var/lib/elasticsearch
#
# Path to log files:
#
path.logs: /var/log/elasticsearch
#
# ----------------------------------- Memory -----------------------------------
#
# Lock the memory on startup:
#
#bootstrap.memory_lock: true
#
# Make sure that the heap size is set to about half the memory available
# on the system and that the owner of the process is allowed to use this
# limit.
#
# Elasticsearch performs poorly when the system is swapping the memory.
#
# ---------------------------------- Network -----------------------------------
#
# Set the bind address to a specific IP (IPv4 or IPv6):
#
#transport.host: localhost
network.host: 0.0.0.0
# Set a custom port for HTTP:
#
#http.port: 9200
#
# For more information, consult the network module documentation.
#
# --------------------------------- Discovery ----------------------------------
#
# Pass an initial list of hosts to perform discovery when this node is started:
# The default list of hosts is ["127.0.0.1", "[::1]"]
#
discovery.seed_hosts: ["127.0.0.1", "[::1]"]
#
# Bootstrap the cluster using an initial set of master-eligible nodes:
#
#cluster.initial_master_nodes: ["node-1", "node-2"]
#
# For more information, consult the discovery and cluster formation module documentation.
#
# ---------------------------------- Gateway -----------------------------------
#
# Block initial recovery after a full cluster restart until N nodes are started:
#
#gateway.recover_after_nodes: 3
#
# For more information, consult the gateway module documentation.
#
# ---------------------------------- Various -----------------------------------
#
# Require explicit names when deleting indices:
#
#action.destructive_requires_name: true
集群日志
[2020-11-07T13:03:59,571][WARN ][r.suppressed ] [NODE] path: /products, params: {index=products}
org.elasticsearch.discovery.MasterNotDiscoveredException: null
at org.elasticsearch.action.support.master.TransportMasterNodeAction$AsyncSingleAction$2.onTimeout(TransportMasterNodeAction.java:220) [elasticsearch-7.9.2.jar:7.9.2]
at org.elasticsearch.cluster.ClusterStateObserver$ContextPreservingListener.onTimeout(ClusterStateObserver.java:325) [elasticsearch-7.9.2.jar:7.9.2]
at org.elasticsearch.cluster.ClusterStateObserver$ObserverClusterStateListener.onTimeout(ClusterStateObserver.java:252) [elasticsearch-7.9.2.jar:7.9.2]
at org.elasticsearch.cluster.service.ClusterApplierService$NotifyTimeout.run(ClusterApplierService.java:605) [elasticsearch-7.9.2.jar:7.9.2]
at org.elasticsearch.common.util.concurrent.ThreadContext$ContextPreservingRunnable.run(ThreadContext.java:678) [elasticsearch-7.9.2.jar:7.9.2]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1130) [?:?]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:630) [?:?]
at java.lang.Thread.run(Thread.java:832) [?:?]
[2020-11-07T13:04:05,597][WARN ][o.e.c.c.ClusterFormationFailureHelper] [NODE] master not discovered yet, this node has not previously joined a bootstrapped (v7+) cluster, and [cluster.initial_master_nodes] is empty on this node: have discovered [{NODE}{2hEi19WjSn2EsdfsdfYZmmbf158Q}{ZeP6OSGJTa24ggregerghaNOMlYOng}{SERVER_IP}{SERVER_IP:9300}{m}{xpack.installed=true, transform.node=false}]; discovery will continue using [127.0.0.1:9300, [::1]:9300] from hosts providers and [{NODE}{2hazEi19WjSnergza2EYgZmmbfr158Q}{ZeP6OSGJTa24haNOddMlYOng}{SERVER_IP}{SERVER_IP:9300}{m}{xpack.installed=true, transform.node=false}] from last-known cluster state; node term 0, last-accepted version 0 in term 0
我对弹性相当陌生,而且我想要实现的目标太复杂了。
解决方案
由于您删除了数据目录,因此您的节点从未加入集群或之前被引导过,这就是它在日志行中所说的内容。
您需要设置该选项cluster.initial_master_nodes
,以便您的节点知道哪些节点是初始主节点。
取消注释该行cluster.initial_master_nodes
并添加您的节点的名称。
cluster.initial_master_nodes: ["myNode"]
这将使您的节点引导自己作为主节点。
此外,您正在设置选项network.host
,这将使 elasticsearch 假定您正在运行到生产模式并将强制进行一系列检查,您需要检查您是否在文档的重要系统配置部分中完成了所有操作,否则您的节点将不会t开始并给你一些例外。
如果您通过 访问您的节点localhost
,您可以注释该network.host
选项并在开发模式下使用它。
推荐阅读
- c# - 如何使用带有泛型约束的 NUnit 测试用例?
- vb.net - 值不能为空。参数名称:图像
- node.js - 限制 Node.JS HTTP 服务器上的上传带宽
- qnx - QNX 7.0 的 Momentics 在哪里?
- flutter - 在 Flutter 中使用设置的 FPS 绘制大量简单、填充颜色的矩形的最高效方法是什么?
- java - 在循环中初始化双精度会给出错误“变量可能尚未初始化”
- angular - Angular 重新加载页面 ngSubmit
- python - python pandas数据框:将函数返回元组分配给数据框的两列
- postgresql - 使用物化视图改进 jsonb 索引和查询
- excel - 将数据透视表范围从一个工作表复制到另一个工作表。代码正在复制活动工作表数据