Deploy a Elasticsearch Cluster on Docker Containers

From Knowledge Center
Jump to: navigation, search


Launch The Cluster:

$ docker run -d --name es0 -p 9200:9200 itzg/elasticsearch
$ docker run -d --name es1 --link es0 -e UNICAST_HOSTS=es0 itzg/elasticsearch
$ docker run -d --name es2 --link es0 -e UNICAST_HOSTS=es0 itzg/elasticsearch

Ingest a couple of documents:

$ curl -XPUT http://127.0.0.1:9200/test/doc/1 -d '{"name": "ruan"}'

Check the nodes:

$ curl -XGET http://127.0.0.1:9200/_cat/nodes?v
ip         heap.percent ram.percent cpu load_1m load_5m load_15m node.role master name
172.17.0.6           37          56   0    0.11    0.13     0.18 mdi       -      _zqhGP2
172.17.0.5           47          56   0    0.11    0.13     0.18 mdi       -      1iy65gc
172.17.0.4           52          56   0    0.11    0.13     0.18 mdi       *      YuRGa8k

Review the shards:

$ curl -XGET http://127.0.0.1:9200/_cat/shards?v
index shard prirep state   docs  store ip         node
test  3     p      STARTED  330 44.9kb 172.17.0.6 _zqhGP2
test  3     r      STARTED  330 40.6kb 172.17.0.5 1iy65gc
test  2     r      STARTED  298 35.1kb 172.17.0.6 _zqhGP2
test  2     p      STARTED  298 34.9kb 172.17.0.4 YuRGa8k
test  4     r      STARTED  313 30.2kb 172.17.0.6 _zqhGP2
test  4     p      STARTED  313 39.7kb 172.17.0.5 1iy65gc
test  1     p      STARTED  267 23.7kb 172.17.0.5 1iy65gc
test  1     r      STARTED  267 32.2kb 172.17.0.4 YuRGa8k
test  0     p      STARTED  294 34.5kb 172.17.0.6 _zqhGP2
test  0     r      STARTED  294 34.3kb 172.17.0.4 YuRGa8k

Reference: