vas*_*ily 6 amazon-web-services elasticsearch docker amazon-elastic-beanstalk
我正在尝试让ElasticSearch在Elastic Beanstalk环境中运行.使用Docker镜像,在负载平衡环境中运行一个实例非常简单.但是,当我尝试向群集添加更多实例时,它们无法发现彼此,并且每个新实例都成为new_master.
我Dockerfile看起来像以下
FROM dockerfile/java:oracle-java8
RUN ... # Downloading and installing ElasticSearch
RUN /elasticsearch/bin/plugin install elasticsearch/elasticsearch-cloud-aws/2.5.0
VOLUME ["/data"]
ADD config/elasticsearch.yml /elasticsearch/config/elasticsearch.yml
WORKDIR /data
CMD ["/elasticsearch/bin/elasticsearch"]
EXPOSE 9200
Run Code Online (Sandbox Code Playgroud)
配置config/elasticsearch.yml如下所示:
cluster:
name: elastic-env-dev
cloud:
aws:
region: ap-southeast-2
discovery:
type: ec2
ec2:
tag:
Name: elastic-env-dev
ping_timeout: 120s
Run Code Online (Sandbox Code Playgroud)
EB环境的名称是elastic-env-dev.
http://vladmiller.com/elasticsearch/aws/2015/12/08/deploy-elasticsearch-on-aws-elasticbeanstalk.html
此时(2015 年 11 月 14 日),在花费了大量时间之后,我会说让 ES 集群在 EB 上工作是不可能的。
问题#1是你必须将 docker 端口映射到主机,就像你会做的那样
docker run -p 9300:9300 ...
Run Code Online (Sandbox Code Playgroud)
如果您通过.ebextensions添加 post appdeploy 挂钩,这将很容易解决,这将设置 iptables 端口转发
files:
"/opt/elasticbeanstalk/hooks/appdeploy/post/99_setup_iptables.sh":
mode: "0755"
owner: root
group: root
content: |
#!/bin/sh
iptables-save | grep -v added_by_ebextension | iptables-restore
DOCKER_IP=$(docker inspect `cat /etc/elasticbeanstalk/.aws_beanstalk.current-container-id` | jq -r .[0].NetworkSettings.IPAddress)
iptables -t nat -A DOCKER -p tcp --dport 9300:9400 -j DNAT --to-destination ${DOCKER_IP} -m comment --comment added_by_ebextension
service iptables save
Run Code Online (Sandbox Code Playgroud)
问题 #2您需要调整安全组,确保允许 SG 中的节点之间的 TCP 9300-9400 和 ICMP 流量。
问题 #3使用 aws-ec2 发现插件并将其限制在您的 SG 中,因此不会发现其他机器
// elasticsearch.yml
cloud.aws:
access_key: YYYYYYYYY
secret_key: XXXXXXXXX
region: us-east-1
discovery.type: ec2
discovery.ec2.ping_timeout: 30s
discovery.ec2.tag.Name: [ENVIRONMENT_NAME]
discovery.ec2.host_type: private_dns
discovery.zen.ping.multicast.enabled: false
Run Code Online (Sandbox Code Playgroud)
问题 #4,未解决的是每个 ES 节点都会绑定到内部 docker IP 地址,类似于172.17.0.3,但是您的主机私有 IP 不同。因此,当节点发现彼此并开始通信时,它们会向其他节点报告错误的 IP 地址。
[2015-11-13 21:50:58,542][TRACE][discovery.zen.ping.unicast] [86ac0ad55d5b] [2] received response from {#zen_unicast_21_#cloud-i-8c317a3b-0#}{10.165.71.177}{ip-10-165-71-177.ec2.internal/10.165.71.177:9300}: [ping_response{node [{86ac0ad55d5b}{U3PF5qOaQCucpK3JfZ3ARA}{172.17.0.3}{172.17.0.3:9300}], id[5], master [null], hasJoinedOnce [false], cluster_name[es-staging]}, ping_response{node [{86ac0ad55d5b}{U3PF5qOaQCucpK3JfZ3ARA}{172.17.0.3}{172.17.0.3:9300}], id[7], master [null], hasJoinedOnce [false], cluster_name[es-staging]}, ping_response{node [{86ac0ad55d5b}{U3PF5qOaQCucpK3JfZ3ARA}{172.17.0.3}{172.17.0.3:9300}], id[9], master [null], hasJoinedOnce [false], cluster_name[es-staging]}, ping_response{node [{86ac0ad55d5b}{U3PF5qOaQCucpK3JfZ3ARA}{172.17.0.3}{172.17.0.3:9300}], id[11], master [null], hasJoinedOnce [false], cluster_name[es-staging]}, ping_response{node [{89764d1bb185}{yVRC-HmIQoayIuWfi6a09g}{172.17.0.3}{172.17.0.3:9300}], id[30], master [{89764d1bb185}{yVRC-HmIQoayIuWfi6a09g}{172.17.0.3}{172.17.0.3:9300}], hasJoinedOnce [true], cluster_name[es-staging]}]
Run Code Online (Sandbox Code Playgroud)
您可以看到在ip-10-165-71-177.ec2.internal/10.165.71.177:9300上发现的节点,但是该节点响应说它的 IP 是172.17.0.3,因此第一个节点将尝试连接到 EC2 私有 IP,而不是连接连接到内部 Docker IP
[2015-11-13 21:51:00,037][TRACE][discovery.ec2 ] [86ac0ad55d5b] full ping responses:
--> ping_response{node [{89764d1bb185}{yVRC-HmIQoayIuWfi6a09g}{172.17.0.3}{172.17.0.3:9300}], id[30], master [{89764d1bb185}{yVRC-HmIQoayIuWfi6a09g}{172.17.0.3}{172.17.0.3:9300}], hasJoinedOnce [true], cluster_name[es-staging]}
[2015-11-13 21:51:00,041][DEBUG][discovery.ec2 ] [86ac0ad55d5b] filtered ping responses: (filter_client[true], filter_data[false])
--> ping_response{node [{89764d1bb185}{yVRC-HmIQoayIuWfi6a09g}{172.17.0.3}{172.17.0.3:9300}], id[30], master [{89764d1bb185}{yVRC-HmIQoayIuWfi6a09g}{172.17.0.3}{172.17.0.3:9300}], hasJoinedOnce [true], cluster_name[es-staging]}
Run Code Online (Sandbox Code Playgroud)
我们需要以某种方式使 ES 绑定到主机的 IP 地址或忽略这些 docker IP 地址并继续发现 IP。
更新1我怀疑你可以在没有Docker的情况下将ES部署到EB,但是我还没有尝试过这个选项。
更新 2我能够让节点发现彼此并尝试进行通信,但是现在它有一个不同的问题
更新3这是有关如何实现预期效果的故事和示例代码http://vladmiller.com/elasticsearch/aws/2015/12/08/deploy-elasticsearch-on-aws-elasticbeanstalk.html
| 归档时间: |
|
| 查看次数: |
4836 次 |
| 最近记录: |