diff --git a/README-build.md b/README-build.md index 1134a6bf..fa516d37 100644 --- a/README-build.md +++ b/README-build.md @@ -2,12 +2,12 @@ Starting with version 1.9 Debezium provides multi platform Docker iamges for `linux/amd64` and `linux/arm64`. -Debeziums own Postgres and MongoDB builds are also available as multi platform, as long +Debeziums own Postgres builds are also available as multi platform, as long as their base images support multi platform builds (see `build-all-multiplatform.sh`). ## Running the build -You can build Debezium, Mongo and Postgres multi platform images using the `build-all-multiplatform.sh` script. +You can build Debezium and Postgres multi platform images using the `build-all-multiplatform.sh` script. Before running the build, you need a `buildx` instance configured. You can create an instance like this: @@ -74,7 +74,7 @@ appropriate runner. Note that the scripts expects the registry listening on http ## Building single images -You can build a single images running either `./build-mongo-multiplatform.sh` or `./build-postgres-multiplatform.sh` +You can build a single images running `./build-postgres-multiplatform.sh` Both of this scripts works with the env variables described above and expect two arguments: @@ -85,7 +85,6 @@ Examples: ```bash ./build-postgres-multiarch.sh 14-alpine "linux/amd64,linux/arm64" - ./build-mongo-multiarch.sh 3.2 "linux/amd64" ``` For building a single Debezium version for multiple platforms, you can run diff --git a/build-all-multiplatform.sh b/build-all-multiplatform.sh index 46bf8b93..2dbeb864 100755 --- a/build-all-multiplatform.sh +++ b/build-all-multiplatform.sh @@ -9,7 +9,7 @@ fi COMPONENTS=$* if [ -z "$COMPONENTS" ]; then - COMPONENTS="mongo postgres debezium" + COMPONENTS="postgres debezium" fi; if [ -z "$MULTIPLATFORM_PLATFORMS" ]; then @@ -29,17 +29,9 @@ function shouldBuild() { # with multi platform build DEBEZIUM_SINGLEPLATFORM_VERSIONS="1.0 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8" -MONGO_MULTIPLATFORM_VERSIONS="5.0 6.0 7.0" - POSTGRES_VERSIONS="12 13 14" POSTGRES_MULTIPLATFORM_VERSIONS="15 16 17 12-alpine 13-alpine 14-alpine 15-alpine 16-alpine 17-alpine" -if shouldBuild "mongo"; then - for MONGO_VERSION in $MONGO_MULTIPLATFORM_VERSIONS; do - ./build-mongo-multiplatform.sh "$MONGO_VERSION" "${MULTIPLATFORM_PLATFORMS}" - done -fi; - if shouldBuild "postgres"; then for POSTGRES_VERSION in $POSTGRES_VERSIONS; do ./build-postgres-multiplatform.sh "$POSTGRES_VERSION" "linux/amd64" diff --git a/build-all.sh b/build-all.sh index 81af1945..0b80478c 100755 --- a/build-all.sh +++ b/build-all.sh @@ -6,13 +6,8 @@ DEBEZIUM_VERSION="3.0" if [ -z "$DEBEZIUM_VERSIONS" ]; then DEBEZIUM_VERSIONS="$DEBEZIUM_VERSION" fi -MONGO_VERSIONS="5.0 6.0 7.0" POSTGRES_VERSIONS="12 12-alpine 13 13-alpine 14 14-alpine 15 15-alpine 16 16-alpine 17 17-alpine" -for MONGO_VERSION in $MONGO_VERSIONS; do - ./build-mongo.sh "$MONGO_VERSION" -done - for POSTGRES_VERSION in $POSTGRES_VERSIONS; do ./build-postgres.sh "$POSTGRES_VERSION" done diff --git a/build-mongo-multiplatform.sh b/build-mongo-multiplatform.sh deleted file mode 100755 index b1513a86..00000000 --- a/build-mongo-multiplatform.sh +++ /dev/null @@ -1,47 +0,0 @@ -#!/bin/bash - -set -eo pipefail - -function usage() { - MSG=$1 - - echo "" - echo "$MSG" - echo "" - echo "Usage: build-mongo-multiplatform "; - echo "" - echo " Where platform can be for example:" - echo " linux/amd64" - echo " linux/amd64,linux/arm64" - echo " linux/arm64" - echo "" - exit 1; -} - -if [[ -z "$1" ]]; then - usage "A version must be specified." -fi - -if [[ -z "$2" ]]; then - usage "Platform must be specified." -fi -PLATFORM=$2 - -if [ -z "${DEBEZIUM_DOCKER_REGISTRY_PRIMARY_NAME}" ]; then - DEBEZIUM_DOCKER_REGISTRY_PRIMARY_NAME=quay.io/debezium -fi; - -echo "" -echo "****************************************************************" -echo "** Building ${DEBEZIUM_DOCKER_REGISTRY_PRIMARY_NAME}/mongo-initiator:$1 for $PLATFORM" -echo "****************************************************************" -TAGS=("-t ${DEBEZIUM_DOCKER_REGISTRY_PRIMARY_NAME}/mongo-initiator:$1") -if [ -n "${DEBEZIUM_DOCKER_REGISTRY_SECONDARY_NAME}" ]; then - TAGS+=("-t ${DEBEZIUM_DOCKER_REGISTRY_SECONDARY_NAME}/mongo-initiator:$1") -fi; - -# shellcheck disable=SC2068 -docker buildx build --push --platform "${PLATFORM}" \ - --build-arg DEBEZIUM_DOCKER_REGISTRY_PRIMARY_NAME="${DEBEZIUM_DOCKER_REGISTRY_PRIMARY_NAME}" \ - ${TAGS[@]} \ - "mongo-initiator/$1" diff --git a/build-mongo.sh b/build-mongo.sh deleted file mode 100755 index 5cfd7f07..00000000 --- a/build-mongo.sh +++ /dev/null @@ -1,31 +0,0 @@ -#!/bin/bash - -set -eo pipefail - -if [[ -z "$1" ]]; then - echo "" - echo "A version must be specified." - echo "" - echo "Usage: build-mongo "; - echo "" - exit 1; -fi - -if [ -z "${DEBEZIUM_DOCKER_REGISTRY_PRIMARY_NAME}" ]; then - DEBEZIUM_DOCKER_REGISTRY_PRIMARY_NAME=quay.io/debezium -fi; - -echo "" -echo "****************************************************************" -echo "** Building ${DEBEZIUM_DOCKER_REGISTRY_PRIMARY_NAME}/mongo-initiator:$1" -echo "****************************************************************" -docker build -t "${DEBEZIUM_DOCKER_REGISTRY_PRIMARY_NAME}/mongo-initiator:$1" "mongo-initiator/$1" - -if [ "$PUSH_IMAGES" == "true" ]; then - echo "Pushing the image into the registry" - docker push "${DEBEZIUM_DOCKER_REGISTRY_PRIMARY_NAME}/mongo-initiator:$1" - if [ -n "${DEBEZIUM_DOCKER_REGISTRY_SECONDARY_NAME}" ]; then - docker tag "${DEBEZIUM_DOCKER_REGISTRY_PRIMARY_NAME}/mongo-initiator:$1" "${DEBEZIUM_DOCKER_REGISTRY_SECONDARY_NAME}/mongo-initiator:$1" - docker push "${DEBEZIUM_DOCKER_REGISTRY_SECONDARY_NAME}/mongo-initiator:$1" - fi; -fi diff --git a/mongo-initiator/3.2/Dockerfile b/mongo-initiator/3.2/Dockerfile deleted file mode 100644 index 1fb54506..00000000 --- a/mongo-initiator/3.2/Dockerfile +++ /dev/null @@ -1,10 +0,0 @@ -FROM mongo:3.2 - -LABEL maintainer="Debezium Community" - -COPY ./docker-entrypoint.sh / - -USER mongodb - -ENTRYPOINT ["/docker-entrypoint.sh"] -CMD ["start"] \ No newline at end of file diff --git a/mongo-initiator/3.2/README.md b/mongo-initiator/3.2/README.md deleted file mode 100644 index 8fe3b980..00000000 --- a/mongo-initiator/3.2/README.md +++ /dev/null @@ -1,26 +0,0 @@ -Initiate a MongoDB replica set on a set of running MongoDB servers, and optionally add the replica set as a shard to one or more running MongoDB routers. - -# How to use this image - -## Initiate a replica set - -With one or more MongoDB servers already running, start a container with this image to check if the replica set is initiated, and if not to initiate it and add all of the servers to the replica set. Start the container with the name of the replica set in the `$REPLICASET` environment variable, using links named like "MONGO_n_" (where _n_=1,2,3, etc.) for each of the MongoDB servers that are to be in the replica set. - -For example, consider three already-running MongoDB servers running in containers `data1`, `data2`, and `data3`. Running a container using the following command will check whether the replica set named `rs0` is properly initiated on these servers, and if not will initiate the replica set: - - $ docker run -it --name mongo-init --rm -e REPLICASET=rs0 --link data1:mongo1 --link data2:mongo2 --link data3:mongo3 quay.io/debezium/mongo-initiator - -The container will exit as soon as the replica set is initiated. - -## Initiate a shard replica set - -The container can optionally add the replica set as a _shard_ to one or more MongoDB routers. For example, consider three MongoDB servers running in containers `shardA1`, `shardA2`, and `shardA3`, and two MongoDB routers running in containers `router1` and `router2`. The following command will ensure that `shardA1`, `shardA2`, and `shardA3` are properly initiated as replica set `shardA`, and that the `shardA` replica set is added as a shard to the routers `router1` and `router2`: - - $ docker run -it --name mongo-init --rm -e REPLICASET=shardA --link shardA1:mongo1 --link shardA2:mongo2 --link shardA3:mongo3 --link router1 --link router2 quay.io/debezium/mongo-initiator - -Additional shard replica sets can be initiated and added by running additional containers. For example: - - $ docker run -it --name mongo-init --rm -e REPLICASET=shardB --link shardB1:mongo1 --link shardB2:mongo2 --link shardB3:mongo3 --link router1 --link router2 quay.io/debezium/mongo-initiator - - - diff --git a/mongo-initiator/3.2/docker-entrypoint.sh b/mongo-initiator/3.2/docker-entrypoint.sh deleted file mode 100755 index 5a8766aa..00000000 --- a/mongo-initiator/3.2/docker-entrypoint.sh +++ /dev/null @@ -1,177 +0,0 @@ -#!/bin/bash - -# Exit immediately if a *pipeline* returns a non-zero status. (Add -x for command tracing) -set -eEo pipefail - -# The names of container links are as follows, where 'n' is 1, 2, 3, etc.: -# -# "MONGOn" - specifies the Mongo replica set nodes, and n=1 for the primary node -# "ROUTERn" - specifies the Mongo router servers (optional, order is not important) -# -# The following environment variables are recognized: -# -# "REPLICASET" - specifies the name of the replica set for storing data/shards -# -# This script will attempt to initiate the replica set in the Mongo servers specified in the one or more `MONGOn` -# links, where the name of the replica set is given in the `REPLICASET` environment variable. (This step does -# nothing if the replica set is already initiated.) Then, if one or more `ROUTERn` links are specified, this -# script will add the replica set named `REPLICASET` as a shard to each of these MongoDB routers. -# - -if [[ -z $1 ]]; then - ARG1="start" -else - ARG1=$1 -fi - -MONGO="/usr/bin/mongo" - -# -# Process all MongoDB nodes by looking for environment variables that match 'MONGOn_PPORT_*_ADDR': -# -NODE_COUNT=0; -for VAR in `env | sort` -do - # First look for port 27019 used for the config server replica sets - env_var=`echo "$VAR" | sed -r "s/(.*)=.*/\1/g"` - if [[ $env_var =~ ^MONGO([0-9]+)_PORT_27019_TCP_ADDR ]]; then - NODE_COUNT=$(($NODE_COUNT+1)) - NODE_HOSTS[$NODE_COUNT]="${!env_var}"; - NODE_PORTS[$NODE_COUNT]="27019"; - if [[ $NODE_COUNT -eq 1 ]]; then - PRIMARY_HOST=${!env_var} - PRIMARY_PORT=27019 - fi - fi -done -if [[ -z $PRIMARY_HOST ]]; then - NODE_COUNT=0; - # None were found, so use whatever is available ... - for VAR in `env | sort` - do - env_var=`echo "$VAR" | sed -r "s/(.*)=.*/\1/g"` - if [[ $env_var =~ ^MONGO([0-9]+)_PORT_([0-9]+)_TCP_ADDR ]]; then - NODE_COUNT=$(($NODE_COUNT+1)) - NODE_HOSTS[$NODE_COUNT]="${!env_var}"; - NODE_PORTS[$NODE_COUNT]="${BASH_REMATCH[2]}"; - if [[ $NODE_COUNT -eq 1 ]]; then - PRIMARY_HOST=${!env_var} - PRIMARY_PORT=${BASH_REMATCH[2]} - fi - fi - done -fi - -# -# Process all MongoDB *router* nodes by looking for environment variables that match 'ROUTERn_PPORT_*_ADDR': -# -ROUTER_COUNT=0; -for VAR in `env | sort` -do - env_var=`echo "$VAR" | sed -r "s/(.*)=.*/\1/g"` - if [[ $env_var =~ ^ROUTER([0-9]+)_PORT_([0-9]+)_TCP_ADDR ]]; then - ROUTER_COUNT=$(($ROUTER_COUNT+1)) - ROUTER_HOSTS[$ROUTER_COUNT]="${!env_var}"; - ROUTER_PORTS[$ROUTER_COUNT]="${BASH_REMATCH[2]}"; - fi -done - -export NODE_HOSTS -export NODE_PORTS -export ROUTER_HOSTS -export ROUTER_PORTS - -# Process some known arguments ... -case $ARG1 in - start) - if [[ $NODE_COUNT -lt 1 ]]; then - echo "At least one Mongo node must be defined in container links, starting with \"MONGO1\" for the primary node and continuing with \"MONGO2\", etc. for secondaries." - exit 1; - fi - if [[ -z "$REPLICASET" ]]; then - echo "The name of the replica set must be defined with the \"REPLICASET\" environment variable" - exit 1; - fi - - # Define the command that will connect the mongo shell to the primary node ... - PRIMARY_MONGO="$MONGO --host $PRIMARY_HOST --port $PRIMARY_PORT" - - # Wait for the nodes to become available ... - echo "Testing connection to MongoDB primary node at ${PRIMARY_HOST}:${PRIMARY_PORT} ..." - status=$($PRIMARY_MONGO --eval db) - if [ "$?" -ne 0 ]; then - echo "Error: Unable to connect to ${PRIMARY_HOST}:${PRIMARY_PORT}" - echo "" - echo "${status}" - exit 2 - fi - - # See if the replica set is not set up ... - rsStatus=$($PRIMARY_MONGO --eval "rs.status()") - if [[ $rsStatus =~ "no replset config has been received" ]]; then - # Set up the replica set configuration document ... - echo "Using MongoDB primary node to initiate replica set \"${REPLICASET}\" with:" - CONFIGVAR="config= {_id: \"${REPLICASET}\", members:[ " - hostNum=1 - while [[ $hostNum -le $NODE_COUNT ]]; do - hostAndPort="${NODE_HOSTS[$hostNum]}:${NODE_PORTS[$hostNum]}" - if [[ $hostNum -eq 1 ]]; then - priority=2 - echo "- primary node: ${hostAndPort}" - else - priority=1 - echo "- secondary node: ${hostAndPort}" - CONFIGVAR="${CONFIGVAR}," - fi - CONFIGVAR="${CONFIGVAR} {_id: ${hostNum}, host: \"${hostAndPort}\", priority: ${priority} }" - hostNum=$hostNum+1 - done - CONFIGVAR="${CONFIGVAR} ] }" - - # Initiate the replica set with our document ... - $PRIMARY_MONGO --eval "${CONFIGVAR};rs.initiate(config);" - - rsStatus=$($PRIMARY_MONGO --eval "rs.status()") - if [[ $rsStatus =~ "no replset config has been received" ]]; then - echo "Failed to initialize replica set" - exit 1 - fi - else - echo "Replica set \"${REPLICASET}\" is already initiated." - fi - #if [[ -n $VERBOSE ]]; then - # echo "" - # echo "Current replica status:" - # echo "${rsStatus}" - #fi - echo "" - echo "Replica set is ready" - echo "" - - if [[ $ROUTER_COUNT -gt 0 ]]; then - # Add the primary of the replica set as a shard to each of the routers ... - echo "" - echo "Checking ${ROUTER_COUNT} router for shard using replica set \"${REPLICASET}/${PRIMARY_HOST}:${PRIMARY_PORT}\":" - hostNum=1 - added=0 - while [[ $hostNum -le $ROUTER_COUNT ]]; do - hostAndPort="${ROUTER_HOSTS[$hostNum]}:${ROUTER_PORTS[$hostNum]}" - result=$($MONGO --host ${ROUTER_HOSTS[$hostNum]} --port ${ROUTER_PORTS[$hostNum]} --eval "rs.status();sh.addShard( \"${REPLICASET}/${PRIMARY_HOST}:${PRIMARY_PORT}\" )") - if [[ $result =~ "E11000 duplicate key error collection: config.shards index: _id_ dup key" ]]; then - echo "- ${hostAndPort} (shard exists)" - else - added=$(($added+1)) - echo "- ${hostAndPort} (adding shard)" - fi - hostNum=$hostNum+1 - done - echo "Added replica set \"${REPLICASET}/${PRIMARY_HOST}:${PRIMARY_PORT}\" as shard to ${added} routers." - echo "" - echo "Routers are ready." - fi - exit 0 - ;; -esac - -# Otherwise just run the specified command -exec "$@" \ No newline at end of file diff --git a/mongo-initiator/3.4/Dockerfile b/mongo-initiator/3.4/Dockerfile deleted file mode 100644 index dfe71dfe..00000000 --- a/mongo-initiator/3.4/Dockerfile +++ /dev/null @@ -1,10 +0,0 @@ -FROM mongo:3.4 - -LABEL maintainer="Debezium Community" - -COPY ./docker-entrypoint.sh / - -USER mongodb - -ENTRYPOINT ["/docker-entrypoint.sh"] -CMD ["start"] \ No newline at end of file diff --git a/mongo-initiator/3.4/README.md b/mongo-initiator/3.4/README.md deleted file mode 100644 index 8fe3b980..00000000 --- a/mongo-initiator/3.4/README.md +++ /dev/null @@ -1,26 +0,0 @@ -Initiate a MongoDB replica set on a set of running MongoDB servers, and optionally add the replica set as a shard to one or more running MongoDB routers. - -# How to use this image - -## Initiate a replica set - -With one or more MongoDB servers already running, start a container with this image to check if the replica set is initiated, and if not to initiate it and add all of the servers to the replica set. Start the container with the name of the replica set in the `$REPLICASET` environment variable, using links named like "MONGO_n_" (where _n_=1,2,3, etc.) for each of the MongoDB servers that are to be in the replica set. - -For example, consider three already-running MongoDB servers running in containers `data1`, `data2`, and `data3`. Running a container using the following command will check whether the replica set named `rs0` is properly initiated on these servers, and if not will initiate the replica set: - - $ docker run -it --name mongo-init --rm -e REPLICASET=rs0 --link data1:mongo1 --link data2:mongo2 --link data3:mongo3 quay.io/debezium/mongo-initiator - -The container will exit as soon as the replica set is initiated. - -## Initiate a shard replica set - -The container can optionally add the replica set as a _shard_ to one or more MongoDB routers. For example, consider three MongoDB servers running in containers `shardA1`, `shardA2`, and `shardA3`, and two MongoDB routers running in containers `router1` and `router2`. The following command will ensure that `shardA1`, `shardA2`, and `shardA3` are properly initiated as replica set `shardA`, and that the `shardA` replica set is added as a shard to the routers `router1` and `router2`: - - $ docker run -it --name mongo-init --rm -e REPLICASET=shardA --link shardA1:mongo1 --link shardA2:mongo2 --link shardA3:mongo3 --link router1 --link router2 quay.io/debezium/mongo-initiator - -Additional shard replica sets can be initiated and added by running additional containers. For example: - - $ docker run -it --name mongo-init --rm -e REPLICASET=shardB --link shardB1:mongo1 --link shardB2:mongo2 --link shardB3:mongo3 --link router1 --link router2 quay.io/debezium/mongo-initiator - - - diff --git a/mongo-initiator/3.4/docker-entrypoint.sh b/mongo-initiator/3.4/docker-entrypoint.sh deleted file mode 100755 index 5a8766aa..00000000 --- a/mongo-initiator/3.4/docker-entrypoint.sh +++ /dev/null @@ -1,177 +0,0 @@ -#!/bin/bash - -# Exit immediately if a *pipeline* returns a non-zero status. (Add -x for command tracing) -set -eEo pipefail - -# The names of container links are as follows, where 'n' is 1, 2, 3, etc.: -# -# "MONGOn" - specifies the Mongo replica set nodes, and n=1 for the primary node -# "ROUTERn" - specifies the Mongo router servers (optional, order is not important) -# -# The following environment variables are recognized: -# -# "REPLICASET" - specifies the name of the replica set for storing data/shards -# -# This script will attempt to initiate the replica set in the Mongo servers specified in the one or more `MONGOn` -# links, where the name of the replica set is given in the `REPLICASET` environment variable. (This step does -# nothing if the replica set is already initiated.) Then, if one or more `ROUTERn` links are specified, this -# script will add the replica set named `REPLICASET` as a shard to each of these MongoDB routers. -# - -if [[ -z $1 ]]; then - ARG1="start" -else - ARG1=$1 -fi - -MONGO="/usr/bin/mongo" - -# -# Process all MongoDB nodes by looking for environment variables that match 'MONGOn_PPORT_*_ADDR': -# -NODE_COUNT=0; -for VAR in `env | sort` -do - # First look for port 27019 used for the config server replica sets - env_var=`echo "$VAR" | sed -r "s/(.*)=.*/\1/g"` - if [[ $env_var =~ ^MONGO([0-9]+)_PORT_27019_TCP_ADDR ]]; then - NODE_COUNT=$(($NODE_COUNT+1)) - NODE_HOSTS[$NODE_COUNT]="${!env_var}"; - NODE_PORTS[$NODE_COUNT]="27019"; - if [[ $NODE_COUNT -eq 1 ]]; then - PRIMARY_HOST=${!env_var} - PRIMARY_PORT=27019 - fi - fi -done -if [[ -z $PRIMARY_HOST ]]; then - NODE_COUNT=0; - # None were found, so use whatever is available ... - for VAR in `env | sort` - do - env_var=`echo "$VAR" | sed -r "s/(.*)=.*/\1/g"` - if [[ $env_var =~ ^MONGO([0-9]+)_PORT_([0-9]+)_TCP_ADDR ]]; then - NODE_COUNT=$(($NODE_COUNT+1)) - NODE_HOSTS[$NODE_COUNT]="${!env_var}"; - NODE_PORTS[$NODE_COUNT]="${BASH_REMATCH[2]}"; - if [[ $NODE_COUNT -eq 1 ]]; then - PRIMARY_HOST=${!env_var} - PRIMARY_PORT=${BASH_REMATCH[2]} - fi - fi - done -fi - -# -# Process all MongoDB *router* nodes by looking for environment variables that match 'ROUTERn_PPORT_*_ADDR': -# -ROUTER_COUNT=0; -for VAR in `env | sort` -do - env_var=`echo "$VAR" | sed -r "s/(.*)=.*/\1/g"` - if [[ $env_var =~ ^ROUTER([0-9]+)_PORT_([0-9]+)_TCP_ADDR ]]; then - ROUTER_COUNT=$(($ROUTER_COUNT+1)) - ROUTER_HOSTS[$ROUTER_COUNT]="${!env_var}"; - ROUTER_PORTS[$ROUTER_COUNT]="${BASH_REMATCH[2]}"; - fi -done - -export NODE_HOSTS -export NODE_PORTS -export ROUTER_HOSTS -export ROUTER_PORTS - -# Process some known arguments ... -case $ARG1 in - start) - if [[ $NODE_COUNT -lt 1 ]]; then - echo "At least one Mongo node must be defined in container links, starting with \"MONGO1\" for the primary node and continuing with \"MONGO2\", etc. for secondaries." - exit 1; - fi - if [[ -z "$REPLICASET" ]]; then - echo "The name of the replica set must be defined with the \"REPLICASET\" environment variable" - exit 1; - fi - - # Define the command that will connect the mongo shell to the primary node ... - PRIMARY_MONGO="$MONGO --host $PRIMARY_HOST --port $PRIMARY_PORT" - - # Wait for the nodes to become available ... - echo "Testing connection to MongoDB primary node at ${PRIMARY_HOST}:${PRIMARY_PORT} ..." - status=$($PRIMARY_MONGO --eval db) - if [ "$?" -ne 0 ]; then - echo "Error: Unable to connect to ${PRIMARY_HOST}:${PRIMARY_PORT}" - echo "" - echo "${status}" - exit 2 - fi - - # See if the replica set is not set up ... - rsStatus=$($PRIMARY_MONGO --eval "rs.status()") - if [[ $rsStatus =~ "no replset config has been received" ]]; then - # Set up the replica set configuration document ... - echo "Using MongoDB primary node to initiate replica set \"${REPLICASET}\" with:" - CONFIGVAR="config= {_id: \"${REPLICASET}\", members:[ " - hostNum=1 - while [[ $hostNum -le $NODE_COUNT ]]; do - hostAndPort="${NODE_HOSTS[$hostNum]}:${NODE_PORTS[$hostNum]}" - if [[ $hostNum -eq 1 ]]; then - priority=2 - echo "- primary node: ${hostAndPort}" - else - priority=1 - echo "- secondary node: ${hostAndPort}" - CONFIGVAR="${CONFIGVAR}," - fi - CONFIGVAR="${CONFIGVAR} {_id: ${hostNum}, host: \"${hostAndPort}\", priority: ${priority} }" - hostNum=$hostNum+1 - done - CONFIGVAR="${CONFIGVAR} ] }" - - # Initiate the replica set with our document ... - $PRIMARY_MONGO --eval "${CONFIGVAR};rs.initiate(config);" - - rsStatus=$($PRIMARY_MONGO --eval "rs.status()") - if [[ $rsStatus =~ "no replset config has been received" ]]; then - echo "Failed to initialize replica set" - exit 1 - fi - else - echo "Replica set \"${REPLICASET}\" is already initiated." - fi - #if [[ -n $VERBOSE ]]; then - # echo "" - # echo "Current replica status:" - # echo "${rsStatus}" - #fi - echo "" - echo "Replica set is ready" - echo "" - - if [[ $ROUTER_COUNT -gt 0 ]]; then - # Add the primary of the replica set as a shard to each of the routers ... - echo "" - echo "Checking ${ROUTER_COUNT} router for shard using replica set \"${REPLICASET}/${PRIMARY_HOST}:${PRIMARY_PORT}\":" - hostNum=1 - added=0 - while [[ $hostNum -le $ROUTER_COUNT ]]; do - hostAndPort="${ROUTER_HOSTS[$hostNum]}:${ROUTER_PORTS[$hostNum]}" - result=$($MONGO --host ${ROUTER_HOSTS[$hostNum]} --port ${ROUTER_PORTS[$hostNum]} --eval "rs.status();sh.addShard( \"${REPLICASET}/${PRIMARY_HOST}:${PRIMARY_PORT}\" )") - if [[ $result =~ "E11000 duplicate key error collection: config.shards index: _id_ dup key" ]]; then - echo "- ${hostAndPort} (shard exists)" - else - added=$(($added+1)) - echo "- ${hostAndPort} (adding shard)" - fi - hostNum=$hostNum+1 - done - echo "Added replica set \"${REPLICASET}/${PRIMARY_HOST}:${PRIMARY_PORT}\" as shard to ${added} routers." - echo "" - echo "Routers are ready." - fi - exit 0 - ;; -esac - -# Otherwise just run the specified command -exec "$@" \ No newline at end of file diff --git a/mongo-initiator/3.6/Dockerfile b/mongo-initiator/3.6/Dockerfile deleted file mode 100644 index d52472c8..00000000 --- a/mongo-initiator/3.6/Dockerfile +++ /dev/null @@ -1,10 +0,0 @@ -FROM mongo:3.6 - -LABEL maintainer="Debezium Community" - -COPY ./docker-entrypoint.sh / - -USER mongodb - -ENTRYPOINT ["/docker-entrypoint.sh"] -CMD ["start"] \ No newline at end of file diff --git a/mongo-initiator/3.6/README.md b/mongo-initiator/3.6/README.md deleted file mode 100644 index 8fe3b980..00000000 --- a/mongo-initiator/3.6/README.md +++ /dev/null @@ -1,26 +0,0 @@ -Initiate a MongoDB replica set on a set of running MongoDB servers, and optionally add the replica set as a shard to one or more running MongoDB routers. - -# How to use this image - -## Initiate a replica set - -With one or more MongoDB servers already running, start a container with this image to check if the replica set is initiated, and if not to initiate it and add all of the servers to the replica set. Start the container with the name of the replica set in the `$REPLICASET` environment variable, using links named like "MONGO_n_" (where _n_=1,2,3, etc.) for each of the MongoDB servers that are to be in the replica set. - -For example, consider three already-running MongoDB servers running in containers `data1`, `data2`, and `data3`. Running a container using the following command will check whether the replica set named `rs0` is properly initiated on these servers, and if not will initiate the replica set: - - $ docker run -it --name mongo-init --rm -e REPLICASET=rs0 --link data1:mongo1 --link data2:mongo2 --link data3:mongo3 quay.io/debezium/mongo-initiator - -The container will exit as soon as the replica set is initiated. - -## Initiate a shard replica set - -The container can optionally add the replica set as a _shard_ to one or more MongoDB routers. For example, consider three MongoDB servers running in containers `shardA1`, `shardA2`, and `shardA3`, and two MongoDB routers running in containers `router1` and `router2`. The following command will ensure that `shardA1`, `shardA2`, and `shardA3` are properly initiated as replica set `shardA`, and that the `shardA` replica set is added as a shard to the routers `router1` and `router2`: - - $ docker run -it --name mongo-init --rm -e REPLICASET=shardA --link shardA1:mongo1 --link shardA2:mongo2 --link shardA3:mongo3 --link router1 --link router2 quay.io/debezium/mongo-initiator - -Additional shard replica sets can be initiated and added by running additional containers. For example: - - $ docker run -it --name mongo-init --rm -e REPLICASET=shardB --link shardB1:mongo1 --link shardB2:mongo2 --link shardB3:mongo3 --link router1 --link router2 quay.io/debezium/mongo-initiator - - - diff --git a/mongo-initiator/3.6/docker-entrypoint.sh b/mongo-initiator/3.6/docker-entrypoint.sh deleted file mode 100755 index 5a8766aa..00000000 --- a/mongo-initiator/3.6/docker-entrypoint.sh +++ /dev/null @@ -1,177 +0,0 @@ -#!/bin/bash - -# Exit immediately if a *pipeline* returns a non-zero status. (Add -x for command tracing) -set -eEo pipefail - -# The names of container links are as follows, where 'n' is 1, 2, 3, etc.: -# -# "MONGOn" - specifies the Mongo replica set nodes, and n=1 for the primary node -# "ROUTERn" - specifies the Mongo router servers (optional, order is not important) -# -# The following environment variables are recognized: -# -# "REPLICASET" - specifies the name of the replica set for storing data/shards -# -# This script will attempt to initiate the replica set in the Mongo servers specified in the one or more `MONGOn` -# links, where the name of the replica set is given in the `REPLICASET` environment variable. (This step does -# nothing if the replica set is already initiated.) Then, if one or more `ROUTERn` links are specified, this -# script will add the replica set named `REPLICASET` as a shard to each of these MongoDB routers. -# - -if [[ -z $1 ]]; then - ARG1="start" -else - ARG1=$1 -fi - -MONGO="/usr/bin/mongo" - -# -# Process all MongoDB nodes by looking for environment variables that match 'MONGOn_PPORT_*_ADDR': -# -NODE_COUNT=0; -for VAR in `env | sort` -do - # First look for port 27019 used for the config server replica sets - env_var=`echo "$VAR" | sed -r "s/(.*)=.*/\1/g"` - if [[ $env_var =~ ^MONGO([0-9]+)_PORT_27019_TCP_ADDR ]]; then - NODE_COUNT=$(($NODE_COUNT+1)) - NODE_HOSTS[$NODE_COUNT]="${!env_var}"; - NODE_PORTS[$NODE_COUNT]="27019"; - if [[ $NODE_COUNT -eq 1 ]]; then - PRIMARY_HOST=${!env_var} - PRIMARY_PORT=27019 - fi - fi -done -if [[ -z $PRIMARY_HOST ]]; then - NODE_COUNT=0; - # None were found, so use whatever is available ... - for VAR in `env | sort` - do - env_var=`echo "$VAR" | sed -r "s/(.*)=.*/\1/g"` - if [[ $env_var =~ ^MONGO([0-9]+)_PORT_([0-9]+)_TCP_ADDR ]]; then - NODE_COUNT=$(($NODE_COUNT+1)) - NODE_HOSTS[$NODE_COUNT]="${!env_var}"; - NODE_PORTS[$NODE_COUNT]="${BASH_REMATCH[2]}"; - if [[ $NODE_COUNT -eq 1 ]]; then - PRIMARY_HOST=${!env_var} - PRIMARY_PORT=${BASH_REMATCH[2]} - fi - fi - done -fi - -# -# Process all MongoDB *router* nodes by looking for environment variables that match 'ROUTERn_PPORT_*_ADDR': -# -ROUTER_COUNT=0; -for VAR in `env | sort` -do - env_var=`echo "$VAR" | sed -r "s/(.*)=.*/\1/g"` - if [[ $env_var =~ ^ROUTER([0-9]+)_PORT_([0-9]+)_TCP_ADDR ]]; then - ROUTER_COUNT=$(($ROUTER_COUNT+1)) - ROUTER_HOSTS[$ROUTER_COUNT]="${!env_var}"; - ROUTER_PORTS[$ROUTER_COUNT]="${BASH_REMATCH[2]}"; - fi -done - -export NODE_HOSTS -export NODE_PORTS -export ROUTER_HOSTS -export ROUTER_PORTS - -# Process some known arguments ... -case $ARG1 in - start) - if [[ $NODE_COUNT -lt 1 ]]; then - echo "At least one Mongo node must be defined in container links, starting with \"MONGO1\" for the primary node and continuing with \"MONGO2\", etc. for secondaries." - exit 1; - fi - if [[ -z "$REPLICASET" ]]; then - echo "The name of the replica set must be defined with the \"REPLICASET\" environment variable" - exit 1; - fi - - # Define the command that will connect the mongo shell to the primary node ... - PRIMARY_MONGO="$MONGO --host $PRIMARY_HOST --port $PRIMARY_PORT" - - # Wait for the nodes to become available ... - echo "Testing connection to MongoDB primary node at ${PRIMARY_HOST}:${PRIMARY_PORT} ..." - status=$($PRIMARY_MONGO --eval db) - if [ "$?" -ne 0 ]; then - echo "Error: Unable to connect to ${PRIMARY_HOST}:${PRIMARY_PORT}" - echo "" - echo "${status}" - exit 2 - fi - - # See if the replica set is not set up ... - rsStatus=$($PRIMARY_MONGO --eval "rs.status()") - if [[ $rsStatus =~ "no replset config has been received" ]]; then - # Set up the replica set configuration document ... - echo "Using MongoDB primary node to initiate replica set \"${REPLICASET}\" with:" - CONFIGVAR="config= {_id: \"${REPLICASET}\", members:[ " - hostNum=1 - while [[ $hostNum -le $NODE_COUNT ]]; do - hostAndPort="${NODE_HOSTS[$hostNum]}:${NODE_PORTS[$hostNum]}" - if [[ $hostNum -eq 1 ]]; then - priority=2 - echo "- primary node: ${hostAndPort}" - else - priority=1 - echo "- secondary node: ${hostAndPort}" - CONFIGVAR="${CONFIGVAR}," - fi - CONFIGVAR="${CONFIGVAR} {_id: ${hostNum}, host: \"${hostAndPort}\", priority: ${priority} }" - hostNum=$hostNum+1 - done - CONFIGVAR="${CONFIGVAR} ] }" - - # Initiate the replica set with our document ... - $PRIMARY_MONGO --eval "${CONFIGVAR};rs.initiate(config);" - - rsStatus=$($PRIMARY_MONGO --eval "rs.status()") - if [[ $rsStatus =~ "no replset config has been received" ]]; then - echo "Failed to initialize replica set" - exit 1 - fi - else - echo "Replica set \"${REPLICASET}\" is already initiated." - fi - #if [[ -n $VERBOSE ]]; then - # echo "" - # echo "Current replica status:" - # echo "${rsStatus}" - #fi - echo "" - echo "Replica set is ready" - echo "" - - if [[ $ROUTER_COUNT -gt 0 ]]; then - # Add the primary of the replica set as a shard to each of the routers ... - echo "" - echo "Checking ${ROUTER_COUNT} router for shard using replica set \"${REPLICASET}/${PRIMARY_HOST}:${PRIMARY_PORT}\":" - hostNum=1 - added=0 - while [[ $hostNum -le $ROUTER_COUNT ]]; do - hostAndPort="${ROUTER_HOSTS[$hostNum]}:${ROUTER_PORTS[$hostNum]}" - result=$($MONGO --host ${ROUTER_HOSTS[$hostNum]} --port ${ROUTER_PORTS[$hostNum]} --eval "rs.status();sh.addShard( \"${REPLICASET}/${PRIMARY_HOST}:${PRIMARY_PORT}\" )") - if [[ $result =~ "E11000 duplicate key error collection: config.shards index: _id_ dup key" ]]; then - echo "- ${hostAndPort} (shard exists)" - else - added=$(($added+1)) - echo "- ${hostAndPort} (adding shard)" - fi - hostNum=$hostNum+1 - done - echo "Added replica set \"${REPLICASET}/${PRIMARY_HOST}:${PRIMARY_PORT}\" as shard to ${added} routers." - echo "" - echo "Routers are ready." - fi - exit 0 - ;; -esac - -# Otherwise just run the specified command -exec "$@" \ No newline at end of file diff --git a/mongo-initiator/4.0/Dockerfile b/mongo-initiator/4.0/Dockerfile deleted file mode 100644 index cc1ea726..00000000 --- a/mongo-initiator/4.0/Dockerfile +++ /dev/null @@ -1,10 +0,0 @@ -FROM mongo:4.0 - -LABEL maintainer="Debezium Community" - -COPY ./docker-entrypoint.sh / - -USER mongodb - -ENTRYPOINT ["/docker-entrypoint.sh"] -CMD ["start"] \ No newline at end of file diff --git a/mongo-initiator/4.0/README.md b/mongo-initiator/4.0/README.md deleted file mode 100644 index 8fe3b980..00000000 --- a/mongo-initiator/4.0/README.md +++ /dev/null @@ -1,26 +0,0 @@ -Initiate a MongoDB replica set on a set of running MongoDB servers, and optionally add the replica set as a shard to one or more running MongoDB routers. - -# How to use this image - -## Initiate a replica set - -With one or more MongoDB servers already running, start a container with this image to check if the replica set is initiated, and if not to initiate it and add all of the servers to the replica set. Start the container with the name of the replica set in the `$REPLICASET` environment variable, using links named like "MONGO_n_" (where _n_=1,2,3, etc.) for each of the MongoDB servers that are to be in the replica set. - -For example, consider three already-running MongoDB servers running in containers `data1`, `data2`, and `data3`. Running a container using the following command will check whether the replica set named `rs0` is properly initiated on these servers, and if not will initiate the replica set: - - $ docker run -it --name mongo-init --rm -e REPLICASET=rs0 --link data1:mongo1 --link data2:mongo2 --link data3:mongo3 quay.io/debezium/mongo-initiator - -The container will exit as soon as the replica set is initiated. - -## Initiate a shard replica set - -The container can optionally add the replica set as a _shard_ to one or more MongoDB routers. For example, consider three MongoDB servers running in containers `shardA1`, `shardA2`, and `shardA3`, and two MongoDB routers running in containers `router1` and `router2`. The following command will ensure that `shardA1`, `shardA2`, and `shardA3` are properly initiated as replica set `shardA`, and that the `shardA` replica set is added as a shard to the routers `router1` and `router2`: - - $ docker run -it --name mongo-init --rm -e REPLICASET=shardA --link shardA1:mongo1 --link shardA2:mongo2 --link shardA3:mongo3 --link router1 --link router2 quay.io/debezium/mongo-initiator - -Additional shard replica sets can be initiated and added by running additional containers. For example: - - $ docker run -it --name mongo-init --rm -e REPLICASET=shardB --link shardB1:mongo1 --link shardB2:mongo2 --link shardB3:mongo3 --link router1 --link router2 quay.io/debezium/mongo-initiator - - - diff --git a/mongo-initiator/4.0/docker-entrypoint.sh b/mongo-initiator/4.0/docker-entrypoint.sh deleted file mode 100755 index 5a8766aa..00000000 --- a/mongo-initiator/4.0/docker-entrypoint.sh +++ /dev/null @@ -1,177 +0,0 @@ -#!/bin/bash - -# Exit immediately if a *pipeline* returns a non-zero status. (Add -x for command tracing) -set -eEo pipefail - -# The names of container links are as follows, where 'n' is 1, 2, 3, etc.: -# -# "MONGOn" - specifies the Mongo replica set nodes, and n=1 for the primary node -# "ROUTERn" - specifies the Mongo router servers (optional, order is not important) -# -# The following environment variables are recognized: -# -# "REPLICASET" - specifies the name of the replica set for storing data/shards -# -# This script will attempt to initiate the replica set in the Mongo servers specified in the one or more `MONGOn` -# links, where the name of the replica set is given in the `REPLICASET` environment variable. (This step does -# nothing if the replica set is already initiated.) Then, if one or more `ROUTERn` links are specified, this -# script will add the replica set named `REPLICASET` as a shard to each of these MongoDB routers. -# - -if [[ -z $1 ]]; then - ARG1="start" -else - ARG1=$1 -fi - -MONGO="/usr/bin/mongo" - -# -# Process all MongoDB nodes by looking for environment variables that match 'MONGOn_PPORT_*_ADDR': -# -NODE_COUNT=0; -for VAR in `env | sort` -do - # First look for port 27019 used for the config server replica sets - env_var=`echo "$VAR" | sed -r "s/(.*)=.*/\1/g"` - if [[ $env_var =~ ^MONGO([0-9]+)_PORT_27019_TCP_ADDR ]]; then - NODE_COUNT=$(($NODE_COUNT+1)) - NODE_HOSTS[$NODE_COUNT]="${!env_var}"; - NODE_PORTS[$NODE_COUNT]="27019"; - if [[ $NODE_COUNT -eq 1 ]]; then - PRIMARY_HOST=${!env_var} - PRIMARY_PORT=27019 - fi - fi -done -if [[ -z $PRIMARY_HOST ]]; then - NODE_COUNT=0; - # None were found, so use whatever is available ... - for VAR in `env | sort` - do - env_var=`echo "$VAR" | sed -r "s/(.*)=.*/\1/g"` - if [[ $env_var =~ ^MONGO([0-9]+)_PORT_([0-9]+)_TCP_ADDR ]]; then - NODE_COUNT=$(($NODE_COUNT+1)) - NODE_HOSTS[$NODE_COUNT]="${!env_var}"; - NODE_PORTS[$NODE_COUNT]="${BASH_REMATCH[2]}"; - if [[ $NODE_COUNT -eq 1 ]]; then - PRIMARY_HOST=${!env_var} - PRIMARY_PORT=${BASH_REMATCH[2]} - fi - fi - done -fi - -# -# Process all MongoDB *router* nodes by looking for environment variables that match 'ROUTERn_PPORT_*_ADDR': -# -ROUTER_COUNT=0; -for VAR in `env | sort` -do - env_var=`echo "$VAR" | sed -r "s/(.*)=.*/\1/g"` - if [[ $env_var =~ ^ROUTER([0-9]+)_PORT_([0-9]+)_TCP_ADDR ]]; then - ROUTER_COUNT=$(($ROUTER_COUNT+1)) - ROUTER_HOSTS[$ROUTER_COUNT]="${!env_var}"; - ROUTER_PORTS[$ROUTER_COUNT]="${BASH_REMATCH[2]}"; - fi -done - -export NODE_HOSTS -export NODE_PORTS -export ROUTER_HOSTS -export ROUTER_PORTS - -# Process some known arguments ... -case $ARG1 in - start) - if [[ $NODE_COUNT -lt 1 ]]; then - echo "At least one Mongo node must be defined in container links, starting with \"MONGO1\" for the primary node and continuing with \"MONGO2\", etc. for secondaries." - exit 1; - fi - if [[ -z "$REPLICASET" ]]; then - echo "The name of the replica set must be defined with the \"REPLICASET\" environment variable" - exit 1; - fi - - # Define the command that will connect the mongo shell to the primary node ... - PRIMARY_MONGO="$MONGO --host $PRIMARY_HOST --port $PRIMARY_PORT" - - # Wait for the nodes to become available ... - echo "Testing connection to MongoDB primary node at ${PRIMARY_HOST}:${PRIMARY_PORT} ..." - status=$($PRIMARY_MONGO --eval db) - if [ "$?" -ne 0 ]; then - echo "Error: Unable to connect to ${PRIMARY_HOST}:${PRIMARY_PORT}" - echo "" - echo "${status}" - exit 2 - fi - - # See if the replica set is not set up ... - rsStatus=$($PRIMARY_MONGO --eval "rs.status()") - if [[ $rsStatus =~ "no replset config has been received" ]]; then - # Set up the replica set configuration document ... - echo "Using MongoDB primary node to initiate replica set \"${REPLICASET}\" with:" - CONFIGVAR="config= {_id: \"${REPLICASET}\", members:[ " - hostNum=1 - while [[ $hostNum -le $NODE_COUNT ]]; do - hostAndPort="${NODE_HOSTS[$hostNum]}:${NODE_PORTS[$hostNum]}" - if [[ $hostNum -eq 1 ]]; then - priority=2 - echo "- primary node: ${hostAndPort}" - else - priority=1 - echo "- secondary node: ${hostAndPort}" - CONFIGVAR="${CONFIGVAR}," - fi - CONFIGVAR="${CONFIGVAR} {_id: ${hostNum}, host: \"${hostAndPort}\", priority: ${priority} }" - hostNum=$hostNum+1 - done - CONFIGVAR="${CONFIGVAR} ] }" - - # Initiate the replica set with our document ... - $PRIMARY_MONGO --eval "${CONFIGVAR};rs.initiate(config);" - - rsStatus=$($PRIMARY_MONGO --eval "rs.status()") - if [[ $rsStatus =~ "no replset config has been received" ]]; then - echo "Failed to initialize replica set" - exit 1 - fi - else - echo "Replica set \"${REPLICASET}\" is already initiated." - fi - #if [[ -n $VERBOSE ]]; then - # echo "" - # echo "Current replica status:" - # echo "${rsStatus}" - #fi - echo "" - echo "Replica set is ready" - echo "" - - if [[ $ROUTER_COUNT -gt 0 ]]; then - # Add the primary of the replica set as a shard to each of the routers ... - echo "" - echo "Checking ${ROUTER_COUNT} router for shard using replica set \"${REPLICASET}/${PRIMARY_HOST}:${PRIMARY_PORT}\":" - hostNum=1 - added=0 - while [[ $hostNum -le $ROUTER_COUNT ]]; do - hostAndPort="${ROUTER_HOSTS[$hostNum]}:${ROUTER_PORTS[$hostNum]}" - result=$($MONGO --host ${ROUTER_HOSTS[$hostNum]} --port ${ROUTER_PORTS[$hostNum]} --eval "rs.status();sh.addShard( \"${REPLICASET}/${PRIMARY_HOST}:${PRIMARY_PORT}\" )") - if [[ $result =~ "E11000 duplicate key error collection: config.shards index: _id_ dup key" ]]; then - echo "- ${hostAndPort} (shard exists)" - else - added=$(($added+1)) - echo "- ${hostAndPort} (adding shard)" - fi - hostNum=$hostNum+1 - done - echo "Added replica set \"${REPLICASET}/${PRIMARY_HOST}:${PRIMARY_PORT}\" as shard to ${added} routers." - echo "" - echo "Routers are ready." - fi - exit 0 - ;; -esac - -# Otherwise just run the specified command -exec "$@" \ No newline at end of file diff --git a/mongo-initiator/4.2/Dockerfile b/mongo-initiator/4.2/Dockerfile deleted file mode 100644 index 459a20bc..00000000 --- a/mongo-initiator/4.2/Dockerfile +++ /dev/null @@ -1,10 +0,0 @@ -FROM mongo:4.2 - -LABEL maintainer="Debezium Community" - -COPY ./docker-entrypoint.sh / - -USER mongodb - -ENTRYPOINT ["/docker-entrypoint.sh"] -CMD ["start"] diff --git a/mongo-initiator/4.2/README.md b/mongo-initiator/4.2/README.md deleted file mode 100644 index 8fe3b980..00000000 --- a/mongo-initiator/4.2/README.md +++ /dev/null @@ -1,26 +0,0 @@ -Initiate a MongoDB replica set on a set of running MongoDB servers, and optionally add the replica set as a shard to one or more running MongoDB routers. - -# How to use this image - -## Initiate a replica set - -With one or more MongoDB servers already running, start a container with this image to check if the replica set is initiated, and if not to initiate it and add all of the servers to the replica set. Start the container with the name of the replica set in the `$REPLICASET` environment variable, using links named like "MONGO_n_" (where _n_=1,2,3, etc.) for each of the MongoDB servers that are to be in the replica set. - -For example, consider three already-running MongoDB servers running in containers `data1`, `data2`, and `data3`. Running a container using the following command will check whether the replica set named `rs0` is properly initiated on these servers, and if not will initiate the replica set: - - $ docker run -it --name mongo-init --rm -e REPLICASET=rs0 --link data1:mongo1 --link data2:mongo2 --link data3:mongo3 quay.io/debezium/mongo-initiator - -The container will exit as soon as the replica set is initiated. - -## Initiate a shard replica set - -The container can optionally add the replica set as a _shard_ to one or more MongoDB routers. For example, consider three MongoDB servers running in containers `shardA1`, `shardA2`, and `shardA3`, and two MongoDB routers running in containers `router1` and `router2`. The following command will ensure that `shardA1`, `shardA2`, and `shardA3` are properly initiated as replica set `shardA`, and that the `shardA` replica set is added as a shard to the routers `router1` and `router2`: - - $ docker run -it --name mongo-init --rm -e REPLICASET=shardA --link shardA1:mongo1 --link shardA2:mongo2 --link shardA3:mongo3 --link router1 --link router2 quay.io/debezium/mongo-initiator - -Additional shard replica sets can be initiated and added by running additional containers. For example: - - $ docker run -it --name mongo-init --rm -e REPLICASET=shardB --link shardB1:mongo1 --link shardB2:mongo2 --link shardB3:mongo3 --link router1 --link router2 quay.io/debezium/mongo-initiator - - - diff --git a/mongo-initiator/4.2/docker-entrypoint.sh b/mongo-initiator/4.2/docker-entrypoint.sh deleted file mode 100755 index 5a8766aa..00000000 --- a/mongo-initiator/4.2/docker-entrypoint.sh +++ /dev/null @@ -1,177 +0,0 @@ -#!/bin/bash - -# Exit immediately if a *pipeline* returns a non-zero status. (Add -x for command tracing) -set -eEo pipefail - -# The names of container links are as follows, where 'n' is 1, 2, 3, etc.: -# -# "MONGOn" - specifies the Mongo replica set nodes, and n=1 for the primary node -# "ROUTERn" - specifies the Mongo router servers (optional, order is not important) -# -# The following environment variables are recognized: -# -# "REPLICASET" - specifies the name of the replica set for storing data/shards -# -# This script will attempt to initiate the replica set in the Mongo servers specified in the one or more `MONGOn` -# links, where the name of the replica set is given in the `REPLICASET` environment variable. (This step does -# nothing if the replica set is already initiated.) Then, if one or more `ROUTERn` links are specified, this -# script will add the replica set named `REPLICASET` as a shard to each of these MongoDB routers. -# - -if [[ -z $1 ]]; then - ARG1="start" -else - ARG1=$1 -fi - -MONGO="/usr/bin/mongo" - -# -# Process all MongoDB nodes by looking for environment variables that match 'MONGOn_PPORT_*_ADDR': -# -NODE_COUNT=0; -for VAR in `env | sort` -do - # First look for port 27019 used for the config server replica sets - env_var=`echo "$VAR" | sed -r "s/(.*)=.*/\1/g"` - if [[ $env_var =~ ^MONGO([0-9]+)_PORT_27019_TCP_ADDR ]]; then - NODE_COUNT=$(($NODE_COUNT+1)) - NODE_HOSTS[$NODE_COUNT]="${!env_var}"; - NODE_PORTS[$NODE_COUNT]="27019"; - if [[ $NODE_COUNT -eq 1 ]]; then - PRIMARY_HOST=${!env_var} - PRIMARY_PORT=27019 - fi - fi -done -if [[ -z $PRIMARY_HOST ]]; then - NODE_COUNT=0; - # None were found, so use whatever is available ... - for VAR in `env | sort` - do - env_var=`echo "$VAR" | sed -r "s/(.*)=.*/\1/g"` - if [[ $env_var =~ ^MONGO([0-9]+)_PORT_([0-9]+)_TCP_ADDR ]]; then - NODE_COUNT=$(($NODE_COUNT+1)) - NODE_HOSTS[$NODE_COUNT]="${!env_var}"; - NODE_PORTS[$NODE_COUNT]="${BASH_REMATCH[2]}"; - if [[ $NODE_COUNT -eq 1 ]]; then - PRIMARY_HOST=${!env_var} - PRIMARY_PORT=${BASH_REMATCH[2]} - fi - fi - done -fi - -# -# Process all MongoDB *router* nodes by looking for environment variables that match 'ROUTERn_PPORT_*_ADDR': -# -ROUTER_COUNT=0; -for VAR in `env | sort` -do - env_var=`echo "$VAR" | sed -r "s/(.*)=.*/\1/g"` - if [[ $env_var =~ ^ROUTER([0-9]+)_PORT_([0-9]+)_TCP_ADDR ]]; then - ROUTER_COUNT=$(($ROUTER_COUNT+1)) - ROUTER_HOSTS[$ROUTER_COUNT]="${!env_var}"; - ROUTER_PORTS[$ROUTER_COUNT]="${BASH_REMATCH[2]}"; - fi -done - -export NODE_HOSTS -export NODE_PORTS -export ROUTER_HOSTS -export ROUTER_PORTS - -# Process some known arguments ... -case $ARG1 in - start) - if [[ $NODE_COUNT -lt 1 ]]; then - echo "At least one Mongo node must be defined in container links, starting with \"MONGO1\" for the primary node and continuing with \"MONGO2\", etc. for secondaries." - exit 1; - fi - if [[ -z "$REPLICASET" ]]; then - echo "The name of the replica set must be defined with the \"REPLICASET\" environment variable" - exit 1; - fi - - # Define the command that will connect the mongo shell to the primary node ... - PRIMARY_MONGO="$MONGO --host $PRIMARY_HOST --port $PRIMARY_PORT" - - # Wait for the nodes to become available ... - echo "Testing connection to MongoDB primary node at ${PRIMARY_HOST}:${PRIMARY_PORT} ..." - status=$($PRIMARY_MONGO --eval db) - if [ "$?" -ne 0 ]; then - echo "Error: Unable to connect to ${PRIMARY_HOST}:${PRIMARY_PORT}" - echo "" - echo "${status}" - exit 2 - fi - - # See if the replica set is not set up ... - rsStatus=$($PRIMARY_MONGO --eval "rs.status()") - if [[ $rsStatus =~ "no replset config has been received" ]]; then - # Set up the replica set configuration document ... - echo "Using MongoDB primary node to initiate replica set \"${REPLICASET}\" with:" - CONFIGVAR="config= {_id: \"${REPLICASET}\", members:[ " - hostNum=1 - while [[ $hostNum -le $NODE_COUNT ]]; do - hostAndPort="${NODE_HOSTS[$hostNum]}:${NODE_PORTS[$hostNum]}" - if [[ $hostNum -eq 1 ]]; then - priority=2 - echo "- primary node: ${hostAndPort}" - else - priority=1 - echo "- secondary node: ${hostAndPort}" - CONFIGVAR="${CONFIGVAR}," - fi - CONFIGVAR="${CONFIGVAR} {_id: ${hostNum}, host: \"${hostAndPort}\", priority: ${priority} }" - hostNum=$hostNum+1 - done - CONFIGVAR="${CONFIGVAR} ] }" - - # Initiate the replica set with our document ... - $PRIMARY_MONGO --eval "${CONFIGVAR};rs.initiate(config);" - - rsStatus=$($PRIMARY_MONGO --eval "rs.status()") - if [[ $rsStatus =~ "no replset config has been received" ]]; then - echo "Failed to initialize replica set" - exit 1 - fi - else - echo "Replica set \"${REPLICASET}\" is already initiated." - fi - #if [[ -n $VERBOSE ]]; then - # echo "" - # echo "Current replica status:" - # echo "${rsStatus}" - #fi - echo "" - echo "Replica set is ready" - echo "" - - if [[ $ROUTER_COUNT -gt 0 ]]; then - # Add the primary of the replica set as a shard to each of the routers ... - echo "" - echo "Checking ${ROUTER_COUNT} router for shard using replica set \"${REPLICASET}/${PRIMARY_HOST}:${PRIMARY_PORT}\":" - hostNum=1 - added=0 - while [[ $hostNum -le $ROUTER_COUNT ]]; do - hostAndPort="${ROUTER_HOSTS[$hostNum]}:${ROUTER_PORTS[$hostNum]}" - result=$($MONGO --host ${ROUTER_HOSTS[$hostNum]} --port ${ROUTER_PORTS[$hostNum]} --eval "rs.status();sh.addShard( \"${REPLICASET}/${PRIMARY_HOST}:${PRIMARY_PORT}\" )") - if [[ $result =~ "E11000 duplicate key error collection: config.shards index: _id_ dup key" ]]; then - echo "- ${hostAndPort} (shard exists)" - else - added=$(($added+1)) - echo "- ${hostAndPort} (adding shard)" - fi - hostNum=$hostNum+1 - done - echo "Added replica set \"${REPLICASET}/${PRIMARY_HOST}:${PRIMARY_PORT}\" as shard to ${added} routers." - echo "" - echo "Routers are ready." - fi - exit 0 - ;; -esac - -# Otherwise just run the specified command -exec "$@" \ No newline at end of file diff --git a/mongo-initiator/4.4/Dockerfile b/mongo-initiator/4.4/Dockerfile deleted file mode 100644 index bd937f65..00000000 --- a/mongo-initiator/4.4/Dockerfile +++ /dev/null @@ -1,10 +0,0 @@ -FROM mongo:4.4 - -LABEL maintainer="Debezium Community" - -COPY ./docker-entrypoint.sh / - -USER mongodb - -ENTRYPOINT ["/docker-entrypoint.sh"] -CMD ["start"] diff --git a/mongo-initiator/4.4/README.md b/mongo-initiator/4.4/README.md deleted file mode 100644 index 8fe3b980..00000000 --- a/mongo-initiator/4.4/README.md +++ /dev/null @@ -1,26 +0,0 @@ -Initiate a MongoDB replica set on a set of running MongoDB servers, and optionally add the replica set as a shard to one or more running MongoDB routers. - -# How to use this image - -## Initiate a replica set - -With one or more MongoDB servers already running, start a container with this image to check if the replica set is initiated, and if not to initiate it and add all of the servers to the replica set. Start the container with the name of the replica set in the `$REPLICASET` environment variable, using links named like "MONGO_n_" (where _n_=1,2,3, etc.) for each of the MongoDB servers that are to be in the replica set. - -For example, consider three already-running MongoDB servers running in containers `data1`, `data2`, and `data3`. Running a container using the following command will check whether the replica set named `rs0` is properly initiated on these servers, and if not will initiate the replica set: - - $ docker run -it --name mongo-init --rm -e REPLICASET=rs0 --link data1:mongo1 --link data2:mongo2 --link data3:mongo3 quay.io/debezium/mongo-initiator - -The container will exit as soon as the replica set is initiated. - -## Initiate a shard replica set - -The container can optionally add the replica set as a _shard_ to one or more MongoDB routers. For example, consider three MongoDB servers running in containers `shardA1`, `shardA2`, and `shardA3`, and two MongoDB routers running in containers `router1` and `router2`. The following command will ensure that `shardA1`, `shardA2`, and `shardA3` are properly initiated as replica set `shardA`, and that the `shardA` replica set is added as a shard to the routers `router1` and `router2`: - - $ docker run -it --name mongo-init --rm -e REPLICASET=shardA --link shardA1:mongo1 --link shardA2:mongo2 --link shardA3:mongo3 --link router1 --link router2 quay.io/debezium/mongo-initiator - -Additional shard replica sets can be initiated and added by running additional containers. For example: - - $ docker run -it --name mongo-init --rm -e REPLICASET=shardB --link shardB1:mongo1 --link shardB2:mongo2 --link shardB3:mongo3 --link router1 --link router2 quay.io/debezium/mongo-initiator - - - diff --git a/mongo-initiator/4.4/docker-entrypoint.sh b/mongo-initiator/4.4/docker-entrypoint.sh deleted file mode 100755 index 5a8766aa..00000000 --- a/mongo-initiator/4.4/docker-entrypoint.sh +++ /dev/null @@ -1,177 +0,0 @@ -#!/bin/bash - -# Exit immediately if a *pipeline* returns a non-zero status. (Add -x for command tracing) -set -eEo pipefail - -# The names of container links are as follows, where 'n' is 1, 2, 3, etc.: -# -# "MONGOn" - specifies the Mongo replica set nodes, and n=1 for the primary node -# "ROUTERn" - specifies the Mongo router servers (optional, order is not important) -# -# The following environment variables are recognized: -# -# "REPLICASET" - specifies the name of the replica set for storing data/shards -# -# This script will attempt to initiate the replica set in the Mongo servers specified in the one or more `MONGOn` -# links, where the name of the replica set is given in the `REPLICASET` environment variable. (This step does -# nothing if the replica set is already initiated.) Then, if one or more `ROUTERn` links are specified, this -# script will add the replica set named `REPLICASET` as a shard to each of these MongoDB routers. -# - -if [[ -z $1 ]]; then - ARG1="start" -else - ARG1=$1 -fi - -MONGO="/usr/bin/mongo" - -# -# Process all MongoDB nodes by looking for environment variables that match 'MONGOn_PPORT_*_ADDR': -# -NODE_COUNT=0; -for VAR in `env | sort` -do - # First look for port 27019 used for the config server replica sets - env_var=`echo "$VAR" | sed -r "s/(.*)=.*/\1/g"` - if [[ $env_var =~ ^MONGO([0-9]+)_PORT_27019_TCP_ADDR ]]; then - NODE_COUNT=$(($NODE_COUNT+1)) - NODE_HOSTS[$NODE_COUNT]="${!env_var}"; - NODE_PORTS[$NODE_COUNT]="27019"; - if [[ $NODE_COUNT -eq 1 ]]; then - PRIMARY_HOST=${!env_var} - PRIMARY_PORT=27019 - fi - fi -done -if [[ -z $PRIMARY_HOST ]]; then - NODE_COUNT=0; - # None were found, so use whatever is available ... - for VAR in `env | sort` - do - env_var=`echo "$VAR" | sed -r "s/(.*)=.*/\1/g"` - if [[ $env_var =~ ^MONGO([0-9]+)_PORT_([0-9]+)_TCP_ADDR ]]; then - NODE_COUNT=$(($NODE_COUNT+1)) - NODE_HOSTS[$NODE_COUNT]="${!env_var}"; - NODE_PORTS[$NODE_COUNT]="${BASH_REMATCH[2]}"; - if [[ $NODE_COUNT -eq 1 ]]; then - PRIMARY_HOST=${!env_var} - PRIMARY_PORT=${BASH_REMATCH[2]} - fi - fi - done -fi - -# -# Process all MongoDB *router* nodes by looking for environment variables that match 'ROUTERn_PPORT_*_ADDR': -# -ROUTER_COUNT=0; -for VAR in `env | sort` -do - env_var=`echo "$VAR" | sed -r "s/(.*)=.*/\1/g"` - if [[ $env_var =~ ^ROUTER([0-9]+)_PORT_([0-9]+)_TCP_ADDR ]]; then - ROUTER_COUNT=$(($ROUTER_COUNT+1)) - ROUTER_HOSTS[$ROUTER_COUNT]="${!env_var}"; - ROUTER_PORTS[$ROUTER_COUNT]="${BASH_REMATCH[2]}"; - fi -done - -export NODE_HOSTS -export NODE_PORTS -export ROUTER_HOSTS -export ROUTER_PORTS - -# Process some known arguments ... -case $ARG1 in - start) - if [[ $NODE_COUNT -lt 1 ]]; then - echo "At least one Mongo node must be defined in container links, starting with \"MONGO1\" for the primary node and continuing with \"MONGO2\", etc. for secondaries." - exit 1; - fi - if [[ -z "$REPLICASET" ]]; then - echo "The name of the replica set must be defined with the \"REPLICASET\" environment variable" - exit 1; - fi - - # Define the command that will connect the mongo shell to the primary node ... - PRIMARY_MONGO="$MONGO --host $PRIMARY_HOST --port $PRIMARY_PORT" - - # Wait for the nodes to become available ... - echo "Testing connection to MongoDB primary node at ${PRIMARY_HOST}:${PRIMARY_PORT} ..." - status=$($PRIMARY_MONGO --eval db) - if [ "$?" -ne 0 ]; then - echo "Error: Unable to connect to ${PRIMARY_HOST}:${PRIMARY_PORT}" - echo "" - echo "${status}" - exit 2 - fi - - # See if the replica set is not set up ... - rsStatus=$($PRIMARY_MONGO --eval "rs.status()") - if [[ $rsStatus =~ "no replset config has been received" ]]; then - # Set up the replica set configuration document ... - echo "Using MongoDB primary node to initiate replica set \"${REPLICASET}\" with:" - CONFIGVAR="config= {_id: \"${REPLICASET}\", members:[ " - hostNum=1 - while [[ $hostNum -le $NODE_COUNT ]]; do - hostAndPort="${NODE_HOSTS[$hostNum]}:${NODE_PORTS[$hostNum]}" - if [[ $hostNum -eq 1 ]]; then - priority=2 - echo "- primary node: ${hostAndPort}" - else - priority=1 - echo "- secondary node: ${hostAndPort}" - CONFIGVAR="${CONFIGVAR}," - fi - CONFIGVAR="${CONFIGVAR} {_id: ${hostNum}, host: \"${hostAndPort}\", priority: ${priority} }" - hostNum=$hostNum+1 - done - CONFIGVAR="${CONFIGVAR} ] }" - - # Initiate the replica set with our document ... - $PRIMARY_MONGO --eval "${CONFIGVAR};rs.initiate(config);" - - rsStatus=$($PRIMARY_MONGO --eval "rs.status()") - if [[ $rsStatus =~ "no replset config has been received" ]]; then - echo "Failed to initialize replica set" - exit 1 - fi - else - echo "Replica set \"${REPLICASET}\" is already initiated." - fi - #if [[ -n $VERBOSE ]]; then - # echo "" - # echo "Current replica status:" - # echo "${rsStatus}" - #fi - echo "" - echo "Replica set is ready" - echo "" - - if [[ $ROUTER_COUNT -gt 0 ]]; then - # Add the primary of the replica set as a shard to each of the routers ... - echo "" - echo "Checking ${ROUTER_COUNT} router for shard using replica set \"${REPLICASET}/${PRIMARY_HOST}:${PRIMARY_PORT}\":" - hostNum=1 - added=0 - while [[ $hostNum -le $ROUTER_COUNT ]]; do - hostAndPort="${ROUTER_HOSTS[$hostNum]}:${ROUTER_PORTS[$hostNum]}" - result=$($MONGO --host ${ROUTER_HOSTS[$hostNum]} --port ${ROUTER_PORTS[$hostNum]} --eval "rs.status();sh.addShard( \"${REPLICASET}/${PRIMARY_HOST}:${PRIMARY_PORT}\" )") - if [[ $result =~ "E11000 duplicate key error collection: config.shards index: _id_ dup key" ]]; then - echo "- ${hostAndPort} (shard exists)" - else - added=$(($added+1)) - echo "- ${hostAndPort} (adding shard)" - fi - hostNum=$hostNum+1 - done - echo "Added replica set \"${REPLICASET}/${PRIMARY_HOST}:${PRIMARY_PORT}\" as shard to ${added} routers." - echo "" - echo "Routers are ready." - fi - exit 0 - ;; -esac - -# Otherwise just run the specified command -exec "$@" \ No newline at end of file diff --git a/mongo-initiator/5.0/Dockerfile b/mongo-initiator/5.0/Dockerfile deleted file mode 100644 index 3f7d9d91..00000000 --- a/mongo-initiator/5.0/Dockerfile +++ /dev/null @@ -1,10 +0,0 @@ -FROM mongo:5.0 - -LABEL maintainer="Debezium Community" - -COPY ./docker-entrypoint.sh / - -USER mongodb - -ENTRYPOINT ["/docker-entrypoint.sh"] -CMD ["start"] diff --git a/mongo-initiator/5.0/README.md b/mongo-initiator/5.0/README.md deleted file mode 100644 index 8fe3b980..00000000 --- a/mongo-initiator/5.0/README.md +++ /dev/null @@ -1,26 +0,0 @@ -Initiate a MongoDB replica set on a set of running MongoDB servers, and optionally add the replica set as a shard to one or more running MongoDB routers. - -# How to use this image - -## Initiate a replica set - -With one or more MongoDB servers already running, start a container with this image to check if the replica set is initiated, and if not to initiate it and add all of the servers to the replica set. Start the container with the name of the replica set in the `$REPLICASET` environment variable, using links named like "MONGO_n_" (where _n_=1,2,3, etc.) for each of the MongoDB servers that are to be in the replica set. - -For example, consider three already-running MongoDB servers running in containers `data1`, `data2`, and `data3`. Running a container using the following command will check whether the replica set named `rs0` is properly initiated on these servers, and if not will initiate the replica set: - - $ docker run -it --name mongo-init --rm -e REPLICASET=rs0 --link data1:mongo1 --link data2:mongo2 --link data3:mongo3 quay.io/debezium/mongo-initiator - -The container will exit as soon as the replica set is initiated. - -## Initiate a shard replica set - -The container can optionally add the replica set as a _shard_ to one or more MongoDB routers. For example, consider three MongoDB servers running in containers `shardA1`, `shardA2`, and `shardA3`, and two MongoDB routers running in containers `router1` and `router2`. The following command will ensure that `shardA1`, `shardA2`, and `shardA3` are properly initiated as replica set `shardA`, and that the `shardA` replica set is added as a shard to the routers `router1` and `router2`: - - $ docker run -it --name mongo-init --rm -e REPLICASET=shardA --link shardA1:mongo1 --link shardA2:mongo2 --link shardA3:mongo3 --link router1 --link router2 quay.io/debezium/mongo-initiator - -Additional shard replica sets can be initiated and added by running additional containers. For example: - - $ docker run -it --name mongo-init --rm -e REPLICASET=shardB --link shardB1:mongo1 --link shardB2:mongo2 --link shardB3:mongo3 --link router1 --link router2 quay.io/debezium/mongo-initiator - - - diff --git a/mongo-initiator/5.0/docker-entrypoint.sh b/mongo-initiator/5.0/docker-entrypoint.sh deleted file mode 100755 index fcf6ba7f..00000000 --- a/mongo-initiator/5.0/docker-entrypoint.sh +++ /dev/null @@ -1,177 +0,0 @@ -#!/bin/bash - -# Exit immediately if a *pipeline* returns a non-zero status. (Add -x for command tracing) -set -eEo pipefail - -# The names of container links are as follows, where 'n' is 1, 2, 3, etc.: -# -# "MONGOn" - specifies the Mongo replica set nodes, and n=1 for the primary node -# "ROUTERn" - specifies the Mongo router servers (optional, order is not important) -# -# The following environment variables are recognized: -# -# "REPLICASET" - specifies the name of the replica set for storing data/shards -# -# This script will attempt to initiate the replica set in the Mongo servers specified in the one or more `MONGOn` -# links, where the name of the replica set is given in the `REPLICASET` environment variable. (This step does -# nothing if the replica set is already initiated.) Then, if one or more `ROUTERn` links are specified, this -# script will add the replica set named `REPLICASET` as a shard to each of these MongoDB routers. -# - -if [[ -z $1 ]]; then - ARG1="start" -else - ARG1=$1 -fi - -MONGO="/usr/bin/mongo" - -# -# Process all MongoDB nodes by looking for environment variables that match 'MONGOn_PPORT_*_ADDR': -# -NODE_COUNT=0; -for VAR in `env | sort` -do - # First look for port 27019 used for the config server replica sets - env_var=`echo "$VAR" | sed -r "s/(.*)=.*/\1/g"` - if [[ $env_var =~ ^MONGO([0-9]+)_PORT_27019_TCP_ADDR ]]; then - NODE_COUNT=$(($NODE_COUNT+1)) - NODE_HOSTS[$NODE_COUNT]="${!env_var}"; - NODE_PORTS[$NODE_COUNT]="27019"; - if [[ $NODE_COUNT -eq 1 ]]; then - PRIMARY_HOST=${!env_var} - PRIMARY_PORT=27019 - fi - fi -done -if [[ -z $PRIMARY_HOST ]]; then - NODE_COUNT=0; - # None were found, so use whatever is available ... - for VAR in `env | sort` - do - env_var=`echo "$VAR" | sed -r "s/(.*)=.*/\1/g"` - if [[ $env_var =~ ^MONGO([0-9]+)_PORT_([0-9]+)_TCP_ADDR ]]; then - NODE_COUNT=$(($NODE_COUNT+1)) - NODE_HOSTS[$NODE_COUNT]="${!env_var}"; - NODE_PORTS[$NODE_COUNT]="${BASH_REMATCH[2]}"; - if [[ $NODE_COUNT -eq 1 ]]; then - PRIMARY_HOST=${!env_var} - PRIMARY_PORT=${BASH_REMATCH[2]} - fi - fi - done -fi - -# -# Process all MongoDB *router* nodes by looking for environment variables that match 'ROUTERn_PPORT_*_ADDR': -# -ROUTER_COUNT=0; -for VAR in `env | sort` -do - env_var=`echo "$VAR" | sed -r "s/(.*)=.*/\1/g"` - if [[ $env_var =~ ^ROUTER([0-9]+)_PORT_([0-9]+)_TCP_ADDR ]]; then - ROUTER_COUNT=$(($ROUTER_COUNT+1)) - ROUTER_HOSTS[$ROUTER_COUNT]="${!env_var}"; - ROUTER_PORTS[$ROUTER_COUNT]="${BASH_REMATCH[2]}"; - fi -done - -export NODE_HOSTS -export NODE_PORTS -export ROUTER_HOSTS -export ROUTER_PORTS - -# Process some known arguments ... -case $ARG1 in - start) - if [[ $NODE_COUNT -lt 1 ]]; then - echo "At least one Mongo node must be defined in container links, starting with \"MONGO1\" for the primary node and continuing with \"MONGO2\", etc. for secondaries." - exit 1; - fi - if [[ -z "$REPLICASET" ]]; then - echo "The name of the replica set must be defined with the \"REPLICASET\" environment variable" - exit 1; - fi - - # Define the command that will connect the mongo shell to the primary node ... - PRIMARY_MONGO="$MONGO --host $PRIMARY_HOST --port $PRIMARY_PORT" - - # Wait for the nodes to become available ... - echo "Testing connection to MongoDB primary node at ${PRIMARY_HOST}:${PRIMARY_PORT} ..." - status=$($PRIMARY_MONGO --eval db) - if [ "$?" -ne 0 ]; then - echo "Error: Unable to connect to ${PRIMARY_HOST}:${PRIMARY_PORT}" - echo "" - echo "${status}" - exit 2 - fi - - # See if the replica set is not set up ... - rsStatus=$($PRIMARY_MONGO --eval "rs.status()") - if [[ $rsStatus =~ "no replset config has been received" ]]; then - # Set up the replica set configuration document ... - echo "Using MongoDB primary node to initiate replica set \"${REPLICASET}\" with:" - CONFIGVAR="config= {_id: \"${REPLICASET}\", members:[ " - hostNum=1 - while [[ $hostNum -le $NODE_COUNT ]]; do - hostAndPort="${NODE_HOSTS[$hostNum]}:${NODE_PORTS[$hostNum]}" - if [[ $hostNum -eq 1 ]]; then - priority=2 - echo "- primary node: ${hostAndPort}" - else - priority=1 - echo "- secondary node: ${hostAndPort}" - CONFIGVAR="${CONFIGVAR}," - fi - CONFIGVAR="${CONFIGVAR} {_id: ${hostNum}, host: \"${hostAndPort}\", priority: ${priority} }" - hostNum=$hostNum+1 - done - CONFIGVAR="${CONFIGVAR} ] }" - - # Initiate the replica set with our document ... - $PRIMARY_MONGO --eval "${CONFIGVAR};rs.initiate(config);" - - rsStatus=$($PRIMARY_MONGO --eval "rs.status()") - if [[ $rsStatus =~ "no replset config has been received" ]]; then - echo "Failed to initialize replica set" - exit 1 - fi - else - echo "Replica set \"${REPLICASET}\" is already initiated." - fi - #if [[ -n $VERBOSE ]]; then - # echo "" - # echo "Current replica status:" - # echo "${rsStatus}" - #fi - echo "" - echo "Replica set is ready" - echo "" - - if [[ $ROUTER_COUNT -gt 0 ]]; then - # Add the primary of the replica set as a shard to each of the routers ... - echo "" - echo "Checking ${ROUTER_COUNT} router for shard using replica set \"${REPLICASET}/${PRIMARY_HOST}:${PRIMARY_PORT}\":" - hostNum=1 - added=0 - while [[ $hostNum -le $ROUTER_COUNT ]]; do - hostAndPort="${ROUTER_HOSTS[$hostNum]}:${ROUTER_PORTS[$hostNum]}" - result=$($MONGO --host ${ROUTER_HOSTS[$hostNum]} --port ${ROUTER_PORTS[$hostNum]} --eval "rs.status();sh.addShard( \"${REPLICASET}/${PRIMARY_HOST}:${PRIMARY_PORT}\" )") - if [[ $result =~ "E11000 duplicate key error collection: config.shards index: _id_ dup key" ]]; then - echo "- ${hostAndPort} (shard exists)" - else - added=$(($added+1)) - echo "- ${hostAndPort} (adding shard)" - fi - hostNum=$hostNum+1 - done - echo "Added replica set \"${REPLICASET}/${PRIMARY_HOST}:${PRIMARY_PORT}\" as shard to ${added} routers." - echo "" - echo "Routers are ready." - fi - exit 0 - ;; -esac - -# Otherwise just run the specified command -exec "$@" diff --git a/mongo-initiator/6.0/Dockerfile b/mongo-initiator/6.0/Dockerfile deleted file mode 100644 index 02149632..00000000 --- a/mongo-initiator/6.0/Dockerfile +++ /dev/null @@ -1,10 +0,0 @@ -FROM mongo:6.0 - -LABEL maintainer="Debezium Community" - -COPY ./docker-entrypoint.sh / - -USER mongodb - -ENTRYPOINT ["/docker-entrypoint.sh"] -CMD ["start"] diff --git a/mongo-initiator/6.0/README.md b/mongo-initiator/6.0/README.md deleted file mode 100644 index 8fe3b980..00000000 --- a/mongo-initiator/6.0/README.md +++ /dev/null @@ -1,26 +0,0 @@ -Initiate a MongoDB replica set on a set of running MongoDB servers, and optionally add the replica set as a shard to one or more running MongoDB routers. - -# How to use this image - -## Initiate a replica set - -With one or more MongoDB servers already running, start a container with this image to check if the replica set is initiated, and if not to initiate it and add all of the servers to the replica set. Start the container with the name of the replica set in the `$REPLICASET` environment variable, using links named like "MONGO_n_" (where _n_=1,2,3, etc.) for each of the MongoDB servers that are to be in the replica set. - -For example, consider three already-running MongoDB servers running in containers `data1`, `data2`, and `data3`. Running a container using the following command will check whether the replica set named `rs0` is properly initiated on these servers, and if not will initiate the replica set: - - $ docker run -it --name mongo-init --rm -e REPLICASET=rs0 --link data1:mongo1 --link data2:mongo2 --link data3:mongo3 quay.io/debezium/mongo-initiator - -The container will exit as soon as the replica set is initiated. - -## Initiate a shard replica set - -The container can optionally add the replica set as a _shard_ to one or more MongoDB routers. For example, consider three MongoDB servers running in containers `shardA1`, `shardA2`, and `shardA3`, and two MongoDB routers running in containers `router1` and `router2`. The following command will ensure that `shardA1`, `shardA2`, and `shardA3` are properly initiated as replica set `shardA`, and that the `shardA` replica set is added as a shard to the routers `router1` and `router2`: - - $ docker run -it --name mongo-init --rm -e REPLICASET=shardA --link shardA1:mongo1 --link shardA2:mongo2 --link shardA3:mongo3 --link router1 --link router2 quay.io/debezium/mongo-initiator - -Additional shard replica sets can be initiated and added by running additional containers. For example: - - $ docker run -it --name mongo-init --rm -e REPLICASET=shardB --link shardB1:mongo1 --link shardB2:mongo2 --link shardB3:mongo3 --link router1 --link router2 quay.io/debezium/mongo-initiator - - - diff --git a/mongo-initiator/6.0/docker-entrypoint.sh b/mongo-initiator/6.0/docker-entrypoint.sh deleted file mode 100755 index f2c2f621..00000000 --- a/mongo-initiator/6.0/docker-entrypoint.sh +++ /dev/null @@ -1,177 +0,0 @@ -#!/bin/bash - -# Exit immediately if a *pipeline* returns a non-zero status. (Add -x for command tracing) -set -Eo pipefail - -# The names of container links are as follows, where 'n' is 1, 2, 3, etc.: -# -# "MONGOn" - specifies the Mongo replica set nodes, and n=1 for the primary node -# "ROUTERn" - specifies the Mongo router servers (optional, order is not important) -# -# The following environment variables are recognized: -# -# "REPLICASET" - specifies the name of the replica set for storing data/shards -# -# This script will attempt to initiate the replica set in the Mongo servers specified in the one or more `MONGOn` -# links, where the name of the replica set is given in the `REPLICASET` environment variable. (This step does -# nothing if the replica set is already initiated.) Then, if one or more `ROUTERn` links are specified, this -# script will add the replica set named `REPLICASET` as a shard to each of these MongoDB routers. -# - -if [[ -z $1 ]]; then - ARG1="start" -else - ARG1=$1 -fi - -MONGO="/usr/bin/mongosh" - -# -# Process all MongoDB nodes by looking for environment variables that match 'MONGOn_PPORT_*_ADDR': -# -NODE_COUNT=0; -for VAR in `env | sort` -do - # First look for port 27019 used for the config server replica sets - env_var=`echo "$VAR" | sed -r "s/(.*)=.*/\1/g"` - if [[ $env_var =~ ^MONGO([0-9]+)_PORT_27019_TCP_ADDR ]]; then - NODE_COUNT=$(($NODE_COUNT+1)) - NODE_HOSTS[$NODE_COUNT]="${!env_var}"; - NODE_PORTS[$NODE_COUNT]="27019"; - if [[ $NODE_COUNT -eq 1 ]]; then - PRIMARY_HOST=${!env_var} - PRIMARY_PORT=27019 - fi - fi -done -if [[ -z $PRIMARY_HOST ]]; then - NODE_COUNT=0; - # None were found, so use whatever is available ... - for VAR in `env | sort` - do - env_var=`echo "$VAR" | sed -r "s/(.*)=.*/\1/g"` - if [[ $env_var =~ ^MONGO([0-9]+)_PORT_([0-9]+)_TCP_ADDR ]]; then - NODE_COUNT=$(($NODE_COUNT+1)) - NODE_HOSTS[$NODE_COUNT]="${!env_var}"; - NODE_PORTS[$NODE_COUNT]="${BASH_REMATCH[2]}"; - if [[ $NODE_COUNT -eq 1 ]]; then - PRIMARY_HOST=${!env_var} - PRIMARY_PORT=${BASH_REMATCH[2]} - fi - fi - done -fi - -# -# Process all MongoDB *router* nodes by looking for environment variables that match 'ROUTERn_PPORT_*_ADDR': -# -ROUTER_COUNT=0; -for VAR in `env | sort` -do - env_var=`echo "$VAR" | sed -r "s/(.*)=.*/\1/g"` - if [[ $env_var =~ ^ROUTER([0-9]+)_PORT_([0-9]+)_TCP_ADDR ]]; then - ROUTER_COUNT=$(($ROUTER_COUNT+1)) - ROUTER_HOSTS[$ROUTER_COUNT]="${!env_var}"; - ROUTER_PORTS[$ROUTER_COUNT]="${BASH_REMATCH[2]}"; - fi -done - -export NODE_HOSTS -export NODE_PORTS -export ROUTER_HOSTS -export ROUTER_PORTS - -# Process some known arguments ... -case $ARG1 in - start) - if [[ $NODE_COUNT -lt 1 ]]; then - echo "At least one Mongo node must be defined in container links, starting with \"MONGO1\" for the primary node and continuing with \"MONGO2\", etc. for secondaries." - exit 1; - fi - if [[ -z "$REPLICASET" ]]; then - echo "The name of the replica set must be defined with the \"REPLICASET\" environment variable" - exit 1; - fi - - # Define the command that will connect the mongo shell to the primary node ... - PRIMARY_MONGO="$MONGO --host $PRIMARY_HOST --port $PRIMARY_PORT" - - # Wait for the nodes to become available ... - echo "Testing connection to MongoDB primary node at ${PRIMARY_HOST}:${PRIMARY_PORT} ..." - status=$($PRIMARY_MONGO --eval db --quiet) - if [ "$?" -ne 0 ]; then - echo "Error: Unable to connect to ${PRIMARY_HOST}:${PRIMARY_PORT}" - echo "" - echo "${status}" - exit 2 - fi - - # See if the replica set is not set up ... - rsStatus=$($PRIMARY_MONGO --eval "rs.status()" --quiet 2>&1) - if [[ $rsStatus =~ "no replset config has been received" ]]; then - # Set up the replica set configuration document ... - echo "Using MongoDB primary node to initiate replica set \"${REPLICASET}\" with:" - CONFIGVAR="config= {_id: \"${REPLICASET}\", members:[ " - hostNum=1 - while [[ $hostNum -le $NODE_COUNT ]]; do - hostAndPort="${NODE_HOSTS[$hostNum]}:${NODE_PORTS[$hostNum]}" - if [[ $hostNum -eq 1 ]]; then - priority=2 - echo "- primary node: ${hostAndPort}" - else - priority=1 - echo "- secondary node: ${hostAndPort}" - CONFIGVAR="${CONFIGVAR}," - fi - CONFIGVAR="${CONFIGVAR} {_id: ${hostNum}, host: \"${hostAndPort}\", priority: ${priority} }" - hostNum=$hostNum+1 - done - CONFIGVAR="${CONFIGVAR} ] }" - - # Initiate the replica set with our document ... - $PRIMARY_MONGO --eval "${CONFIGVAR};rs.initiate(config);" --quiet - - rsStatus=$($PRIMARY_MONGO --eval "rs.status()" --quiet 2>&1) - if [[ $rsStatus =~ "no replset config has been received" ]]; then - echo "Failed to initialize replica set" - exit 1 - fi - else - echo "Replica set \"${REPLICASET}\" is already initiated." - fi - #if [[ -n $VERBOSE ]]; then - # echo "" - # echo "Current replica status:" - # echo "${rsStatus}" - #fi - echo "" - echo "Replica set is ready" - echo "" - - if [[ $ROUTER_COUNT -gt 0 ]]; then - # Add the primary of the replica set as a shard to each of the routers ... - echo "" - echo "Checking ${ROUTER_COUNT} router for shard using replica set \"${REPLICASET}/${PRIMARY_HOST}:${PRIMARY_PORT}\":" - hostNum=1 - added=0 - while [[ $hostNum -le $ROUTER_COUNT ]]; do - hostAndPort="${ROUTER_HOSTS[$hostNum]}:${ROUTER_PORTS[$hostNum]}" - result=$($MONGO --host ${ROUTER_HOSTS[$hostNum]} --port ${ROUTER_PORTS[$hostNum]} --eval "rs.status();sh.addShard( \"${REPLICASET}/${PRIMARY_HOST}:${PRIMARY_PORT}\" )" --quiet 2>&1) - if [[ $result =~ "E11000 duplicate key error collection: config.shards index: _id_ dup key" ]]; then - echo "- ${hostAndPort} (shard exists)" - else - added=$(($added+1)) - echo "- ${hostAndPort} (adding shard)" - fi - hostNum=$hostNum+1 - done - echo "Added replica set \"${REPLICASET}/${PRIMARY_HOST}:${PRIMARY_PORT}\" as shard to ${added} routers." - echo "" - echo "Routers are ready." - fi - exit 0 - ;; -esac - -# Otherwise just run the specified command -exec "$@" diff --git a/mongo-initiator/7.0/Dockerfile b/mongo-initiator/7.0/Dockerfile deleted file mode 100644 index 5602158e..00000000 --- a/mongo-initiator/7.0/Dockerfile +++ /dev/null @@ -1,10 +0,0 @@ -FROM mongo:7.0 - -LABEL maintainer="Debezium Community" - -COPY ./docker-entrypoint.sh / - -USER mongodb - -ENTRYPOINT ["/docker-entrypoint.sh"] -CMD ["start"] diff --git a/mongo-initiator/7.0/README.md b/mongo-initiator/7.0/README.md deleted file mode 100644 index 8fe3b980..00000000 --- a/mongo-initiator/7.0/README.md +++ /dev/null @@ -1,26 +0,0 @@ -Initiate a MongoDB replica set on a set of running MongoDB servers, and optionally add the replica set as a shard to one or more running MongoDB routers. - -# How to use this image - -## Initiate a replica set - -With one or more MongoDB servers already running, start a container with this image to check if the replica set is initiated, and if not to initiate it and add all of the servers to the replica set. Start the container with the name of the replica set in the `$REPLICASET` environment variable, using links named like "MONGO_n_" (where _n_=1,2,3, etc.) for each of the MongoDB servers that are to be in the replica set. - -For example, consider three already-running MongoDB servers running in containers `data1`, `data2`, and `data3`. Running a container using the following command will check whether the replica set named `rs0` is properly initiated on these servers, and if not will initiate the replica set: - - $ docker run -it --name mongo-init --rm -e REPLICASET=rs0 --link data1:mongo1 --link data2:mongo2 --link data3:mongo3 quay.io/debezium/mongo-initiator - -The container will exit as soon as the replica set is initiated. - -## Initiate a shard replica set - -The container can optionally add the replica set as a _shard_ to one or more MongoDB routers. For example, consider three MongoDB servers running in containers `shardA1`, `shardA2`, and `shardA3`, and two MongoDB routers running in containers `router1` and `router2`. The following command will ensure that `shardA1`, `shardA2`, and `shardA3` are properly initiated as replica set `shardA`, and that the `shardA` replica set is added as a shard to the routers `router1` and `router2`: - - $ docker run -it --name mongo-init --rm -e REPLICASET=shardA --link shardA1:mongo1 --link shardA2:mongo2 --link shardA3:mongo3 --link router1 --link router2 quay.io/debezium/mongo-initiator - -Additional shard replica sets can be initiated and added by running additional containers. For example: - - $ docker run -it --name mongo-init --rm -e REPLICASET=shardB --link shardB1:mongo1 --link shardB2:mongo2 --link shardB3:mongo3 --link router1 --link router2 quay.io/debezium/mongo-initiator - - - diff --git a/mongo-initiator/7.0/docker-entrypoint.sh b/mongo-initiator/7.0/docker-entrypoint.sh deleted file mode 100755 index f2c2f621..00000000 --- a/mongo-initiator/7.0/docker-entrypoint.sh +++ /dev/null @@ -1,177 +0,0 @@ -#!/bin/bash - -# Exit immediately if a *pipeline* returns a non-zero status. (Add -x for command tracing) -set -Eo pipefail - -# The names of container links are as follows, where 'n' is 1, 2, 3, etc.: -# -# "MONGOn" - specifies the Mongo replica set nodes, and n=1 for the primary node -# "ROUTERn" - specifies the Mongo router servers (optional, order is not important) -# -# The following environment variables are recognized: -# -# "REPLICASET" - specifies the name of the replica set for storing data/shards -# -# This script will attempt to initiate the replica set in the Mongo servers specified in the one or more `MONGOn` -# links, where the name of the replica set is given in the `REPLICASET` environment variable. (This step does -# nothing if the replica set is already initiated.) Then, if one or more `ROUTERn` links are specified, this -# script will add the replica set named `REPLICASET` as a shard to each of these MongoDB routers. -# - -if [[ -z $1 ]]; then - ARG1="start" -else - ARG1=$1 -fi - -MONGO="/usr/bin/mongosh" - -# -# Process all MongoDB nodes by looking for environment variables that match 'MONGOn_PPORT_*_ADDR': -# -NODE_COUNT=0; -for VAR in `env | sort` -do - # First look for port 27019 used for the config server replica sets - env_var=`echo "$VAR" | sed -r "s/(.*)=.*/\1/g"` - if [[ $env_var =~ ^MONGO([0-9]+)_PORT_27019_TCP_ADDR ]]; then - NODE_COUNT=$(($NODE_COUNT+1)) - NODE_HOSTS[$NODE_COUNT]="${!env_var}"; - NODE_PORTS[$NODE_COUNT]="27019"; - if [[ $NODE_COUNT -eq 1 ]]; then - PRIMARY_HOST=${!env_var} - PRIMARY_PORT=27019 - fi - fi -done -if [[ -z $PRIMARY_HOST ]]; then - NODE_COUNT=0; - # None were found, so use whatever is available ... - for VAR in `env | sort` - do - env_var=`echo "$VAR" | sed -r "s/(.*)=.*/\1/g"` - if [[ $env_var =~ ^MONGO([0-9]+)_PORT_([0-9]+)_TCP_ADDR ]]; then - NODE_COUNT=$(($NODE_COUNT+1)) - NODE_HOSTS[$NODE_COUNT]="${!env_var}"; - NODE_PORTS[$NODE_COUNT]="${BASH_REMATCH[2]}"; - if [[ $NODE_COUNT -eq 1 ]]; then - PRIMARY_HOST=${!env_var} - PRIMARY_PORT=${BASH_REMATCH[2]} - fi - fi - done -fi - -# -# Process all MongoDB *router* nodes by looking for environment variables that match 'ROUTERn_PPORT_*_ADDR': -# -ROUTER_COUNT=0; -for VAR in `env | sort` -do - env_var=`echo "$VAR" | sed -r "s/(.*)=.*/\1/g"` - if [[ $env_var =~ ^ROUTER([0-9]+)_PORT_([0-9]+)_TCP_ADDR ]]; then - ROUTER_COUNT=$(($ROUTER_COUNT+1)) - ROUTER_HOSTS[$ROUTER_COUNT]="${!env_var}"; - ROUTER_PORTS[$ROUTER_COUNT]="${BASH_REMATCH[2]}"; - fi -done - -export NODE_HOSTS -export NODE_PORTS -export ROUTER_HOSTS -export ROUTER_PORTS - -# Process some known arguments ... -case $ARG1 in - start) - if [[ $NODE_COUNT -lt 1 ]]; then - echo "At least one Mongo node must be defined in container links, starting with \"MONGO1\" for the primary node and continuing with \"MONGO2\", etc. for secondaries." - exit 1; - fi - if [[ -z "$REPLICASET" ]]; then - echo "The name of the replica set must be defined with the \"REPLICASET\" environment variable" - exit 1; - fi - - # Define the command that will connect the mongo shell to the primary node ... - PRIMARY_MONGO="$MONGO --host $PRIMARY_HOST --port $PRIMARY_PORT" - - # Wait for the nodes to become available ... - echo "Testing connection to MongoDB primary node at ${PRIMARY_HOST}:${PRIMARY_PORT} ..." - status=$($PRIMARY_MONGO --eval db --quiet) - if [ "$?" -ne 0 ]; then - echo "Error: Unable to connect to ${PRIMARY_HOST}:${PRIMARY_PORT}" - echo "" - echo "${status}" - exit 2 - fi - - # See if the replica set is not set up ... - rsStatus=$($PRIMARY_MONGO --eval "rs.status()" --quiet 2>&1) - if [[ $rsStatus =~ "no replset config has been received" ]]; then - # Set up the replica set configuration document ... - echo "Using MongoDB primary node to initiate replica set \"${REPLICASET}\" with:" - CONFIGVAR="config= {_id: \"${REPLICASET}\", members:[ " - hostNum=1 - while [[ $hostNum -le $NODE_COUNT ]]; do - hostAndPort="${NODE_HOSTS[$hostNum]}:${NODE_PORTS[$hostNum]}" - if [[ $hostNum -eq 1 ]]; then - priority=2 - echo "- primary node: ${hostAndPort}" - else - priority=1 - echo "- secondary node: ${hostAndPort}" - CONFIGVAR="${CONFIGVAR}," - fi - CONFIGVAR="${CONFIGVAR} {_id: ${hostNum}, host: \"${hostAndPort}\", priority: ${priority} }" - hostNum=$hostNum+1 - done - CONFIGVAR="${CONFIGVAR} ] }" - - # Initiate the replica set with our document ... - $PRIMARY_MONGO --eval "${CONFIGVAR};rs.initiate(config);" --quiet - - rsStatus=$($PRIMARY_MONGO --eval "rs.status()" --quiet 2>&1) - if [[ $rsStatus =~ "no replset config has been received" ]]; then - echo "Failed to initialize replica set" - exit 1 - fi - else - echo "Replica set \"${REPLICASET}\" is already initiated." - fi - #if [[ -n $VERBOSE ]]; then - # echo "" - # echo "Current replica status:" - # echo "${rsStatus}" - #fi - echo "" - echo "Replica set is ready" - echo "" - - if [[ $ROUTER_COUNT -gt 0 ]]; then - # Add the primary of the replica set as a shard to each of the routers ... - echo "" - echo "Checking ${ROUTER_COUNT} router for shard using replica set \"${REPLICASET}/${PRIMARY_HOST}:${PRIMARY_PORT}\":" - hostNum=1 - added=0 - while [[ $hostNum -le $ROUTER_COUNT ]]; do - hostAndPort="${ROUTER_HOSTS[$hostNum]}:${ROUTER_PORTS[$hostNum]}" - result=$($MONGO --host ${ROUTER_HOSTS[$hostNum]} --port ${ROUTER_PORTS[$hostNum]} --eval "rs.status();sh.addShard( \"${REPLICASET}/${PRIMARY_HOST}:${PRIMARY_PORT}\" )" --quiet 2>&1) - if [[ $result =~ "E11000 duplicate key error collection: config.shards index: _id_ dup key" ]]; then - echo "- ${hostAndPort} (shard exists)" - else - added=$(($added+1)) - echo "- ${hostAndPort} (adding shard)" - fi - hostNum=$hostNum+1 - done - echo "Added replica set \"${REPLICASET}/${PRIMARY_HOST}:${PRIMARY_PORT}\" as shard to ${added} routers." - echo "" - echo "Routers are ready." - fi - exit 0 - ;; -esac - -# Otherwise just run the specified command -exec "$@"