HomeMogDBMogDB StackUqbar

Documentation:v2.0

Supported Versions:

Create a MogDB Cluster

Before creating a MogDB cluster, make sure that you have installed and configured MogDB Stack correctly based on Getting Started.

There are two methods of creating a MogDB cluster, using the mgo client or manifest.

It is recommended that the mgo client is used for cluster creation.


mgo Client

1. Create a MogDB Cluster

The following command will create a MogDB cluster with default configurations in the default mgo namespace. For details, see mgo create cluster.

mgo create cluster cluster1

Output:

created cluster: cluster1

This operation may consume a little time.


2. Check Installation

The following command queries the status information of a created cluster. For details, see mgo show cluster.

mgo show cluster cluster1

Output:

cluster : cluster1
 pod : cluster1-ib7zq (Running) on mogdb-k8s-001 (3/3) (primary)
 pod : cluster1-rtwdz (Running) on mogdb-k8s-002 (3/3) (standby)
 service : cluster1-svc-master - ClusterIP (10.1.149.4) - Ports (5432:30013/TCP)
 service : cluster1-svc-replicas - ClusterIP (10.1.175.46) - Ports (5432:30012/TCP)

3. Process of Creating a Cluster

The mgo client creates a record in mogdbcluster, including properties required by cluster creation.

In the above example, the MogDB cluster uses most of the default values in the MogDB Operator configuration. For example, there are two standby nodes by default.

For details about the MogDB Operator configuration, see the related section.


helm

1. Add the MogDB Stack Library

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

Output:

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

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

2. Deploy the MogDB Cluster

helm install mycluster mogdb-stack/mogdb-cluster --namespace mogdb-operator-system

Output:

mogdbcluster.mogdb.enmotech.io/cluster1 created

Note:

  • For details about the parameter definition in Helm, see values;
  • By default, the local-path storage class in the kubernetes cluster, and the 30012 and 30013 ports are used for read and write.
  • The high availability function is disabled by default. To enable it, make sure that you have registered the HA component and set enableHa to true.
  • If the HA function is required, install the HA module in advance. For details, see installation/helm.

3. Check Installation

The following command checks whether the MogDB node is running correctly.

kubectl get pod,svc -n mogdb-operator-system --selector="mogdb.enmotech.io/cluster=cluster1"

Output:

NAME                 READY   STATUS    RESTARTS   AGE
pod/cluster1-lhomu   2/2     Running   0          3m
pod/cluster1-tygxc   2/2     Running   0          3m17s

NAME                            TYPE       CLUSTER-IP     EXTERNAL-IP   PORT(S)          AGE
service/cluster1-svc-master     NodePort   10.106.99.88   <none>        5432:30013/TCP   3m17s
service/cluster1-svc-replicas   NodePort   10.96.219.62   <none>        5432:30012/TCP   3m17s

If all resources in a pod are in the running status, the cluster creation is successful.

Kustomize

Prerequisites

  • Install Kustomize v3+.

    go install sigs.k8s.io/kustomize/kustomize/v3@v3.8.7
    ~/go/bin/kustomize version

    Note: kubectl 1.4+ is integrated with Kustomize by default.

  • Download MogDB Operator examples

    Fork the MogDB Stack examples library from GitHub.

    https://github.com/enmotech/mogdb-stack-examples/fork

    You can run the following command to download MogDB Stack to the local server.

    YOUR_GITHUB_UN="<your GitHub username>"
    git clone --depth 1 "git@github.com:${YOUR_GITHUB_UN}/mogdb-stack-examples.git"
    cd mogdb-stack-examples

    MogDB Operator is installed in the kustomize directory.

1. Create a MogDB Cluster

kubectl apply -k kustomize/mogdb-cluster

Output:

mogdbcluster.mogdb.enmotech.io/cluster1 created

Note:

  • By default, the local-path storage class in the kubernetes cluster, and the 30012 and 30013 ports are used for read and write.
  • The high availability function is disabled by default. To enable it, make sure that you have registered the HA component and set enableHa to true.
  • If the HA function is required, install the HA module in advance. For details, see installation/helm.
  • If customization is required, access the installation examples about different scenarios from the kustomize directory.

2. Check Installation

The following command checks whether the MogDB node is running correctly.

kubectl get pod,svc -n mogdb-operator-system --selector="mogdb.enmotech.io/cluster=cluster1"

Output:

NAME                 READY   STATUS    RESTARTS   AGE
pod/cluster1-8gkok   2/2     Running   0          3m8s
pod/cluster1-bqv8m   2/2     Running   0          4m

NAME                            TYPE       CLUSTER-IP      EXTERNAL-IP   PORT(S)          AGE
service/cluster1-svc-master     NodePort   10.96.117.172   <none>        5432:30013/TCP   4m
service/cluster1-svc-replicas   NodePort   10.96.103.146   <none>        5432:30012/TCP   4m

If all resources in a pod are in the running status, the cluster creation is successful.

Copyright © 2011-2024 www.enmotech.com All rights reserved.