Adjust resource for MongoDB Stateful Set

- Currently, MongoDB container crashed because of resource constaints i.e.
out of memory exception. This change updates the resources and provides
data on how the configure/calculate them(if not following the guide).
- Also, add the ability to specify the storage engine(WiredTiger) cache
size for MongoDB, this configuration also helps with keeping the resources
constrained for MongoDB containers.
- Minor changes in some other documents as well.
This commit is contained in:
muawiakh 2017-09-25 16:44:39 +02:00
parent 43d8beed99
commit 7abdca205a
6 changed files with 41 additions and 6 deletions

View File

@ -92,7 +92,7 @@ consolidated file containing both the public and private keys.
.. code:: bash
cat /path/to/mdb-instance-0.crt /path/to/mdb-instance-0.key > mdb-instance-0.pem
cat /path/to/bdb-instance-0.crt /path/to/bdb-instance-0.key > bdb-instance-0.pem
OR

View File

@ -542,6 +542,19 @@ Step 12: Start a Kubernetes StatefulSet for MongoDB
- ``mdb-certs``
- ``ca-auth``
* **Optional**: You can also change the value for ``STORAGE_ENGINE_CACHE_SIZE``, for more information
regarding this configuration, please consult the `MongoDB Official
Documentation <https://docs.mongodb.com/manual/reference/configuration-options/#storage.wiredTiger.engineConfig.cacheSizeGB>`_.
* **Optional**: If you are not using the **Standard_D2_v2** virtual machines for Kubernetes agents as per the guide,
please update the ``resources`` for ``mongo-ss``. We suggest allocating ``memory`` using the following scheme
for a MongoDB StatefulSet:
.. code:: bash
memory = (Total_Memory_Agent_VM_GB - 2GB)
STORAGE_ENGINE_CACHE_SIZE = memory / 2
* Create the MongoDB StatefulSet using:
.. code:: bash

View File

@ -1,5 +1,5 @@
#!/bin/bash
docker build -t bigchaindb/mongodb:3.1 .
docker build -t bigchaindb/mongodb:3.2 .
docker push bigchaindb/mongodb:3.1
docker push bigchaindb/mongodb:3.2

View File

@ -86,6 +86,7 @@ storage:
wiredTiger:
engineConfig:
journalCompressor: snappy
configString: cache_size=STORAGE_ENGINE_CACHE_SIZE
collectionConfig:
blockCompressor: snappy
indexConfig:
@ -98,4 +99,3 @@ operationProfiling:
replication:
replSetName: REPLICA_SET_NAME
enableMajorityReadConcern: true

View File

@ -46,6 +46,10 @@ while [[ $# -gt 1 ]]; do
MONGODB_IP="$2"
shift
;;
--storage-engine-cache-size)
STORAGE_ENGINE_CACHE_SIZE="$2"
shift
;;
*)
echo "Unknown option: $1"
exit 1
@ -61,7 +65,8 @@ if [[ -z "${REPLICA_SET_NAME:?REPLICA_SET_NAME not specified. Exiting!}" || \
-z "${MONGODB_IP:?MONGODB_IP not specified. Exiting!}" || \
-z "${MONGODB_KEY_FILE_PATH:?MONGODB_KEY_FILE_PATH not specified. Exiting!}" || \
-z "${MONGODB_CA_FILE_PATH:?MONGODB_CA_FILE_PATH not specified. Exiting!}" || \
-z "${MONGODB_CRL_FILE_PATH:?MONGODB_CRL_FILE_PATH not specified. Exiting!}" ]] ; then
-z "${MONGODB_CRL_FILE_PATH:?MONGODB_CRL_FILE_PATH not specified. Exiting!}" ||
-z "${STORAGE_ENGINE_CACHE_SIZE:=''}" ]] ; then
#-z "${MONGODB_KEY_FILE_PASSWORD:?MongoDB Key File Password not specified. Exiting!}" || \
exit 1
else
@ -72,6 +77,7 @@ else
echo MONGODB_KEY_FILE_PATH="$MONGODB_KEY_FILE_PATH"
echo MONGODB_CA_FILE_PATH="$MONGODB_CA_FILE_PATH"
echo MONGODB_CRL_FILE_PATH="$MONGODB_CRL_FILE_PATH"
echo STORAGE_ENGINE_CACHE_SIZE="$STORAGE_ENGINE_CACHE_SIZE"
fi
MONGODB_CONF_FILE_PATH=/etc/mongod.conf
@ -84,6 +90,16 @@ sed -i "s|MONGODB_KEY_FILE_PATH|${MONGODB_KEY_FILE_PATH}|g" ${MONGODB_CONF_FILE_
sed -i "s|MONGODB_CA_FILE_PATH|${MONGODB_CA_FILE_PATH}|g" ${MONGODB_CONF_FILE_PATH}
sed -i "s|MONGODB_CRL_FILE_PATH|${MONGODB_CRL_FILE_PATH}|g" ${MONGODB_CONF_FILE_PATH}
sed -i "s|REPLICA_SET_NAME|${REPLICA_SET_NAME}|g" ${MONGODB_CONF_FILE_PATH}
if [ ! -z "$STORAGE_ENGINE_CACHE_SIZE" ]; then
if [[ "$STORAGE_ENGINE_CACHE_SIZE" =~ ^[0-9]+\.?(G|M|T)B$ ]]; then
sed -i.bk "s|STORAGE_ENGINE_CACHE_SIZE|${STORAGE_ENGINE_CACHE_SIZE}|g" ${MONGODB_CONF_FILE_PATH}
else
echo "Invalid Value for storage engine cache size $STORAGE_ENGINE_CACHE_SIZE"
exit 1
fi
else
sed -i.bk "/cacheSizeGB/d" ${MONGODB_CONF_FILE_PATH}
fi
# add the hostname and ip to hosts file
echo "${MONGODB_IP} ${MONGODB_FQDN}" >> $HOSTS_FILE_PATH

View File

@ -43,6 +43,10 @@ spec:
configMapKeyRef:
name: vars
key: mongodb-backend-port
# Optional: Optimize storage engine(wired tiger)
# cache size. e.g. (2048MB, 2GB, 1TB)
- name: STORAGE_ENGINE_CACHE_SIZE
value: ""
args:
- --mongodb-port
- $(MONGODB_PORT)
@ -58,6 +62,8 @@ spec:
- $(MONGODB_FQDN)
- --mongodb-ip
- $(MONGODB_POD_IP)
- --storage-engine-cache-size
- $(STORAGE_ENGINE_CACHE_SIZE)
securityContext:
capabilities:
add:
@ -80,7 +86,7 @@ spec:
resources:
limits:
cpu: 200m
memory: 3.5G
memory: 5G
livenessProbe:
tcpSocket:
port: mdb-api-port