4.0.13-debian-9-r0 release

This commit is contained in:
Bitnami Bot
2019-11-04 17:16:39 +00:00
parent 3e5ed49899
commit 7073d87932
12 changed files with 2095 additions and 0 deletions

View File

@@ -0,0 +1,25 @@
FROM bitnami/minideb-extras-base:stretch-r378
LABEL maintainer "Bitnami <containers@bitnami.com>"
ENV BITNAMI_PKG_CHMOD="-R g+rwX" \
HOME="/" \
OS_ARCH="amd64" \
OS_FLAVOUR="debian-9" \
OS_NAME="linux"
# Install required system packages and dependencies
RUN install_packages libc6 libcomerr2 libcurl3 libffi6 libgcc1 libgcrypt20 libgmp10 libgnutls30 libgpg-error0 libgssapi-krb5-2 libhogweed4 libidn11 libidn2-0 libk5crypto3 libkeyutils1 libkrb5-3 libkrb5support0 libldap-2.4-2 libnettle6 libnghttp2-14 libp11-kit0 libpcap0.8 libpsl5 librtmp1 libsasl2-2 libssh2-1 libssl1.0.2 libssl1.1 libtasn1-6 libunistring0 zlib1g
RUN . ./libcomponent.sh && component_unpack "mongodb" "4.0.13-0" --checksum ba03c87d3ee0187638e487b34cdfee71390cab1e48ca846b18b13498ee6fdbc2
COPY rootfs /
RUN /postunpack.sh
ENV BITNAMI_APP_NAME="mongodb" \
BITNAMI_IMAGE_VERSION="4.0.13-debian-9-r0" \
NAMI_PREFIX="/.nami" \
PATH="/opt/bitnami/mongodb/bin:$PATH"
EXPOSE 27017
USER 1001
ENTRYPOINT [ "/entrypoint.sh" ]
CMD [ "/run.sh" ]

View File

@@ -0,0 +1,45 @@
version: '2'
services:
mongodb-sharded:
image: 'bitnami/mongodb-sharded:4.0'
environment:
- MONGODB_ADVERTISED_HOSTNAME=mongodb-sharded
- MONGODB_SHARDING_MODE=mongos
- MONGODB_CFG_PRIMARY_HOST=mongodb-cfg
- MONGODB_CFG_REPLICA_SET_NAME=cfgreplicaset
- MONGODB_REPLICA_SET_KEY=replicasetkey123
- MONGODB_ROOT_PASSWORD=password123
ports:
- "27017:27017"
mongodb-shard0:
image: 'bitnami/mongodb-sharded:4.0'
environment:
- MONGODB_ADVERTISED_HOSTNAME=mongodb-shard0
- MONGODB_SHARDING_MODE=shardsvr
- MONGODB_MONGOS_HOST=mongodb-sharded
- MONGODB_ROOT_PASSWORD=password123
- MONGODB_REPLICA_SET_MODE=primary
- MONGODB_REPLICA_SET_KEY=replicasetkey123
- MONGODB_REPLICA_SET_NAME=shard0
volumes:
- 'shard0_data:/bitnami'
mongodb-cfg:
image: 'bitnami/mongodb-sharded:4.0'
environment:
- MONGODB_ADVERTISED_HOSTNAME=mongodb-cfg
- MONGODB_SHARDING_MODE=configsvr
- MONGODB_ROOT_PASSWORD=password123
- MONGODB_REPLICA_SET_MODE=primary
- MONGODB_REPLICA_SET_KEY=replicasetkey123
- MONGODB_REPLICA_SET_NAME=cfgreplicaset
volumes:
- 'cfg_data:/bitnami'
volumes:
shard0_data:
driver: local
cfg_data:
driver: local

View File

@@ -0,0 +1,28 @@
#!/bin/bash
# shellcheck disable=SC1091
set -o errexit
set -o nounset
set -o pipefail
# Load libraries
. /libbitnami.sh
. /libmongodb.sh
. /libmongodb-sharded.sh
# Load MongoDB env. variables
eval "$(mongodb_env)"
eval "$(mongodb_sharded_env)"
print_welcome_page
if [[ "$*" = "/run.sh" ]]; then
info "** Starting MongoDB Sharded setup **"
/setup.sh
info "** MongoDB Sharded setup finished! **"
fi
echo ""
exec "$@"

View File

@@ -0,0 +1,382 @@
#!/bin/bash
#
# Bitnami MongoDB library
# shellcheck disable=SC1090
# shellcheck disable=SC1091
# Load Generic Libraries
. /liblog.sh
. /libvalidations.sh
. /libmongodb.sh
########################
# Load global variables used on MongoDB Sharded configuration.
# Globals:
# MONGODB_*
# Arguments:
# None
# Returns:
# Series of exports to be used as 'eval' arguments
#########################
mongodb_sharded_env() {
cat <<"EOF"
# Paths
export MONGODB_MONGOS_TEMPLATES_FILE="$MONGODB_TEMPLATES_DIR/mongos.conf.tpl"
# Settings
export MONGODB_SHARDING_MODE="${MONGODB_SHARDING_MODE:-}"
export MONGODB_CFG_REPLICA_SET_NAME="${MONGODB_CFG_REPLICA_SET_NAME:-}"
export MONGODB_CFG_PRIMARY_HOST="${MONGODB_CFG_PRIMARY_HOST:-}"
export MONGODB_MONGOS_HOST="${MONGODB_MONGOS_HOST:-}"
export MONGODB_MONGOS_PORT_NUMBER="${MONGODB_MONGOS_PORT_NUMBER:-27017}"
export MONGODB_CFG_PRIMARY_PORT_NUMBER="${MONGODB_CFG_PRIMARY_PORT_NUMBER:-27017}"
EOF
}
########################
# Get current status of the shard in the cluster
# Globals:
# MONGODB_*
# Arguments:
# $1 - Name of the replica set
# Returns:
# None
#########################
mongodb_sharded_shard_currently_in_cluster() {
local -r replicaset="${1:?node is required}"
local result
result=$(mongodb_execute "$MONGODB_PRIMARY_ROOT_USER" "$MONGODB_PRIMARY_ROOT_PASSWORD" "admin" "$MONGODB_MONGOS_HOST" "$MONGODB_MONGOS_PORT_NUMBER" <<EOF
db.adminCommand({ listShards: 1 })
EOF
)
grep -q "id.*$replicaset" <<< "$result"
}
###############
# Initialize MongoDB (mongod) service with sharded configuration
# Globals:
# MONGODB_*
# Arguments:
# None
# Returns:
# None
#########################
mongodb_sharded_mongod_initialize() {
local persisted=false
info "Initializing MongoDB Sharded..."
mongodb_clean_from_restart
mongodb_copy_mounted_config
mongodb_ensure_mongod_config_exists
mongodb_set_permissions
mongodb_sharded_set_sharding_conf
if is_dir_empty "$MONGODB_DATA_DIR/db"; then
info "Deploying MongoDB Sharded from scratch..."
ensure_dir_exists "$MONGODB_DATA_DIR/db"
am_i_root && chown -R "$MONGODB_DAEMON_USER" "$MONGODB_DATA_DIR/db"
mongodb_start_bg
mongodb_create_users
mongodb_create_keyfile "$MONGODB_REPLICA_SET_KEY"
mongodb_set_keyfile_conf
mongodb_set_auth_conf
mongodb_set_replicasetmode_conf
mongodb_set_listen_all_conf
mongodb_sharded_configure_replica_set
mongodb_stop
else
persisted=true
mongodb_create_keyfile "$MONGODB_REPLICA_SET_KEY"
mongodb_set_keyfile_conf
mongodb_set_auth_conf
info "Deploying MongoDB Sharded with persisted data..."
if [[ "$MONGODB_REPLICA_SET_MODE" = "dynamic" ]]; then
mongodb_ensure_dynamic_mode_consistency
fi
mongodb_set_replicasetmode_conf
fi
if [[ "$MONGODB_SHARDING_MODE" = "shardsvr" ]] && [[ "$MONGODB_REPLICA_SET_MODE" = "primary" ]]; then
mongodb_wait_for_node "$MONGODB_MONGOS_HOST" "$MONGODB_MONGOS_PORT_NUMBER" "root" "$MONGODB_ROOT_PASSWORD"
if ! mongodb_sharded_shard_currently_in_cluster "$MONGODB_REPLICA_SET_NAME"; then
mongodb_sharded_join_shard_cluster
else
info "Shard already in cluster"
fi
fi
mongodb_sharded_print_properties $persisted
}
########################
# Print properties
# Globals:
# MONGODB_*
# Arguments:
# $1 - true if persited data
# Returns:
# None
#########################
mongodb_sharded_print_properties() {
local -r persisted=${1:?persisted is required}
mongodb_print_properties "$persisted"
info " Shard Mode: ${MONGODB_SHARDING_MODE}"
info "########################################################################"
}
########################
# Validate settings in MONGODB_* env. variables (sharded configuration)
# Globals:
# MONGODB_*
# Arguments:
# None
# Returns:
# None
#########################
mongodb_sharded_validate() {
local error_code=0
if ! (mongodb_validate); then
error_code=1
fi
# Auxiliary functions
print_validation_error() {
error "$1"
error_code=1
}
if [[ -z "$MONGODB_SHARDING_MODE" ]]; then
print_validation_error "You need to speficy one of the sharding modes: mongos, shardsvr or configsvr"
fi
if [[ "$MONGODB_SHARDING_MODE" = "mongos" ]] || { [[ "$MONGODB_SHARDING_MODE" = "shardsvr" ]] && [[ "$MONGODB_REPLICA_SET_MODE" = "primary" ]] ;}; then
if [[ -z "$MONGODB_ROOT_PASSWORD" ]]; then
print_validation_error "Missing root password for the Config Server. Set MONGODB_ROOT_PASSWORD"
fi
fi
if [[ "$MONGODB_SHARDING_MODE" =~ (shardsvr|configsvr) ]]; then
if [[ -z "$MONGODB_REPLICA_SET_MODE" ]]; then
print_validation_error "Sharding requires setting replica set mode. Set MONGODB_REPLICA_SET_MODE"
fi
fi
if [[ "$MONGODB_SHARDING_MODE" = "mongos" ]]; then
if [[ -z "$MONGODB_CFG_PRIMARY_HOST" ]]; then
print_validation_error "Missing primary host for the Config Server. Set MONGODB_CFG_PRIMARY_HOST"
fi
if [[ -z "$MONGODB_CFG_REPLICA_SET_NAME" ]]; then
print_validation_error "Missing replica set name for the Config Server. Set MONGODB_CFG_REPLICA_SET_NAME"
fi
if [[ -z "$MONGODB_REPLICA_SET_KEY" ]]; then
print_validation_error "Missing replica set key for the Config Server. Set MONGODB_REPLICA_SET_KEY"
fi
fi
if [[ "$MONGODB_SHARDING_MODE" = "shardsvr" ]] && [[ "$MONGODB_REPLICA_SET_MODE" = "primary" ]]; then
if [[ -z "$MONGODB_MONGOS_HOST" ]]; then
print_validation_error "Missing mongos host for registration. Set MONGODB_MONGOS_HOST"
fi
fi
if [[ "$MONGODB_SHARDING_MODE" = "configsvr" ]]; then
if [[ "$MONGODB_REPLICA_SET_MODE" = "arbiter" ]]; then
print_validation_error "Arbiters are not allowed in Config Server replicasets"
fi
fi
[[ "$error_code" -eq 0 ]] || exit "$error_code"
}
########################
# Enable Sharding in mongodb.conf
# Globals:
# MONGODB_*
# Arguments:
# None
# Returns:
# None
#########################
mongodb_sharded_set_sharding_conf() {
if ! mongodb_is_file_external "mongodb.conf"; then
mongodb_config_apply_regex "#?sharding:.*" "sharding:"
mongodb_config_apply_regex "#?clusterRole:.*" "clusterRole: $MONGODB_SHARDING_MODE"
else
debug "mongodb.conf mounted. Skipping sharding mode enabling"
fi
}
########################
# Join shard cluster
# Globals:
# MONGODB_*
# Arguments:
# None
# Returns:
# None
#########################
mongodb_sharded_join_shard_cluster() {
mongodb_start_bg
info "Joining the shard cluster"
if ! retry_while "mongodb_sharded_is_join_shard_pending $MONGODB_REPLICA_SET_NAME/$MONGODB_ADVERTISED_HOSTNAME:$MONGODB_PORT_NUMBER $MONGODB_MONGOS_HOST $MONGODB_MONGOS_PORT_NUMBER root $MONGODB_ROOT_PASSWORD" "$MONGODB_MAX_TIMEOUT"; then
error "Unable to join the sharded cluster"
exit 1
fi
mongodb_stop
}
########################
# Get if secondary node is pending
# Globals:
# MONGODB_*
# Arguments:
# $1 - node
# Returns:
# Boolean
#########################
mongodb_sharded_is_join_shard_pending() {
local -r shard_connection_string="${1:?shard connection string is required}"
local -r mongos_host="${2:?node is required}"
local -r mongos_port="${3:?port is required}"
local -r user="${4:?user is required}"
local -r password="${5:?password is required}"
local result
result=$(mongodb_execute "$user" "$password" "admin" "$mongos_host" "$mongos_port" <<EOF
sh.addShard("$shard_connection_string")
EOF
)
grep -q "\"ok\" : 1" <<< "$result"
}
########################
# Configure Replica Set
# Globals:
# MONGODB_*
# Arguments:
# None
# Returns:
# None
#########################
mongodb_sharded_configure_replica_set() {
local node
info "Configuring MongoDB Sharded replica set..."
node=$(get_mongo_hostname)
mongodb_set_replicasetmode_conf
mongodb_restart
case "$MONGODB_REPLICA_SET_MODE" in
"primary" )
if [[ "$MONGODB_SHARDING_MODE" = "configsvr" ]]; then
mongodb_sharded_configure_configsvr_primary "$node"
else
mongodb_configure_primary "$node"
fi
;;
"secondary")
mongodb_configure_secondary "$node"
;;
"arbiter")
mongodb_configure_arbiter "$node"
;;
"dynamic")
# Do nothing
;;
esac
if [[ "$MONGODB_REPLICA_SET_MODE" = "secondary" ]]; then
mongodb_wait_until_sync_complete
fi
}
########################
# Get if primary node is initialized
# Globals:
# MONGODB_*
# Arguments:
# $1 - node
# Returns:
# None
#########################
mongodb_sharded_is_configsvr_initiated() {
local -r node="${1:?node is required}"
local result
result=$(mongodb_execute "root" "$MONGODB_ROOT_PASSWORD" "admin" "$node" "$MONGODB_PORT_NUMBER" <<EOF
rs.initiate({"_id":"$MONGODB_REPLICA_SET_NAME", "configsvr": true, "members":[{"_id":0,"host":"$node:$MONGODB_PORT_NUMBER","priority":5}]})
EOF
)
grep -q "\"ok\" : 1" <<< "$result"
}
########################
# Configure primary node
# Globals:
# MONGODB_*
# Arguments:
# $1 - node
# Returns:
# None
#########################
mongodb_sharded_configure_configsvr_primary() {
local -r node="${1:?node is required}"
info "Configuring MongoDB primary node...: $node"
wait-for-port --timeout 360 "$MONGODB_PORT_NUMBER"
if ! retry_while "mongodb_sharded_is_configsvr_initiated $node" "$MONGODB_MAX_TIMEOUT"; then
error "Unable to initialize primary config server"
exit 1
fi
}
mongodb_sharded_mongos_initialize() {
info "Initializing Mongos..."
mongodb_clean_from_restart
mongodb_set_permissions
mongodb_sharded_ensure_mongos_config_exists
mongodb_create_keyfile "$MONGODB_REPLICA_SET_KEY"
mongodb_set_keyfile_conf
mongodb_wait_for_primary_node "$MONGODB_CFG_PRIMARY_HOST" "$MONGODB_CFG_PRIMARY_PORT_NUMBER" "root" "$MONGODB_ROOT_PASSWORD"
}
########################
# Create Mongos configuration (mongodb.conf) file
# Globals:
# MONGODB_*
# Arguments:
# None
# Returns:
# None
#########################
mongodb_sharded_ensure_mongos_config_exists() {
if [[ -f "$MONGODB_CONF_FILE" ]]; then
info "Custom configuration $MONGODB_CONF_FILE detected!"
else
info "No injected configuration files found. Creating default config files..."
mongodb_sharded_create_mongos_config
fi
}
########################
# Create Mongos configuration file
# Globals:
# MONGODB_*
# Arguments:
# None
# Returns:
# None
#########################
mongodb_sharded_create_mongos_config() {
debug "Creating main configuration file..."
render-template "$MONGODB_MONGOS_TEMPLATES_FILE" > "$MONGODB_CONF_FILE"
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,52 @@
# mongod.conf
# for documentation of all options, see:
# http://docs.mongodb.org/manual/reference/configuration-options/
# where and how to store data.
storage:
dbPath: {{MONGODB_DATA_DIR}}/db
journal:
enabled: true
directoryPerDB: {{MONGODB_ENABLE_DIRECTORY_PER_DB}}
# where to write logging data.
systemLog:
destination: file
quiet: {{MONGODB_DISABLE_SYSTEM_LOG}}
logAppend: true
logRotate: reopen
path: {{MONGODB_LOG_DIR}}/mongodb.log
verbosity: {{MONGODB_SYSTEM_LOG_VERBOSITY}}
# network interfaces
net:
port: {{MONGODB_PORT_NUMBER}}
unixDomainSocket:
enabled: true
pathPrefix: {{MONGODB_TMP_DIR}}
ipv6: {{MONGODB_ENABLE_IPV6}}
bindIpAll: false
bindIp: 127.0.0.1
# replica set options
#replication:
#replSetName: {{MONGODB_REPLICA_SET_NAME}}
#enableMajorityReadConcern: true
# sharding options
#sharding:
#clusterRole:
# process management options
processManagement:
fork: false
pidFilePath: {{MONGODB_PID_FILE}}
# set parameter options
setParameter:
enableLocalhostAuthBypass: true
# security options
security:
authorization: disabled
#keyFile: replace_me

View File

@@ -0,0 +1,38 @@
# mongod.conf
# for documentation of all options, see:
# http://docs.mongodb.org/manual/reference/configuration-options/
# where to write logging data.
systemLog:
destination: file
quiet: {{MONGODB_DISABLE_SYSTEM_LOG}}
logAppend: true
logRotate: reopen
path: {{MONGODB_LOG_DIR}}/mongodb.log
verbosity: {{MONGODB_SYSTEM_LOG_VERBOSITY}}
# network interfaces
net:
port: {{MONGODB_PORT_NUMBER}}
unixDomainSocket:
enabled: true
pathPrefix: {{MONGODB_TMP_DIR}}
ipv6: {{MONGODB_ENABLE_IPV6}}
bindIpAll: false
bindIp: 127.0.0.1
# sharding options
sharding:
configDB: {{MONGODB_CFG_REPLICA_SET_NAME}}/{{MONGODB_CFG_PRIMARY_HOST}}:{{MONGODB_PORT_NUMBER}}
security:
keyFile: {{MONGODB_KEY_FILE}}
# process management options
processManagement:
fork: false
pidFilePath: {{MONGODB_PID_FILE}}
# set parameter options
setParameter:
enableLocalhostAuthBypass: false

View File

@@ -0,0 +1,24 @@
#!/bin/bash
# shellcheck disable=SC1091
# Load libraries
. /libfs.sh
. /liblog.sh
. /libmongodb.sh
. /libmongodb-sharded.sh
# Load MongoDB env. variables
eval "$(mongodb_env)"
eval "$(mongodb_sharded_env)"
for dir in "$MONGODB_TMP_DIR" "$MONGODB_LOG_DIR" "$MONGODB_CONF_DIR" "$MONGODB_DATA_DIR" "$MONGODB_VOLUME_DIR"; do
ensure_dir_exists "$dir"
done
chmod -R g+rwX "$MONGODB_TMP_DIR" "$MONGODB_LOG_DIR" "$MONGODB_CONF_DIR" "$MONGODB_DATA_DIR" "$MONGODB_VOLUME_DIR"
# Create .dbshell file to avoid error message
touch /.dbshell /.mongorc.js && chmod g+rw /.dbshell /.mongorc.js
# Redirect all logging to stdout
ln -sf /dev/stdout "$MONGODB_LOG_FILE"

View File

@@ -0,0 +1,34 @@
#!/bin/bash
# shellcheck disable=SC1091
set -o errexit
set -o nounset
set -o pipefail
. /libmongodb.sh
. /libmongodb-sharded.sh
. /libos.sh
# Load MongoDB env. variables
eval "$(mongodb_env)"
eval "$(mongodb_sharded_env)"
if [[ "$MONGODB_SHARDING_MODE" = "mongos" ]]; then
cmd=$(command -v mongos)
else
cmd=$(command -v mongod)
fi
flags=("--config=$MONGODB_CONF_FILE")
if [[ -n "${MONGODB_EXTRA_FLAGS:-}" ]]; then
read -r -a extra_flags <<< "$MONGODB_EXTRA_FLAGS"
flags+=("${extra_flags[@]}")
fi
info "** Starting MongoDB **"
if am_i_root; then
exec gosu "$MONGODB_DAEMON_USER" "${cmd}" "${flags[@]}"
else
exec "${cmd}" "${flags[@]}"
fi

View File

@@ -0,0 +1,39 @@
#!/bin/bash
# shellcheck disable=SC1091
set -o errexit
set -o nounset
set -o pipefail
# Load libraries
. /libfs.sh
. /libos.sh
. /libmongodb.sh
. /libmongodb-sharded.sh
# Load MongoDB env. variables
eval "$(mongodb_env)"
eval "$(mongodb_sharded_env)"
is_boolean_yes "$MONGODB_DISABLE_SYSTEM_LOG" && MONGODB_DISABLE_SYSTEM_LOG="true" || MONGODB_DISABLE_SYSTEM_LOG="false"
is_boolean_yes "$MONGODB_ENABLE_DIRECTORY_PER_DB" && MONGODB_ENABLE_DIRECTORY_PER_DB="true" || MONGODB_ENABLE_DIRECTORY_PER_DB="false"
is_boolean_yes "$MONGODB_ENABLE_IPV6" && MONGODB_ENABLE_IPV6="true" || MONGODB_ENABLE_IPV6="false"
# Ensure MongoDB env var settings are valid
mongodb_sharded_validate
# Ensure MongoDB is stopped when this script ends.
trap "mongodb_stop" EXIT
# Ensure 'daemon' user exists when running as 'root'
am_i_root && ensure_user_exists "$MONGODB_DAEMON_USER" "$MONGODB_DAEMON_GROUP"
# Ensure MongoDB is initialized
if [[ "$MONGODB_SHARDING_MODE" = "mongos" ]]; then
mongodb_sharded_mongos_initialize
else
mongodb_sharded_mongod_initialize
fi
mongodb_set_listen_all_conf
# Allow running custom initialization scripts
mongodb_custom_init_scripts

View File

@@ -0,0 +1,153 @@
version: '2'
services:
mongodb-sharded:
image: 'bitnami/mongodb-sharded:4.2'
environment:
- MONGODB_ADVERTISED_HOSTNAME=mongodb-sharded
- MONGODB_SHARDING_MODE=mongos
- MONGODB_CFG_PRIMARY_HOST=mongodb-cfg-primary
- MONGODB_CFG_REPLICA_SET_NAME=cfgreplicaset
- MONGODB_REPLICA_SET_KEY=replicasetkey123
- MONGODB_ROOT_PASSWORD=password123
ports:
- "27017:27017"
mongodb-sharded-2:
image: 'bitnami/mongodb-sharded:4.2'
environment:
- MONGODB_ADVERTISED_HOSTNAME=mongodb-sharded-2
- MONGODB_SHARDING_MODE=mongos
- MONGODB_CFG_PRIMARY_HOST=mongodb-cfg-primary
- MONGODB_CFG_REPLICA_SET_NAME=cfgreplicaset
- MONGODB_REPLICA_SET_KEY=replicasetkey123
- MONGODB_ROOT_PASSWORD=password123
mongodb-shard0-primary:
image: 'bitnami/mongodb-sharded:4.2'
environment:
- MONGODB_ADVERTISED_HOSTNAME=mongodb-shard0-primary
- MONGODB_SHARDING_MODE=shardsvr
- MONGODB_MONGOS_HOST=mongodb-sharded
- MONGODB_ROOT_PASSWORD=password123
- MONGODB_REPLICA_SET_MODE=primary
- MONGODB_REPLICA_SET_KEY=replicasetkey123
- MONGODB_REPLICA_SET_NAME=shard0
volumes:
- 'shard0_data:/bitnami'
mongodb-shard0-secondary:
image: 'bitnami/mongodb-sharded:4.2'
depends_on:
- mongodb-shard0-primary
environment:
- MONGODB_ADVERTISED_HOSTNAME=mongodb-shard0-secondary
- MONGODB_REPLICA_SET_MODE=secondary
- MONGODB_PRIMARY_HOST=mongodb-shard0-primary
- MONGODB_PRIMARY_ROOT_PASSWORD=password123
- MONGODB_REPLICA_SET_KEY=replicasetkey123
- MONGODB_SHARDING_MODE=shardsvr
- MONGODB_REPLICA_SET_NAME=shard0
volumes:
- 'shard0_sec_data:/bitnami'
mongodb-shard1-primary:
image: 'bitnami/mongodb-sharded:4.2'
environment:
- MONGODB_ADVERTISED_HOSTNAME=mongodb-shard1-primary
- MONGODB_SHARDING_MODE=shardsvr
- MONGODB_MONGOS_HOST=mongodb-sharded
- MONGODB_ROOT_PASSWORD=password123
- MONGODB_REPLICA_SET_MODE=primary
- MONGODB_REPLICA_SET_KEY=replicasetkey123
- MONGODB_REPLICA_SET_NAME=shard1
volumes:
- 'shard1_data:/bitnami'
mongodb-shard1-secondary:
image: 'bitnami/mongodb-sharded:4.2'
depends_on:
- mongodb-shard1-primary
environment:
- MONGODB_ADVERTISED_HOSTNAME=mongodb-shard1-secondary
- MONGODB_REPLICA_SET_MODE=secondary
- MONGODB_PRIMARY_HOST=mongodb-shard1-primary
- MONGODB_PRIMARY_ROOT_PASSWORD=password123
- MONGODB_REPLICA_SET_KEY=replicasetkey123
- MONGODB_SHARDING_MODE=shardsvr
- MONGODB_REPLICA_SET_NAME=shard1
volumes:
- 'shard1_sec_data:/bitnami'
mongodb-shard2-primary:
image: 'bitnami/mongodb-sharded:4.2'
environment:
- MONGODB_ADVERTISED_HOSTNAME=mongodb-shard2-primary
- MONGODB_SHARDING_MODE=shardsvr
- MONGODB_MONGOS_HOST=mongodb-sharded
- MONGODB_ROOT_PASSWORD=password123
- MONGODB_REPLICA_SET_MODE=primary
- MONGODB_REPLICA_SET_KEY=replicasetkey123
- MONGODB_REPLICA_SET_NAME=shard2
volumes:
- 'shard2_data:/bitnami'
mongodb-shard2-secondary:
image: 'bitnami/mongodb-sharded:4.2'
depends_on:
- mongodb-shard2-primary
environment:
- MONGODB_ADVERTISED_HOSTNAME=mongodb-shard2-secondary
- MONGODB_REPLICA_SET_MODE=secondary
- MONGODB_PRIMARY_HOST=mongodb-shard2-primary
- MONGODB_PRIMARY_ROOT_PASSWORD=password123
- MONGODB_REPLICA_SET_KEY=replicasetkey123
- MONGODB_SHARDING_MODE=shardsvr
- MONGODB_REPLICA_SET_NAME=shard2
volumes:
- 'shard2_sec_data:/bitnami'
mongodb-cfg-primary:
image: 'bitnami/mongodb-sharded:4.2'
environment:
- MONGODB_ADVERTISED_HOSTNAME=mongodb-cfg-primary
- MONGODB_SHARDING_MODE=configsvr
- MONGODB_ROOT_PASSWORD=password123
- MONGODB_REPLICA_SET_MODE=primary
- MONGODB_REPLICA_SET_KEY=replicasetkey123
- MONGODB_REPLICA_SET_NAME=cfgreplicaset
volumes:
- 'cfg_data:/bitnami'
mongodb-cfg-secondary:
image: 'bitnami/mongodb-sharded:4.2'
depends_on:
- mongodb-cfg-primary
environment:
- MONGODB_ADVERTISED_HOSTNAME=mongodb-cfg-secondary
- MONGODB_REPLICA_SET_MODE=secondary
- MONGODB_PRIMARY_HOST=mongodb-cfg-primary
- MONGODB_PRIMARY_ROOT_PASSWORD=password123
- MONGODB_REPLICA_SET_KEY=replicasetkey123
- MONGODB_REPLICA_SET_NAME=cfgreplicaset
- MONGODB_SHARDING_MODE=configsvr
volumes:
- 'cfg_sec_data:/bitnami'
volumes:
shard0_data:
driver: local
shard0_sec_data:
driver: local
shard1_data:
driver: local
shard1_sec_data:
driver: local
shard2_data:
driver: local
shard2_sec_data:
driver: local
cfg_data:
driver: local
cfg_sec_data:
driver: local

View File

@@ -0,0 +1,45 @@
version: '2'
services:
mongodb-sharded:
image: 'bitnami/mongodb-sharded:4.0'
environment:
- MONGODB_ADVERTISED_HOSTNAME=mongodb-sharded
- MONGODB_SHARDING_MODE=mongos
- MONGODB_CFG_PRIMARY_HOST=mongodb-cfg
- MONGODB_CFG_REPLICA_SET_NAME=cfgreplicaset
- MONGODB_REPLICA_SET_KEY=replicasetkey123
- MONGODB_ROOT_PASSWORD=password123
ports:
- "27017:27017"
mongodb-shard0:
image: 'bitnami/mongodb-sharded:4.0'
environment:
- MONGODB_ADVERTISED_HOSTNAME=mongodb-shard0
- MONGODB_SHARDING_MODE=shardsvr
- MONGODB_MONGOS_HOST=mongodb-sharded
- MONGODB_ROOT_PASSWORD=password123
- MONGODB_REPLICA_SET_MODE=primary
- MONGODB_REPLICA_SET_KEY=replicasetkey123
- MONGODB_REPLICA_SET_NAME=shard0
volumes:
- 'shard0_data:/bitnami'
mongodb-cfg:
image: 'bitnami/mongodb-sharded:4.0'
environment:
- MONGODB_ADVERTISED_HOSTNAME=mongodb-cfg
- MONGODB_SHARDING_MODE=configsvr
- MONGODB_ROOT_PASSWORD=password123
- MONGODB_REPLICA_SET_MODE=primary
- MONGODB_REPLICA_SET_KEY=replicasetkey123
- MONGODB_REPLICA_SET_NAME=cfgreplicaset
volumes:
- 'cfg_data:/bitnami'
volumes:
shard0_data:
driver: local
cfg_data:
driver: local