From 0101a74980a91cf843af4b1a84a1ee4a32382a4e Mon Sep 17 00:00:00 2001 From: Baohua Yang Date: Thu, 30 Jul 2015 14:54:22 +0800 Subject: [PATCH] Add mongo cluster and mongo webui --- README.md | 24 ++++++++++++++- mongo_cluster/docker-compose.yml | 43 ++++++++++++++++++++++++++ mongo_cluster/scripts/mongosetup.sh | 46 ++++++++++++++++++++++++++++ mongo_webui/.docker-compose.yml.swp | Bin 0 -> 12288 bytes mongo_webui/docker-compose.yml | 28 +++++++++++++++++ 5 files changed, 140 insertions(+), 1 deletion(-) create mode 100644 mongo_cluster/docker-compose.yml create mode 100644 mongo_cluster/scripts/mongosetup.sh create mode 100644 mongo_webui/.docker-compose.yml.swp create mode 100644 mongo_webui/docker-compose.yml diff --git a/README.md b/README.md index 4c71eedd..b4062169 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,24 @@ -# docker-compose-files +Docker Compose Files +=== Some typical docker compose templates. + +# Install Docker Compose +```sh +$ sudo pip install docker-compose +``` + +# Docker-compose Usage +See [https://docs.docker.com/compose/](https://docs.docker.com/compose/). + + +# templates + +## mongo_cluster +Start 3 mongo instance to make a replica set. + +## mongo_webui +Start 1 mongo instance and a mongo-express web tool to watch it. + +The mongo instance will store data into local /opt/data/mongo_home. + +The web UI will listen on local 8081 port. diff --git a/mongo_cluster/docker-compose.yml b/mongo_cluster/docker-compose.yml new file mode 100644 index 00000000..24993abd --- /dev/null +++ b/mongo_cluster/docker-compose.yml @@ -0,0 +1,43 @@ +# This will boot 4 containers: 3 mongo as a cluster, and 1 to issue mongo commands to others +# + +mongo3: + image: mongo:3.0 + hostname: mongo3 + expose: + - "27017" + - "28017" + restart: always + entrypoint: [ "/usr/bin/mongod", "--replSet", "rs", "--rest", "--httpinterface" ] + +mongo2: + image: mongo:3.0 + hostname: mongo2 + expose: + - "27017" + - "28017" + restart: always + entrypoint: [ "/usr/bin/mongod", "--replSet", "rs", "--rest", "--httpinterface" ] + +mongo1: + image: mongo:3.0 + hostname: mongo1 + expose: + - "27017" + - "28017" + links: + - mongo2:mongo2 + - mongo3:mongo3 + restart: always + entrypoint: [ "/usr/bin/mongod", "--replSet", "rs", "--rest", "--httpinterface" ] + +mongosetup: + image: mongo:3.0 + links: + - mongo1:mongo1 + - mongo2:mongo2 + - mongo3:mongo3 + volumes: + - ./scripts:/scripts + restart: always + entrypoint: [ "bash", "/scripts/mongosetup.sh" ] diff --git a/mongo_cluster/scripts/mongosetup.sh b/mongo_cluster/scripts/mongosetup.sh new file mode 100644 index 00000000..fa67b4ff --- /dev/null +++ b/mongo_cluster/scripts/mongosetup.sh @@ -0,0 +1,46 @@ +#!/bin/bash + +MONGODB1=`ping -c 1 mongo1 | head -1 | cut -d "(" -f 2 | cut -d ")" -f 1` +MONGODB2=`ping -c 1 mongo2 | head -1 | cut -d "(" -f 2 | cut -d ")" -f 1` +MONGODB3=`ping -c 1 mongo3 | head -1 | cut -d "(" -f 2 | cut -d ")" -f 1` + +echo "Waiting for startup.." +until curl http://${MONGODB1}:28017/serverStatus\?text\=1 2>&1 | grep uptime | head -1; do + printf '.' + sleep 1 +done + +echo curl http://${MONGODB1}:28017/serverStatus\?text\=1 2>&1 | grep uptime | head -1 +echo "Started.." + +sleep 10 + +echo SETUP.sh time now: `date +"%T" ` +mongo --host ${MONGODB1}:27017 < /dev/null diff --git a/mongo_webui/.docker-compose.yml.swp b/mongo_webui/.docker-compose.yml.swp new file mode 100644 index 0000000000000000000000000000000000000000..1a9a6c0a82ebb5b8abd51007f56048ec5d66318e GIT binary patch literal 12288 zcmeI2KX21O6u_@63_wA!GCWeLVZgDIA{trh(5eN3R8$%YY|%Ns#HZSK#&>QBpMkFc zL%#rGWMp7qU|?oq;Uh2s<@t}GsZ!V&s&~>aaqiCV?)`jOk{5W7dYiD^y2-FzV(in0 zw>!n<^(DpvuA`h6pZ?xf*Ef6jduvXwfA3bid;7%68@{_afptC16QQhe??`($58O}> zcSYt5b&_f$oRN%$aTBe^day5oTppXynk4awOV9urAOo`uDY>LUYWfDDiUGC&5%02v?yWZ;w-8{{SO0?CjkNU`oYgc=zj17v^`)re4gGSjLkkoLM%kO{%$h0?U~{0XtM<#+azZTCZapE=#wwl&znbKTXDKdJMVAR5bX8EgC50EuligVcM!ANJ-2*lD@p`;pvR#1p-L0<@n ztWAyYx?^dhJZRyWac9Y?