After you install the MongoDB service on Cloud Pak for Data, you must deploy a database instance. You can use
the MongoDB
OpenShift® command-line interface to deploy
the database by creating a custom resource.
Procedure
- Set the following environment variables:
- Set the MGDB_INSTANCE_NAME environment variable to the name that you
want to use for this database instance.
export MGDB_INSTANCE_NAME=<name>
- Set the MGDB_VERSION environment variable to the version of the
database to deploy.
export MGDB_VERSION=<version>
Use the following table to determine the appropriate value:
| Cloud Pak for Data version |
Service instance versions (Pick one)
|
| 5.0.3 |
6.0.16-ent,
7.0.12-ent |
| 5.0.2 |
6.0.15-ent,
7.0.11-ent |
| 5.0.1 |
6.0.15-ent,
7.0.11-ent |
| 5.0.0 |
5.0.23-ent,
6.0.12-ent |
- Set the OPS_MANAGER_INSTANCE_NAME environment variable to the MongoDB
Ops Manager instance deployed in the
project.
export OPS_MANAGER_INSTANCE_NAME=<name>
- Set the STG_CLASS_BLOCK environment variable to the block storage
class you want to use for this database instance.
export STG_CLASS_BLOCK=<storage>
- Run the following command to deploy your database:
cat <<EOF | oc apply -f -
apiVersion: mongodb.cpd.ibm.com/v1
kind: CPDMongoDB
metadata:
name: ${MGDB_INSTANCE_NAME}
namespace: ${PROJECT_CPD_INST_OPERANDS}
spec:
forceDeleteResource: false
license:
accept: true
version: "${MGDB_VERSION}"
opsManager: ${OPS_MANAGER_INSTANCE_NAME}
replicas: 1
storageSize: "2G"
storageClass: ${STG_CLASS_BLOCK}
resources:
requests:
memory: 4Gi
cpu: 1
limits:
memory: 4Gi
cpu: 1
EOF
Tip: To automatically remove Persistent Volume Claims (PVCs) and secrets when you delete
an instance, set the forceDeleteResources key under the spec key
to true.
What to do next
MongoDB is ready to use. To get started with MongoDB, see Administering the MongoDB service and Working with MongoDB databases.