Run a distributed database on the cloud

Run a distributed database on the cloud
wuweijie
Mon, 04/17/2023 – 03:00

Apache ShardingSphere is an open source distributed database toolkit. It enhances any database with data sharding, elastic scaling, encryption, and many other capabilities. Deploying and maintaining ShardingSphere-Proxy clusters and load balancing manually can be labor-intensive and time-consuming. To address this issue, Apache ShardingSphere offers ShardingSphere on Cloud, a collection of cloud-based solutions.

ShardingSphere-on-Cloud includes automated deployment scripts to virtual machines in cloud environments. It also includes tools for a Kubernetes cloud-native environment and a variety of hands-on content for high availability, observability, security policy compliance, and more. This includes Helm Charts, an Operator, and automatic horizontal scaling.

The new cloud project provides the following capabilities:

  • Helm Charts-based ShardingSphere-Proxy for one-click deployment in Kubernetes environments.
  • Operator-based ShardingSphere-Proxy for one-click deployment and automated maintenance in Kubernetes environments.
  • Amazon Web Services (AWS) CloudFormation-based ShardingSphere-Proxy for rapid deployment.
  • Terraform-based rapid deployment of ShardingSphere-Proxy in AWS environments.

This article demonstrates one of the fundamental capabilities of ShardingSphere on Cloud: One-click deployment of ShardingSphere-Proxy clusters in Kubernetes using Helm Charts.

  1. Use the following three-line command to create a three-node ShardingSphere-Proxy cluster within a Kubernetes cluster with the default configuration and serve it through the Service:

    $ helm repo add shardingsphere https://apache.github.io/shardingsphere-on-cloud
    $ helm repo update
    $ helm install shardingsphere-proxy shardingsphere/apache-shardingsphere-proxy-charts -n shardingsphere
Create a three-node ShardingSphere-Proxy cluster

(Wu Weijie, CC BY-SA 4.0)

  1. The application can access the ShardingSphere-Proxy cluster through the svc domain:

    $ kubectl run mysql-client --image=mysql:5.7.36 
      --image-pull-policy=IfNotPresent -- sleep 300
    $ kubectl exec -i -t mysql-client -- mysql 
      -h shardingsphere-proxy-apache-shardingsphere-proxy.shardingsphere.svc.cluster.local 
      -P3307 -uroot -proot
Access the cluster through the svc domain

(Wu Weijie, CC BY-SA 4.0)

It’s as easy as that. You’re running ShardingSphere on the cloud, and that’s just the beginning. For more advanced features, refer to the official ShardingSphere-on-Cloud documentation.


This article is adapted from A Distributed Database Load Balancing Architecture Based on ShardingSphere: Demo and User Case and is republished with permission.

Create a distributed database cluster with Kubernetes in two easy steps.

diagram of planning a cloud

Opensource.com

What to read next

Creative Commons License
This work is licensed under a Creative Commons Attribution-Share Alike 4.0 International License.

Powered by WPeMatico

Author: dasuberworm

Standing just over 2 meters and hailing from о́стров Ратма́нова, Dasuberworm is a professional cryptologist, entrepreneur and cage fighter. When he's not breaking cyphers and punching people in the face, Das enjoys receiving ominous DHL packages at one of his many drop sites in SE Asia.

Share This Post On