amazon-web-services - Elasticsearch Master 未发现异常 - 版本 2.3.0

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

这是我第一次使用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。

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

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

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

    谢谢

    最佳答案

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

    这显然是出于安全目的和简单的开发设置。在本地,它工作得很好,但是当情况变得更严重时,您需要针对您的环境进行配置。这也是您可以通过 localhost 与节点通信的原因。 基本上,当您想要使用 network settings 跨其他计算机的多个节点时,您需要这一点。 。这适用于 ES 2.3+:

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

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

    由于您在使用 Elasticsearch 2.0+ 的 EC2 中,我建议 you install the cloud-aws plugin ( future 的读者请注意:这个插件在 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 地址绑定(bind)到预期的地址来进行通信。 如果您希望能够通过 SSH 连接到这些机器并通过本地主机与 ES 进行通信(您可能会进行调试),那么您将希望使用 _local_ 注释掉该版本:该列表中的 bind_host

    关于amazon-web-services - Elasticsearch Master 未发现异常 - 版本 2.3.0,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38130943/

    相关文章:

    amazon-web-services - 在 CloudFormation 中创建 AWS WorkMail Lambda 调用权限

    java - 无法连接到 ec2 实例上的 Tomcat 服务器

    java - 为什么描述 Amazon EC2 实例可能没有结果?

    amazon-web-services - 自动缩放 EC2 : Launch Webserver on Spun-up Instance

    amazon-ec2 - elasticSearch和AWS插件异常

    python - Elasticbeanstalk/多个数据库的 Django 迁移过程

    amazon-web-services - 在 AWS 上导入入站安全组规则

    elasticsearch - 从字段数组中提取文本

    elasticsearch - 聚合后的Elasticsearch排序日期

    groovy - ElasticSearch Groovy 脚本错误,可疑请求