- 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
MogDB Stack Installation
Step 1: Install MogDB Operator
The process of deploying MogDB Operator is divided into two steps.
-
Install MogDB Operator CRD
-
Install MogDB Operator
Install MogDB Operator CRD
MogDB Operator includes many Custom Resource Define (CRD). Execute the following command to install CRDs into a Kubernetes cluster.
kubectl apply -f https://raw.githubusercontent.com/enmotech/mogdb-stack-examples/main/helm/crd.yamlExpected output:
customresourcedefinition.apiextensions.k8s.io/mogdbclusters.mogdb.enmotech.io created
customresourcedefinition.apiextensions.k8s.io/mogdbbackups.mogdb.enmotech.io createdInstall MogDB Operator
Install Helm 3 and deploy MogDB Operator with Helm 3
-
Add MogDB Stack repository
helm repo add mogdb-stack https://enmotech.github.io/mogdb-stack-examples/helm/chartsExpected output:
"mogdb-stack" has been added to your repositorieshelm search repo mogdb-stackExpected output:
NAME CHART VERSION APP VERSION DESCRIPTION mogdb-stack/mogdb-apiserver 2.0.0 2.0.0 A Helm chart for Kubernetes mogdb-stack/mogdb-cluster 2.0.0 2.0.0 A Helm chart for Kubernetes mogdb-stack/mogdb-monitor 2.0.0 2.0.0 A Helm chart for Kubernetes mogdb-stack/mogdb-operator 2.0.0 2.0.0 A Helm chart for Kubernetes mogdb-stack/mogha 2.0.0 2.0.0 A Helm chart for KubernetesThe repository contains five chart packages, which are mogdb-operator, mogdb-apiserver, mogha, mogdb-monitor and mogdb-cluster.
-
Create a namespace for the MogDB Operator
kubectl create namespace mogdb-operator-systemExpected output:
namespace/mogdb-operator-system created -
Install MogDB Operator
helm install myproject mogdb-stack/mogdb-operator --namespace mogdb-operator-systemExpected output:
NAME: myproject LAST DEPLOYED: Tue Jan 10 17:33:05 2023 NAMESPACE: mogdb-operator-system STATUS: deployed REVISION: 1 TEST SUITE: None NOTES: Thank you for deploying a MogDB Operator!
Check if the MogDB Operator component is running properly.
kubectl get pods -n mogdb-operator-systemExpected output:
NAME READY STATUS RESTARTS AGE
mogdb-operator-myproject-5cd5bb9d9-7xztz 1/1 Running 0 73sWhen the Pod is in Running state, continue to the next step.
Step 2: Install MogDB apiserver
helm install myapiserver mogdb-stack/mogdb-apiserver --namespace mogdb-operator-systemExpected output:
NAME: myapiserver
LAST DEPLOYED: Tue Jan 10 17:43:50 2023
NAMESPACE: mogdb-operator-system
STATUS: deployed
REVISION: 1
TEST SUITE: None
NOTES:
Thank you for deploying a MogDB Operator Apiserver!Check if the MogDB apiserver is running properly.
NAME READY STATUS RESTARTS AGE
mogdb-apiserver-699c855d9b-878qj 1/1 Running 0 72s
mogdb-operator-myproject-5cd5bb9d9-7xztz 1/1 Running 0 11mWhen the Pod is in Running state, continue to the next step.
Step 3: Install the mgo Client
wget https://cdn-mogdb.enmotech.com/mogdb-stack/v2.0.0/client-setup.sh
chmod +x client-setup.sh
./client-setup.shThis will download the mgo client and prompt you to add some environment variables for you to set in your session, which you can do with the following command.
export MGOUSER="${HOME?}/.mgo/mgouser"
export MGO_CA_CERT="${HOME?}/.mgo/client.crt"
export MGO_CLIENT_CERT="${HOME?}/.mgo/client.crt"
export MGO_CLIENT_KEY="${HOME?}/.mgo/client.key"
export MGO_APISERVER_URL='https://127.0.0.1:32444'
export MGO_NAMESPACE=mogdb-operator-systemIf you wish to permanently add these variables to your environment, you can run the following command.
cat <<EOF >> ~/.bashrc
export PATH="${HOME?}/.mgo:$PATH"
export MGOUSER="${HOME?}/.mgo/mgouser"
export MGO_CA_CERT="${HOME?}/.mgo/client.crt"
export MGO_CLIENT_CERT="${HOME?}/.mgo/client.crt"
export MGO_CLIENT_KEY="${HOME?}/.mgo/client.key"
export MGO_APISERVER_URL='https://127.0.0.1:32444'
export MGO_NAMESPACE=mogdb-operator-system
EOF
source ~/.bashrcNote: For macOS users, you use the file ~/.bash_profile instead of ~/.bashrc.
Step 4: Install MogHA
-
Create a namespace for MogHA
kubectl create namespace moghaExpected output:
namespace/mogha created -
Install MogHA
helm install mogdb-ha mogdb-stack/mogha --namespace moghaExpected output:
NAME: mogdb-ha LAST DEPLOYED: Tue Jan 10 17:40:51 2023 NAMESPACE: mogha STATUS: deployed REVISION: 1 TEST SUITE: None NOTES: Thank you for deploying a Mogha!
Check that the Mogha component is running properly.
kubectl get pods -n moghaExpected output:
NAME READY STATUS RESTARTS AGE
mogdb-ha-6d67c96476-6j42z 2/2 Running 0 49sWhen the Pod is in Running state, continue to the next step.
Step 5: Install Monitoring and Alerting
-
Config
cat > myvalues.yaml <<-EOF grafanaNodeport: 31043 # grafana graphical interface address port prometheusNodeport: 31042 # prometheus graphical interface address port alertmanagerNodeport: 31044 # alertmanager graphical interface address port alertEmailHost: smtp.163.com # Alert mailbox server host alertEmailSmtp: smtp.163.com:25 # SMTP server for sending emails, including port number alertEmailUsername: <Your Email Name> # Mailbox for sending alerts alertEmailPassword: <Your Email Password> # Mailbox authorization password receiversEmail: <Your Receive Email> # Mailbox for receiving alarms, multiple separated by commas EOF -
Create a namespace for monitoring
kubectl create namespace monitorExpected output:
namespace/monitor created -
Install Monitoring and Alerting
helm install -f myvalues.yaml monitor mogdb-stack/mogdb-monitor --namespace monitorExpected output:
NAME: monitor LAST DEPLOYED: Tue Jan 10 18:00:45 2023 NAMESPACE: monitor STATUS: deployed REVISION: 1 TEST SUITE: None
Check that the Monitoring and Alerting component is running properly.
kubectl get pods -n monitorExpected output:
NAME READY STATUS RESTARTS AGE
grafana-5548d85c77-v9x69 1/1 Running 0 77s
node-exporter-67ggw 1/1 Running 0 77s
node-exporter-6gf2c 1/1 Running 0 77s
node-exporter-qz4jk 1/1 Running 0 77s
prometheus-645fcdf654-q4q59 2/2 Running 0 77sWhen all pods are in Running state, continue to the next step.
Step 6: Create a cluster
By default, one primary and one standby node will be created. If more than one node is needed, the replicaCount parameter can be set by Helm to support up to 7 replicas.
helm install mycluster mogdb-stack/mogdb-cluster --set enableHa=true --namespace mogdb-operator-systemExpected output:
NAME: mycluster
LAST DEPLOYED: Wed Jan 11 11:17:53 2023
NAMESPACE: mogdb-operator-system
STATUS: deployed
REVISION: 1
TEST SUITE: None
NOTES:
Thank you for deploying a MogDB Cluster!Check if the pod is running properly
kubectl get pods -n mogdb-operator-systemExpected output:
NAME READY STATUS RESTARTS AGE
cluster1-g3umz 2/2 Running 0 3m48s
cluster1-s8sti 2/2 Running 0 2m28s
mogdb-apiserver-699c855d9b-878qj 1/1 Running 0 17h
mogdb-operator-myproject-5cd5bb9d9-7xztz 1/1 Running 0 17hWhen all pods are in Running state, it means the cluster is created successfully.
Uninstall
Step 1: Delete the cluster
helm uninstall mycluster -n mogdb-operator-systemExpected output:
release "mycluster" uninstalledCheck if cluster pods are deleted correctly
kubectl get pods -n mogdb-operator-systemExpected output:
NAME READY STATUS RESTARTS AGE
mogdb-apiserver-699c855d9b-878qj 1/1 Running 0 22h
mogdb-operator-myproject-5cd5bb9d9-7xztz 1/1 Running 0 22hYou can see that all the pods related to MogDB Cluster are deleted successfully except for the system pod. After successful deletion, continue to the next step.
Note: There may be more than one set of clusters in the system, and you must delete them one by one before you can proceed to the next step.
Step 2: Uninstall Monitoring and Alerting
-
Delete resource objects
helm uninstall monitor -n monitorExpected output:
release "monitor" uninstalledCheck if the relevant Pod was successfully deleted
No resources found in monitor namespace.You can see that all the pods under the monitor namespace have been successfully deleted.
-
Delete namespace
kubectl delete namespace monitorExpected output:
namespace "monitor" deleted
After all operations are successful, continue to the next step.
Step 3: Uninstall MogDB Operator
-
Uninstall the MogDB Operator object
helm uninstall myproject -n mogdb-operator-systemExpected output:
release "myproject" uninstalledCheck if the relevant Pod was successfully deleted
kubectl get pods -n mogdb-operator-systemExpected output:
NAME READY STATUS RESTARTS AGE mogdb-apiserver-699c855d9b-878qj 1/1 Running 0 22hYou can see that mogdb-operator-myproject-xxx was deleted successfully.
-
Delete MogDB Operator CRDs
MogDB Operator contains many Custom Resource Define (CRD). Execute the following command to remove the CRD from a Kubernetes cluster.
kubectl delete -f https://raw.githubusercontent.com/enmotech/mogdb-stack-examples/main/helm/crd.yamlExpected output:
customresourcedefinition.apiextensions.k8s.io/mogdbclusters.mogdb.enmotech.io created customresourcedefinition.apiextensions.k8s.io/mogdbbackups.mogdb.enmotech.io created
After all operations are successful, continue to the next step.
Step 4: Uninstall MogDB apiserver
-
Delete resource objects
helm uninstall myapiserver -n mogdb-operator-systemExpected output:
release "myapiserver" uninstalledCheck if the relevant Pod was successfully deleted
kubectl get pods -n mogdb-operator-systemExpected output:
No resources found in mogdb-operator-system namespace.You can see that mogdb-apiserver-xxx was deleted successfully.
-
Delete namespace
kubectl delete namespace mogdb-operator-systemExpected output:
namespace "mogdb-operator-system" deleted
After all operations are successful, continue to the next step.
Step 5: Uninstall MogHA
-
Delete resource objects
helm uninstall mogdb-ha --namespace moghaExpected output:
release "mogdb-ha" uninstalledCheck if the relevant Pod was successfully deleted
kubectl get pods -n moghaExpected output:
No resources found in mogha namespace.You can see that mogdb-ha-xxx was deleted successfully.
-
Delete namespace
kubectl delete namespace moghaExpected output:
namespace "mogha" deleted