ScalarDB Schema Loader
このページ は英語版のページが機械翻訳されたものです。英語版との間に矛盾または不一致がある場合は、英語版を正としてください。
ScalarDB には、実装固有のデータモデルとスキーマにマップされる独自のデータモデルとスキーマがあります。 さらに、ScalarDB は、Consensus Commit トランザクションマネージャーを使用するときにトランザクションログとステータスを管理するために、トランザクション ID、レコードバージョン、トランザクションステータスなどの内部メタデータを保存します。
トランザクションのスキーママッピングとメタデータの管理は難しい場合があるため、スキーママッピングやメタデータに関する詳細な知識を必要としないスキーマ作成ツールである ScalarDB Schema Loader を使用できます。
Schema Loader で一般的な CLI オプションを指定するには、次の2つのオプションがあります。
- ScalarDB プロパティファイルとデータベース固有またはストレージ固有のオプションを渡します。
- ScalarDB プロパティファイルなしでデータベース固有またはストレージ固有のオプションを渡します。(非推奨)
このツールは、テーブルの作成、削除、修復、または変更を行うための基本的なオプションのみをサポートしています。データベースの高度な機能を使用する場合は、このツールでテーブルを作成した後、データベース固有のツールを使用してテーブルを変更する必要があります。
Schema Loader を設定する
希望する方法を選択して Schema Loader を設定し、指示に従います。
- Fat JAR
- Docker container
Schema Loader のリリースバージョンは、ScalarDB Releases ページからダウンロードできます。
次のコマンドを実行し、山括弧内の内容を説明に従って置き換えることで、Scalar コンテナーレジストリ から Docker イメージを取得できます 。
docker run --rm -v <PATH_TO_YOUR_LOCAL_SCALARDB_PROPERTIES_FILE>:/scalardb.properties -v <PATH_TO_YOUR_LOCAL_SCHEMA_FILE>:/schema.json ghcr.io/scalar-labs/scalardb-schema-loader:<VERSION> --config /scalardb.properties --schema-file /schema.json <OTHER_COMMAND_ARGUMENTS>
fat JAR やコンテナを使用する場合でも、同じコマンド引数を指定できます。利用可能なコマンドセクションでは JAR が使用されていますが、java -jar scalardb-schema-loader-<VERSION>.jar を docker run --rm -v <PATH_TO_YOUR_LOCAL_SCHEMA_FILE>:<PATH_TO_SCHEMA_FILE_DOCKER> [-v <PATH_TO_LOCAL_SCALARDB_PROPERTIES_FILE>:<PATH_TO_SCALARDB_PROPERTIES_FILE_IN_DOCKER>] ghcr.io/scalar-labs/scalardb-schema-loader:<VERSION> に置き換えることで、コンテナを使用して同様にコマンドを実行できます。
Schema Loader を実行する
このセクションでは、Schema Loader を実行する方法について説明します。
利用可能なコマンド
データベースの Schema Loader を設定する方法を選択します。他のデータベース固有の方法は非推奨であるため、プロパティファイルを使用することをお勧めします。
プロパティファイルを使用する場合、次のコマンドを使用できます。
Usage: java -jar scalardb-schema-loader-<VERSION>.jar [-D] [--coordinator]
[--no-backup] [--no-scaling] -c=<configPath>
[--compaction-strategy=<compactionStrategy>] [-f=<schemaFile>]
[--replication-factor=<replicaFactor>]
[--replication-strategy=<replicationStrategy>] [--ru=<ru>]
Create/Delete schemas in the storage defined in the config file
-A, --alter Alter tables : it will add new columns and create/delete
secondary index for existing tables. It compares the
provided table schema to the existing schema to decide
which columns need to be added and which indexes need
to be created or deleted
-c, --config=<configPath>
Path to the config file of ScalarDB
--compaction-strategy=<compactionStrategy>
The compaction strategy, must be LCS, STCS or TWCS
(supported in Cassandra)
--coordinator Create/delete/repair Coordinator tables
-D, --delete-all Delete tables
-f, --schema-file=<schemaFile>
-I, --import Import tables : it will import existing non-ScalarDB
tables to ScalarDB.
Path to the schema json file
--no-backup Disable continuous backup (supported in DynamoDB)
--no-scaling Disable auto-scaling (supported in DynamoDB, Cosmos DB)
--repair-all Repair namespaces and tables that are in an unknown
state: it re-creates namespaces, tables, secondary
indexes, and their metadata if necessary.
--replication-factor=<replicaFactor>
The replication factor (supported in Cassandra)
--replication-strategy=<replicationStrategy>
The replication strategy, must be SimpleStrategy or
NetworkTopologyStrategy (supported in Cassandra)
--ru=<ru> Base resource unit (supported in DynamoDB, Cosmos DB)
--upgrade Upgrades the ScalarDB environment to support the latest
version of the ScalarDB API. Typically, as indicated in
the release notes, you will need to run this command
after updating the ScalarDB version that your
application environment uses.
サンプルのプロパティファイルについては、database.properties を参照してください。
次のデータベース固有のメソッドは非推奨になりました。代わりに、プロパティファイルを設定するためのコマンドを使用してください。
- JDBC データベース
- DynamoDB
- Cosmos DB for NoSQL
- Cassandra
Usage: java -jar scalardb-schema-loader-<VERSION>.jar --jdbc [-D]
-f=<schemaFile> -j=<url> -p=<password> -u=<user>
Create/Delete JDBC schemas
-A, --alter Alter tables : it will add new columns and create/delete
secondary index for existing tables. It compares the
provided table schema to the existing schema to decide
which columns need to be added and which indexes need
to be created or deleted
-D, --delete-all Delete tables
-f, --schema-file=<schemaFile>
Path to the schema json file
-j, --jdbc-url=<url> JDBC URL
-p, --password=<password>
JDBC password
--repair-all Repair tables : it repairs the table metadata of
existing tables
-u, --user=<user> JDBC user
Usage: java -jar scalardb-schema-loader-<VERSION>.jar --dynamo [-D]
[--no-backup] [--no-scaling] [--endpoint-override=<endpointOverride>]
-f=<schemaFile> -p=<awsSecKey> [-r=<ru>] --region=<awsRegion>
-u=<awsKeyId>
Create/Delete DynamoDB schemas
-A, --alter Alter tables : it will add new columns and create/delete
secondary index for existing tables. It compares the
provided table schema to the existing schema to decide
which columns need to be added and which indexes need
to be created or deleted
-D, --delete-all Delete tables
--endpoint-override=<endpointOverride>
Endpoint with which the DynamoDB SDK should
communicate
-f, --schema-file=<schemaFile>
Path to the schema json file
--no-backup Disable continuous backup for DynamoDB
--no-scaling Disable auto-scaling for DynamoDB
-p, --password=<awsSecKey> AWS access secret key
-r, --ru=<ru> Base resource unit
--region=<awsRegion> AWS region
--repair-all Repair tables : it repairs the table metadata of
existing tables
-u, --user=<awsKeyId> AWS access key ID
Usage: java -jar scalardb-schema-loader-<VERSION>.jar --cosmos [-D]
[--no-scaling] -f=<schemaFile> -h=<uri> -p=<key> [-r=<ru>]
Create/Delete Cosmos DB schemas
-A, --alter Alter tables : it will add new columns and create/delete
secondary index for existing tables. It compares the
provided table schema to the existing schema to decide
which columns need to be added and which indexes need
to be created or deleted
-D, --delete-all Delete tables
-f, --schema-file=<schemaFile>
Path to the schema json file
-h, --host=<uri> Cosmos DB account URI
--no-scaling Disable auto-scaling for Cosmos DB
-p, --password=<key> Cosmos DB key
-r, --ru=<ru> Base resource unit
--repair-all Repair tables : it repairs the table metadata of
existing tables and repairs stored procedure
attached to each table
Usage: java -jar scalardb-schema-loader-<VERSION>.jar --cassandra [-D]
[-c=<compactionStrategy>] -f=<schemaFile> -h=<hostIp>
[-n=<replicationStrategy>] [-p=<password>] [-P=<port>]
[-R=<replicationFactor>] [-u=<user>]
Create/Delete Cassandra schemas
-A, --alter Alter tables : it will add new columns and create/delete
secondary index for existing tables. It compares the
provided table schema to the existing schema to decide
which columns need to be added and which indexes need
to be created or deleted
-c, --compaction-strategy=<compactionStrategy>
Cassandra compaction strategy, must be LCS, STCS or TWCS
-D, --delete-all Delete tables
-f, --schema-file=<schemaFile>
Path to the schema json file
-h, --host=<hostIp> Cassandra host IP
-n, --network-strategy=<replicationStrategy>
Cassandra network strategy, must be SimpleStrategy or
NetworkTopologyStrategy
-p, --password=<password>
Cassandra password
-P, --port=<port> Cassandra Port
-R, --replication-factor=<replicationFactor>
Cassandra replication factor
--repair-all Repair tables : it repairs the table metadata of
existing tables
-u, --user=<user> Cassandra user