メインコンテンツまでスキップ
バージョン: 3.13

マルチストレージトランザクション

注記

このページは英語版のページが機械翻訳されたものです。英語版との間に矛盾または不一致がある場合は、英語版を正としてください。

ScalarDB トランザクションは、マルチストレージトランザクション と呼ばれる機能を使用することで、ACID 準拠を維持しながら複数のストレージまたはデータベースにまたがることができます。

このページでは、マルチストレージトランザクションの仕組みと、ScalarDB でこの機能を設定する方法について説明します。

ScalarDB でのマルチストレージトランザクションの仕組み

ScalarDB では、マルチストレージ 実装は複数のストレージインスタンスを保持し、名前空間名から適切なストレージインスタンスへのマッピングを持っています。操作が実行されると、マルチストレージトランザクション機能は、名前空間ストレージマッピングを使用して指定された名前空間から適切なストレージインスタンスを選択し、そのストレージインスタンスを使用します。

マルチストレージトランザクションをサポートするように ScalarDB を設定する方法

マルチストレージトランザクションを有効にするには、scalar.db.transaction_manager の値として consensus-commit を指定し、scalar.db.storage の値として multi-storage を指定し、ScalarDB プロパティファイルでデータベースを設定する必要があります。

以下は、マルチストレージトランザクションの設定例です。

# Consensus Commit is required to support multi-storage transactions.
scalar.db.transaction_manager=consensus-commit

# Multi-storage implementation is used for Consensus Commit.
scalar.db.storage=multi-storage

# Define storage names by using a comma-separated format.
# In this case, "cassandra" and "mysql" are used.
scalar.db.multi_storage.storages=cassandra,mysql

# Define the "cassandra" storage.
# When setting storage properties, such as `storage`, `contact_points`, `username`, and `password`, for multi-storage transactions, the format is `scalar.db.multi_storage.storages.<STORAGE_NAME>.<PROPERTY_NAME>`.
# For example, to configure the `scalar.db.contact_points` property for Cassandra, specify `scalar.db.multi_storage.storages.cassandra.contact_point`.
scalar.db.multi_storage.storages.cassandra.storage=cassandra
scalar.db.multi_storage.storages.cassandra.contact_points=localhost
scalar.db.multi_storage.storages.cassandra.username=cassandra
scalar.db.multi_storage.storages.cassandra.password=cassandra

# Define the "mysql" storage.
# When defining JDBC-specific configurations for multi-storage transactions, you can follow a similar format of `scalar.db.multi_storage.storages.<STORAGE_NAME>.<PROPERTY_NAME>`.
# For example, to configure the `scalar.db.jdbc.connection_pool.min_idle` property for MySQL, specify `scalar.db.multi_storage.storages.mysql.jdbc.connection_pool.min_idle`.
scalar.db.multi_storage.storages.mysql.storage=jdbc
scalar.db.multi_storage.storages.mysql.contact_points=jdbc:mysql://localhost:3306/
scalar.db.multi_storage.storages.mysql.username=root
scalar.db.multi_storage.storages.mysql.password=mysql
# Define the JDBC-specific configurations for the "mysql" storage.
scalar.db.multi_storage.storages.mysql.jdbc.connection_pool.min_idle=5
scalar.db.multi_storage.storages.mysql.jdbc.connection_pool.max_idle=10
scalar.db.multi_storage.storages.mysql.jdbc.connection_pool.max_total=25

# Define namespace mapping from a namespace name to a storage.
# The format is "<NAMESPACE_NAME>:<STORAGE_NAME>,...".
scalar.db.multi_storage.namespace_mapping=user:cassandra,coordinator:mysql

# Define the default storage that's used if a specified table doesn't have any mapping.
scalar.db.multi_storage.default_storage=cassandra

追加の設定については、ScalarDB 設定を参照してください。

実践的なチュートリアル

実践的なチュートリアルについては、マルチストレージトランザクションをサポートするサンプルアプリケーションを作成するを参照してください。

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.