HomeMogDBMogDB StackUqbar

Documentation:v2.0

Supported Versions:

Other Versions:

MogDB Stack Installation

Step 1: Install MogDB Operator

The process of deploying MogDB Operator is divided into two steps.

  1. Install MogDB Operator CRD

  2. 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.yaml

Expected output:

customresourcedefinition.apiextensions.k8s.io/mogdbclusters.mogdb.enmotech.io created
customresourcedefinition.apiextensions.k8s.io/mogdbbackups.mogdb.enmotech.io created

Install MogDB Operator

Install Helm 3 and deploy MogDB Operator with Helm 3

  1. Add MogDB Stack repository

    helm repo add mogdb-stack https://enmotech.github.io/mogdb-stack-examples/helm/charts

    Expected output:

    "mogdb-stack" has been added to your repositories
    helm search repo mogdb-stack

    Expected 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 Kubernetes

    The repository contains five chart packages, which are mogdb-operator, mogdb-apiserver, mogha, mogdb-monitor and mogdb-cluster.

  2. Create a namespace for the MogDB Operator

    kubectl create namespace mogdb-operator-system

    Expected output:

    namespace/mogdb-operator-system created
  3. Install MogDB Operator

    helm install myproject mogdb-stack/mogdb-operator --namespace mogdb-operator-system

    Expected 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-system

Expected output:

NAME                                       READY   STATUS    RESTARTS   AGE
mogdb-operator-myproject-5cd5bb9d9-7xztz   1/1     Running   0          73s

When 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-system

Expected 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          11m

When 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.sh

This 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-system

If 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 ~/.bashrc

Note: For macOS users, you use the file ~/.bash_profile instead of ~/.bashrc.

Step 4: Install MogHA

  1. Create a namespace for MogHA

    kubectl create namespace mogha

    Expected output:

    namespace/mogha created
  2. Install MogHA

    helm install mogdb-ha mogdb-stack/mogha --namespace mogha

    Expected 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 mogha

Expected output:

NAME                        READY   STATUS    RESTARTS   AGE
mogdb-ha-6d67c96476-6j42z   2/2     Running   0          49s

When the Pod is in Running state, continue to the next step.

Step 5: Install Monitoring and Alerting

  1. 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
  2. Create a namespace for monitoring

    kubectl create namespace monitor

    Expected output:

    namespace/monitor created
  3. Install Monitoring and Alerting

    helm install -f myvalues.yaml monitor mogdb-stack/mogdb-monitor --namespace monitor

    Expected 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 monitor

Expected 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          77s

When 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-system

Expected 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-system

Expected 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          17h

When 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-system

Expected output:

release "mycluster" uninstalled

Check if cluster pods are deleted correctly

kubectl get pods -n  mogdb-operator-system

Expected output:

NAME                                       READY   STATUS    RESTARTS   AGE
mogdb-apiserver-699c855d9b-878qj           1/1     Running   0          22h
mogdb-operator-myproject-5cd5bb9d9-7xztz   1/1     Running   0          22h

You 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

  1. Delete resource objects

    helm uninstall monitor -n monitor

    Expected output:

    release "monitor" uninstalled

    Check 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.

  2. Delete namespace

    kubectl delete namespace monitor

    Expected output:

    namespace "monitor" deleted

After all operations are successful, continue to the next step.

Step 3: Uninstall MogDB Operator

  1. Uninstall the MogDB Operator object

    helm uninstall myproject -n mogdb-operator-system

    Expected output:

    release "myproject" uninstalled

    Check if the relevant Pod was successfully deleted

     kubectl get pods -n  mogdb-operator-system

    Expected output:

    NAME                               READY   STATUS    RESTARTS   AGE
    mogdb-apiserver-699c855d9b-878qj   1/1     Running   0          22h

    You can see that mogdb-operator-myproject-xxx was deleted successfully.

  2. 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.yaml

    Expected 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

  1. Delete resource objects

    helm uninstall myapiserver -n mogdb-operator-system 

    Expected output:

    release "myapiserver" uninstalled

    Check if the relevant Pod was successfully deleted

    kubectl get pods -n mogdb-operator-system

    Expected output:

    No resources found in mogdb-operator-system namespace.

    You can see that mogdb-apiserver-xxx was deleted successfully.

  2. Delete namespace

    kubectl delete namespace mogdb-operator-system

    Expected output:

    namespace "mogdb-operator-system" deleted

After all operations are successful, continue to the next step.

Step 5: Uninstall MogHA

  1. Delete resource objects

    helm uninstall mogdb-ha  --namespace mogha

    Expected output:

    release "mogdb-ha" uninstalled

    Check if the relevant Pod was successfully deleted

    kubectl get pods -n mogha

    Expected output:

    No resources found in mogha namespace.

    You can see that mogdb-ha-xxx was deleted successfully.

  2. Delete namespace

    kubectl delete namespace mogha

    Expected output:

    namespace "mogha" deleted
Copyright © 2011-2024 www.enmotech.com All rights reserved.