【问题标题】:Elasticserch Master not discoverd exception - Version 2.3.0Elasticsearch Master 未发现异常 - 版本 2.3.0
【发布时间】:2016-06-30 18:41:37
【问题描述】:

这是我第一次使用 elasticsearch。 以下是我的环境/配置。

  1. 我有 3 个 EC2 Ubuntu 14.04 实例。
  2. 我已经下载并解压了 elasticsearch-2.3.0.tar.gz。
  3. 我已经更改了每个实例中 elasticsearch/config 下的 elasticsearch.yml 文件。 我对每个 elasticsearch.yml 文件进行了以下更改。

3.1. EC2 实例编号 1(我的客户端节点)

cluster.name: MyCluster
node.name: Client
node.master: false
node.data: false
path.data: /home/ubuntu/elasticsearch/data/elasticsearch/nodes/0

discovery.zen.ping.multicast.enabled: false
discovery.zen.ping.unicast.hosts: ["aa.aa.aa.aa" , "aa.aa.aaa.aa" , "aaa.a.aa.aa"]

在上面的括号中,我提供了所有 3 个实例的 IP。

3.2. EC2 实例编号 2(我的主节点)

cluster.name: MyCluster
node.name: Master
node.master: true
node.data: true
path.data: /home/ubuntu/elasticsearch/data/elasticsearch/nodes/0

discovery.zen.ping.multicast.enabled: false
discovery.zen.ping.unicast.hosts: ["aa.aa.aa.aa" , "aa.aa.aaa.aa" , "aaa.a.aa.aa"]

在上面的括号中,我提供了所有 3 个实例的 IP。 请注意,我已经制作了 node.data: true (according to this link)

3.3. EC2 实例编号 3(我的数据节点)

cluster.name: MyCluster
node.name: slave_1
node.master: false
node.data: true
path.data: /home/ubuntu/elasticsearch/data/elasticsearch/nodes/0

discovery.zen.ping.multicast.enabled: false
discovery.zen.ping.unicast.hosts: ["aa.aa.aa.aa" , "aa.aa.aaa.aa" , "aaa.a.aa.aa"]

在上面的括号中,我提供了所有 3 个实例的 IP。

  1. 完成此配置后,我在每个实例上运行 elasticsearch 服务,从数据节点开始,然后是主节点和客户端节点。
  2. 如果我使用 curl http://localhost:9200 检查节点状态,我会得到表明节点正在运行的 json。

  1. 但是当我使用 curl -XGET 'http://localhost:9200/_cluster/health?pretty=true' 检查集群运行状况时,我的客户端实例上出现以下错误。

我希望我的问题很清楚,并且我正朝着正确的方向前进。

谢谢

【问题讨论】:

  • 刚开始时,您绝对应该运行最新的 ES 2.3.x:2.3.3。

标签: amazon-web-services elasticsearch amazon-ec2 elasticsearch-2.0


【解决方案1】:

Elasticsearch 2.0+ 默认将所有套接字绑定到localhost。这意味着,默认情况下,该机器之外的任何东西都无法与之对话。

这明确用于安全目的和简单的开发设置。在本地,它工作得很好,但是当它变得更严重时,您需要为您的环境配置它。这也是您可以通过localhost 与节点对话的原因。 基本上,当您希望使用network settings 跨越其他机器的多个节点时,您需要这个。这适用于 ES 2.3+:

network:
  bind_host: [ _local_, _global_ ]
  publish_host: _global_

然后其他节点可以与公共 IP 通信,但您仍然拥有 localhost 来简化在本地与节点的工作(例如,您——人类——在通过 SSH 连接到一个盒子时永远不必知道 IP)。

由于您在 EC2 中使用 Elasticsearch 2.0+,我建议您使用 you install the cloud-aws plugin(未来的读者请注意:此插件在 ES 5.x 中被分解为 3 个单独的插件!)。

$ bin/plugin install cloud-aws

安装后,您可以更加了解 EC2 实例。借助这种强大的功能,您可以为 ES 配置添加更多细节:

# Guarantee that the plugin is installed
plugin.mandatory: cloud-aws

# Discovery / AWS EC2 Settings
discovery
  type: ec2
  ec2:
    availability_zones: [ "us-east-1a", "us-east-1b" ]
    groups: [ "my_security_group1", "my_security_group2" ]

# The keys here need to be replaced with your keys
cloud:
  aws
    access_key: AKVAIQBF2RECL7FJWGJQ
    secret_key: vExyMThREXeRMm/b/LRzEB8jWwvzQeXgjqMX+6br
    region: us-east-1
  node.auto_attributes: true

# Bind to the network on whatever IP you want to allow connections on.
# You _should_ only want to allow connections from within the network
# so you only need to bind to the private IP
node.host: _ec2:privateIp_

# You can bind to all hosts that are possible to communicate with the
# node but advertise it to other nodes via the private IP (less
# relevant because of the type of discovery used, but not a bad idea).
#node:
#  bind_host: [ _local_, _ec2:privateIp_, _ec2:publicIp_, _ec2:publicDns_ ]
#  publish_host: _ec2:privateIp_

这将允许他们通过将 IP 地址绑定到预期的地址来进行交谈。 如果您希望能够通过 SSH 连接到这些机器并通过 localhost 与 ES 通信(您可能会这样做以进行调试),那么您将希望将带有 _local_ 注释掉的版本作为 bind_host 在那个列表。

【讨论】:

  • 非常感谢先生分享所有这些概念和要点。我已经浏览了插件,我的意思是基础知识,但我想自己配置它。我只想了解配置及其工作原理。您能否建议我在当前环境中尝试解决此问题的解决方案。为了使我的集群正常工作,我应该非常了解所有其他配置。谢谢你
  • 您需要设置network.host 以便它绑定到每个端口的正确IP 地址。使用更高级的network.bind_hostnetwork.publish_host 选项会更好,但主机会让你继续前进。注意:如果你只使用主机,那么在与任何节点通信时你将无法使用 localhost。
  • 非常感谢先生。我将通过上述配置选项并相应地进行更改。一旦我完成,我会告诉你。谢谢
  • 先生,我终于可以设置集群了。我已经设置了我的network.host: 0.0.0.0 的值。 **但是我有一个疑问,在制作 network.host: 0.0.0.0 之前,我在所有实例上都尝试了 network.host: ["ip_of_ec21", "ip_of_ec2" , "ip_of_ec23"] 并且在开始时遇到了以下错误弹性搜索服务。我在每个实例上都收到此错误。错误:** nested: ChannelException[Failed to bind to: /xx.xx.xx.x:9400]; nested: BindException[Cannot assign requested address]; 上面错误中的 ip 是我的主节点实例的 ip。我无法理解原因。
  • 如果您为实例分配了适当的 IAM 角色(允许 ec2:DescribeInstances 的角色),则不需要将密钥放在 elasticsearch.yml 中。
猜你喜欢
  • 1970-01-01
  • 2016-06-01
  • 1970-01-01
  • 2022-07-24
  • 1970-01-01
  • 1970-01-01
  • 2010-12-11
  • 1970-01-01
  • 2023-02-02
相关资源
最近更新 更多