这是我第一次使用弹性搜索。以下是我的环境/配置。
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设置为true(根据此链接)
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 2.0默认将所有套接字绑定到localhost
。这意味着,默认情况下,该机器之外的任何东西都不能与它对话。
这显然是出于安全目的和简单的开发设置。在本地,它工作得很好,但当它变得更严重时,您需要为您的环境配置它。这也是为什么您可以通过localhost
与节点对话。基本上,当您使用网络设置在其他机器上想要多个节点时,您需要这样做。这适用于ES 2.3:
network:
bind_host: [ _local_, _global_ ]
publish_host: _global_
然后其他节点可以与公共IP通信,但您仍然需要localhost来简化本地使用该节点的工作(例如,当SSHed到一个框中时,您-人类-永远不必知道IP)。
由于你在EC2中使用Elasticsearch 2.0,我建议你安装< code>cloud-aws插件(未来的读者请注意:这个插件在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通信(您可能为了调试而这样做),那么您将希望在该列表中用< code>_local_作为< code>bind_host注释掉该版本。