Skip to content

Instantly share code, notes, and snippets.

@brandocorp
Last active August 29, 2015 14:17
Show Gist options
  • Save brandocorp/0f11efdb4680b2f3aeb4 to your computer and use it in GitHub Desktop.
Save brandocorp/0f11efdb4680b2f3aeb4 to your computer and use it in GitHub Desktop.
Elasticsearch Unicast across Docker Hosts
#!/bin/bash
#
# Docker Host 01
# eth0: 192.168.1.10
#
docker run -d \
-p 9200:9200 \
-p 9300:9300 \
ehazlett/elasticsearch \
--cluster.name=unicast \
--network.publish_host=192.168.1.10 \
--discovery.zen.ping.multicast.enabled=false \
--discovery.zen.ping.unicast.hosts=192.168.1.20 \
--discovery.zen.ping.timeout=3s \
--discovery.zen.minimum_master_nodes=1
#!/bin/bash
#
# Docker Host 02
# eth0: 192.168.1.20
#
docker run -d \
-p 9200:9200 \
-p 9300:9300 \
ehazlett/elasticsearch \
--cluster.name=unicast \
--network.publish_host=192.168.1.20 \
--discovery.zen.ping.multicast.enabled=false \
--discovery.zen.ping.unicast.hosts=192.168.1.10 \
--discovery.zen.ping.timeout=3s \
--discovery.zen.minimum_master_nodes=1
@brandocorp
Copy link
Author

Checking the cluster health should reveal the following:

Docker Host 01

curl http://192.168.1.10:9200/_cluster/health
{"cluster_name":"staging","status":"green","timed_out":false,"number_of_nodes":2,"number_of_data_nodes":2,"active_primary_shards":0,"active_shards":0,"relocating_shards":0,"initializing_shards":0,"unassigned_shards":0}

Docker Host 02

curl http://192.168.1.20:9200/_cluster/health
{"cluster_name":"staging","status":"green","timed_out":false,"number_of_nodes":2,"number_of_data_nodes":2,"active_primary_shards":0,"active_shards":0,"relocating_shards":0,"initializing_shards":0,"unassigned_shards":0}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment