Skip to main content
Version: 3.15

Run Transactions Through ScalarDB Cluster

This guide explains how to configure your ScalarDB properties file and create schemas to run transactions through a one-phase or a two-phase commit interface by using ScalarDB Cluster.

warning

You need to have a license key (trial license or commercial license) for ScalarDB Cluster. If you don't have a license key, please contact us.

Preparation​

For the purpose of this guide, you will set up a database and ScalarDB Cluster in standalone mode by using a sample in the ScalarDB samples repository.

note

ScalarDB Cluster in standalone mode is primarily for development and testing purposes.

Clone the ScalarDB samples repository​

Open Terminal, then clone the ScalarDB samples repository by running the following command:

git clone https://github.com/scalar-labs/scalardb-samples

Then, go to the directory that contains the necessary files by running the following command:

cd scalardb-samples/scalardb-cluster-standalone-mode

Set up a database​

Select your database, and follow the instructions to configure it for ScalarDB Cluster.

For a list of databases that ScalarDB supports, see Databases.

Run MySQL locally

You can run MySQL in Docker Compose by using the docker-compose.yaml file in the scalardb-samples/scalardb-cluster-standalone-mode directory.

To start MySQL, run the following command:

docker compose up -d mysql

Configure ScalarDB Cluster

The scalardb-cluster-node.properties file in the scalardb-samples/scalardb-cluster-standalone-mode directory contains database configurations for ScalarDB Cluster. Please uncomment the properties for MySQL in the scalardb-cluster-node.properties file so that the configuration looks as follows:

# For MySQL
scalar.db.storage=jdbc
scalar.db.contact_points=jdbc:mysql://mysql-1:3306/
scalar.db.username=root
scalar.db.password=mysql

For a comprehensive list of configurations for ScalarDB Cluster, see ScalarDB Cluster Configurations.

Set up ScalarDB Cluster in standalone mode​

To set up ScalarDB Cluster in standalone mode, you'll need to set a license key and then start ScalarDB Cluster.

Set the license key​

Set the license key (trial license or commercial license) for the ScalarDB Clusters in the properties file. For details, see How to Configure a Product License Key.

Start ScalarDB Cluster in standalone mode​

To start ScalarDB Cluster in standalone mode, run the following command:

note

If you want to change other configurations for ScalarDB Cluster, update the scalardb-cluster-node.properties file before running the command below.

docker compose up -d scalardb-cluster-node

Create or import a schema​

ScalarDB has its own data model and schema that maps to the implementation-specific data model and schema.

Run transactions​

You can run transactions by using a one-phase or a two-phase commit interface. Select your method for running transactions.

note

If you are building a monolithic application, you should use the one-phase commit interface. However, if you are building a microservice application, see ScalarDB Cluster Deployment Patterns for Microservices to decide which interface to use.

One-phase commit interface

For details about how to run transactions by using a one-phase commit interface, see the ScalarDB Java API Guide.

note

To try running transactions by using a one-phase commit interface, see the following sample tutorials:

Two-phase commit interface

For details about how to run transactions by using a two-phase commit interface, see Transactions with a Two-Phase Commit Interface.

note

To try running transactions by using a two-phase commit interface, see the following sample tutorials:

Learn more

To learn more about running transactions by using ScalarDB Cluster, see the following:

This website uses cookies to enhance the visitor experience. By continuing to use this website, you acknowledge that you have read and understood our privacy policy and consent to the use of cookies to help improve your browsing experience and provide you with personalized content.