- 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
Connecting to MogDB Cluster
Before connecting, make sure the MogDB cluster has been installed correctly based on Create a MogDB Cluster.
Changing Password
Before connecting, you need to change the password of the default user. You can change the password by connecting to the container where the primary node is located using the kubectl command.
kubectl exec -it pod/cluster1-nduk8 -c mogdb -n mogdb-operator-system -- /bin/bash
gsql -dpostgres
ALTER USER mogdb WITH PASSWORD 'P@55word!';
Connecting MogDB
Installing gsql
For details, see gsql | MogDB Docs.
Connecting the MogDB Cluster
By default, MogDB Operator creates two services with a cluster name prefix, one service for the primary node and one service for the standby node.
The following command can be used to obtain a list of all available services in the mogdb-operator-system namespace.
kubectl get svc -n mogdb-operator-system
Expected output:
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
cluster1-svc-master NodePort 10.96.158.193 <none> 5432:30013/TCP 13m
cluster1-svc-replicas NodePort 10.110.121.108 <none> 5432:30012/TCP 13m
mogdb-apiserver NodePort 10.99.235.65 <none> 8444:32444/TCP 33m
In the output, the port of the primary node service is 30013, and the port of the standby node service is 30012. You can run the following command to connect the database:
gsql -h 127.0.0.1 -p 30013 -U mogdb -W P@55word!
You should then see the MogDB prompt.
gsql ((MogDB 3.1.0 build aef997f9) compiled at 2022-11-24 00:02:35 commit 0 last mr )
Non-SSL connection (SSL connection is recommended when requiring high-security)
Type "help" for help.
MogDB=>
Outside of the Kubernetes Cluster
MogDB Operator creates two services with a cluster name prefix, and the type of service is set to NodePort, which can map service port and host port.
You only need to connect "Host:Port".