- About MogDB Stack
- Quick Start
- Installation
- Tutorial
- Architecture
- References
- Client
- mgo
- mgo create
- mgo create mgorole
- mgo create mgouser
- mgo create cluster
- mgo show
- mgo show k8s
- mgo show mgorole
- mgo show mgouser
- mgo show cluster
- mgo show restore
- mgo delete
- mgo delete mgorole
- mgo delete mgouser
- mgo delete cluster
- mgo delete backup
- mgo delete k8s
- mgo scale
- mgo scaledown
- mgo switch
- mgo update
- mgo update mgorole
- mgo update mgouser
- mgo update cluster
- mgo version
- mgo addk8s
- mgo localk8s
- mgo backup
- mgo backup detail
- mgo restore
- mgo minio
- mgo minio object
- mgo minio object ls
- mgo minio object stat
- mgo minio object getf
- Server
- Client
- FAQ
- Release Note
Customize a MogDB Cluster
There are two methods of creating a MogDB cluster, including mgo (MogDB Operator) client and manifest. You can choose one on demand.
You are recommended to use the mgo client to create a cluster. The following mainly describes the mgo method.
Customize a MogDB cluster
- MogDB version
- MogDB configuration
- High availability (for example, customize standby nodes)
- Resource allocation, including memory, calculating, and storage resources
mgo Client
There are many different configurations for customizing MogDB clusters. You can refer to [mgo create cluster](. /references/client/mgo-create-cluster.md) to learn about all these options.
1. Customize Storage
MogDB defines three types of storage directories for configurations.
Data directory: stores all data.
Backup directory: stores backup data.
Log directory: stores logs.
Databases come in a variety of sizes, and those sizes are sure to change over time. Therefore, it is helpful to be able to specify the size of the PVC in which the MogDB data is to be stored.
Customizing the Data Directory for the MogDB Database
mgo allows you to choose the size of the "MogDB data directory" using the --data-storage-size
flag. the PVC size should be chosen by the standard Kubernetes resource unit, eg. 128Mi.
For example, create a MogDB cluster with the data directory of 128 Mi.
mgo create cluster cluster1 --data-storage-size=20Gi
Customizing the Backup Directory for the MogDB Database
mgo allows you to choose the size of the "MogDB backup directory" using the --backup-storage-size
flag. It is used to store all your backups, so you are supposed to resize it to meet your backup retention policy.
For example, create a MogDB cluster with the backup directory of 1 Gi.
mgo create cluster cluster1 --backup-storage-size=1Gi
Customizing the Log Directory for the MogDB Database
mgo allows you to choose the size of the "MogDB log directory" using the --log-storage-size
flag. Therefore, you are supposed to adjust its size to meet your log retention policy.
For example, create a MogDB cluster with the log directory of 1 Gi.
mgo create cluster cluster1 --log-storage-size=1Gi
2. Customize CPU/Memory
Databases have different CPU and memory requirements, often depending on the amount of data (i.e., actively accessed data) in the working set. kubernetes provides several ways for Pods to manage CPU and memory resources.
- Limits: specifies the upper limit for resources a pod can use.
- Requests: specifies the lower limit for resources a pod can use, which may affects pod scheduling.
Typically, the size of resources used by pods is between requests and limits.
Note: If the memory size used by pods exceeds limits, kubernetes will terminate any process that causes the limit to be exceeded. Therefore, memory limit may influence MogDB availability. You are advised to use it with caution.
The following introduces how to customize the CPU and memory resources available to your MogDB cluster. Customizing CPU and memory does add more resources to your MogDB cluster, but the additional resources should be taken full use. You also need to customize the MogDB configuration and adjust parameters such as shared_buffers
.
Customizing CPU/Memory for MogDB
mgo provides several flags to help manage the resources of the MogDB instance.
- --cpu: specifies the CPU requests for the MogDB instance.
- --cpu-limit: specifies the CPU limit for the MogDB instance.
- --memory: specifies the memory request for the MogDB instance.
- --memory-limit: specifies the memory limit for the MogDB instance.
For example, create a MogDB cluster with a CPU request of 1.0, a CPU limit of 2.0, a memory request of 1Gi, and a memory limit of 2Gi.
mgo create cluster cluster1 \
--cpu=1.0 --cpu-limit=2.0 \
--memory=1Gi --memory-limit=2Gi
3. Create a High Availability MogDB Cluster
High availability allows you to deploy MogDB clusters with redundancy so that your applications can access them even if your primary instance experiences a downtime event. MogDB clusters use the distributed consensus storage system that comes with Kubernetes, so availability is tied to the availability of the Kubernetes cluster.
To create a high availability MogDB cluster with a standby node, you can run the following command.
mgo create cluster cluster1 --replicas=2
You can use mgo scale and mgo scaledown command to scale up or down MogDB clusters.
manifest
You can customize a cluster by referring to CRD References and manifest demo. You can modify the manifest fields based on the CRD field description. In this way can you realize customization of a MogDB cluster.