mirror of
https://github.com/bigchaindb/bigchaindb.git
synced 2024-10-13 13:34:05 +00:00
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:
parent
43d8beed99
commit
7abdca205a
@ -92,7 +92,7 @@ consolidated file containing both the public and private keys.
|
|||||||
|
|
||||||
.. code:: bash
|
.. 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
|
OR
|
||||||
|
|
||||||
|
@ -542,6 +542,19 @@ Step 12: Start a Kubernetes StatefulSet for MongoDB
|
|||||||
- ``mdb-certs``
|
- ``mdb-certs``
|
||||||
- ``ca-auth``
|
- ``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:
|
* Create the MongoDB StatefulSet using:
|
||||||
|
|
||||||
.. code:: bash
|
.. code:: bash
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#!/bin/bash
|
#!/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
|
||||||
|
@ -86,6 +86,7 @@ storage:
|
|||||||
wiredTiger:
|
wiredTiger:
|
||||||
engineConfig:
|
engineConfig:
|
||||||
journalCompressor: snappy
|
journalCompressor: snappy
|
||||||
|
configString: cache_size=STORAGE_ENGINE_CACHE_SIZE
|
||||||
collectionConfig:
|
collectionConfig:
|
||||||
blockCompressor: snappy
|
blockCompressor: snappy
|
||||||
indexConfig:
|
indexConfig:
|
||||||
@ -98,4 +99,3 @@ operationProfiling:
|
|||||||
replication:
|
replication:
|
||||||
replSetName: REPLICA_SET_NAME
|
replSetName: REPLICA_SET_NAME
|
||||||
enableMajorityReadConcern: true
|
enableMajorityReadConcern: true
|
||||||
|
|
||||||
|
@ -46,6 +46,10 @@ while [[ $# -gt 1 ]]; do
|
|||||||
MONGODB_IP="$2"
|
MONGODB_IP="$2"
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
|
--storage-engine-cache-size)
|
||||||
|
STORAGE_ENGINE_CACHE_SIZE="$2"
|
||||||
|
shift
|
||||||
|
;;
|
||||||
*)
|
*)
|
||||||
echo "Unknown option: $1"
|
echo "Unknown option: $1"
|
||||||
exit 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_IP:?MONGODB_IP not specified. Exiting!}" || \
|
||||||
-z "${MONGODB_KEY_FILE_PATH:?MONGODB_KEY_FILE_PATH 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_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!}" || \
|
#-z "${MONGODB_KEY_FILE_PASSWORD:?MongoDB Key File Password not specified. Exiting!}" || \
|
||||||
exit 1
|
exit 1
|
||||||
else
|
else
|
||||||
@ -72,6 +77,7 @@ else
|
|||||||
echo MONGODB_KEY_FILE_PATH="$MONGODB_KEY_FILE_PATH"
|
echo MONGODB_KEY_FILE_PATH="$MONGODB_KEY_FILE_PATH"
|
||||||
echo MONGODB_CA_FILE_PATH="$MONGODB_CA_FILE_PATH"
|
echo MONGODB_CA_FILE_PATH="$MONGODB_CA_FILE_PATH"
|
||||||
echo MONGODB_CRL_FILE_PATH="$MONGODB_CRL_FILE_PATH"
|
echo MONGODB_CRL_FILE_PATH="$MONGODB_CRL_FILE_PATH"
|
||||||
|
echo STORAGE_ENGINE_CACHE_SIZE="$STORAGE_ENGINE_CACHE_SIZE"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
MONGODB_CONF_FILE_PATH=/etc/mongod.conf
|
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_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|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}
|
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
|
# add the hostname and ip to hosts file
|
||||||
echo "${MONGODB_IP} ${MONGODB_FQDN}" >> $HOSTS_FILE_PATH
|
echo "${MONGODB_IP} ${MONGODB_FQDN}" >> $HOSTS_FILE_PATH
|
||||||
|
@ -43,6 +43,10 @@ spec:
|
|||||||
configMapKeyRef:
|
configMapKeyRef:
|
||||||
name: vars
|
name: vars
|
||||||
key: mongodb-backend-port
|
key: mongodb-backend-port
|
||||||
|
# Optional: Optimize storage engine(wired tiger)
|
||||||
|
# cache size. e.g. (2048MB, 2GB, 1TB)
|
||||||
|
- name: STORAGE_ENGINE_CACHE_SIZE
|
||||||
|
value: ""
|
||||||
args:
|
args:
|
||||||
- --mongodb-port
|
- --mongodb-port
|
||||||
- $(MONGODB_PORT)
|
- $(MONGODB_PORT)
|
||||||
@ -58,6 +62,8 @@ spec:
|
|||||||
- $(MONGODB_FQDN)
|
- $(MONGODB_FQDN)
|
||||||
- --mongodb-ip
|
- --mongodb-ip
|
||||||
- $(MONGODB_POD_IP)
|
- $(MONGODB_POD_IP)
|
||||||
|
- --storage-engine-cache-size
|
||||||
|
- $(STORAGE_ENGINE_CACHE_SIZE)
|
||||||
securityContext:
|
securityContext:
|
||||||
capabilities:
|
capabilities:
|
||||||
add:
|
add:
|
||||||
@ -80,7 +86,7 @@ spec:
|
|||||||
resources:
|
resources:
|
||||||
limits:
|
limits:
|
||||||
cpu: 200m
|
cpu: 200m
|
||||||
memory: 3.5G
|
memory: 5G
|
||||||
livenessProbe:
|
livenessProbe:
|
||||||
tcpSocket:
|
tcpSocket:
|
||||||
port: mdb-api-port
|
port: mdb-api-port
|
||||||
|
Loading…
x
Reference in New Issue
Block a user