Oracle NoSQL DatabaseからJSONファイルへの移行
この例では、Oracle NoSQL Database Migratorを使用して、Oracle NoSQL DatabaseからJSONファイルにNoSQL表のデータおよびスキーマ定義をコピーする方法を示します。
ユースケース
組織は、Oracle NoSQL Databaseデータを使用してモデルのトレーニングを行い、将来の行動を予測し、パーソナライズされた推奨を提供することを決定しました。NoSQLデータベース表のデータの定期的なコピーをJSONファイルに取得し、分析エンジンに適用してモデルを分析およびトレーニングできます。これは、分析問合せを低遅延のクリティカル・パスから分離するのに役立ちます。
例
このデモでは、myTableというNoSQL表のデータおよびスキーマ定義をNoSQLデータベースからJSONファイルに移行する方法について説明します。
前提条件
- 移行するソースとシンクを指定します。
- ソース: Oracle NoSQL Database
- シンク: JSONファイル
- オンプレミスKVStoreの次の詳細を指定します。
- storeName:
kvstore - helperHosts:
<hostname>:5000 - table:
myTable
- storeName:
手順
myTableのデータおよびスキーマ定義をOracle NoSQL DatabaseからJSONファイルに移行するには:
- コマンド・プロンプトを開き、NoSQL Database Migratorユーティリティを抽出したディレクトリに移動します。
- NoSQL Database Migratorを使用して構成ファイルを生成するには、ランタイム・パラメータを指定せずに
runMigratorコマンドを実行します。[~/nosqlMigrator]$./runMigrator - ランタイム・パラメータとして構成ファイルを指定しなかったため、構成を今すぐ生成するかどうかを尋ねるプロンプトが表示されます。
「y」と入力します。Configuration file is not provided. Do you want to generate configuration? (y/n) [n]: y Generating a configuration file interactively. - ユーティリティのプロンプトに基づいて、ソース構成のオプションを選択します。
Enter a location for your config [./migrator-config.json]: /home/<user>/nosqlMigrator/ Select the source: 1) nosqldb 2) nosqldb_cloud 3) file 4) object_storage_oci 5) aws_s3 #? 1 Configuration for source type=nosqldb Enter store name of the Oracle NoSQL Database: kvstore Enter comma separated list of host:port of Oracle NoSQL Database: <hostname>:5000 Enter fully qualified table name: myTable Include TTL data? If you select 'yes' TTL of rows will also be included in the exported data.(y/n) [n]: Is the store secured? (y/n) [y]: Enter store operation timeout in milliseconds. (1-30000) [5000]: - ユーティリティのプロンプトに基づいて、シンク構成のオプションを選択します。
Select the sink: 1) nosqldb 2) nosqldb_cloud 3) file #? 3 Configuration for sink type=file Select the sink file format: 1) json 2) parquet #? 1 Enter path to a directory to store JSON data: /home/<user>/nosqlMigrator would you like to export data to multiple files for each source?(y/n) [y]: n Would you like to store JSON in pretty format? (y/n) [n]: y Would you like to migrate the table schema also? (y/n) [y]: y Enter path to a file to store table schema: /home/<user>/nosqlMigrator/myTableSchema.ddl - ユーティリティのプロンプトに基づいて、ソース・データ変換のオプションを選択します。デフォルト値は
nです。Would you like to add transformations to source data? (y/n) [n]: - レコードの移行に失敗した場合に移行を続行するかどうかを決定するための選択肢を入力します。
Would you like to continue migration in case of any record/row is failed to migrate?: (y/n) [n]: - 生成された構成が画面に表示されます。
Generated configuration is: { "source" : { "type" : "nosqldb", "storeName" : "kvstore", "helperHosts" : ["<hostname>:5000"], "table" : "myTable", "includeTTL" : true, "requestTimeoutMs" : 5000 }, "sink" : { "type" : "file", "format" : "json", "useMultiFiles" : false, "schemaPath" : "/home/<username>/nosqlMigrator/myTableSchema.ddl", "pretty" : true, "dataPath" : "/home/<username>/nosqlMigrator/" }, "abortOnError" : true, "migratorVersion" : "1.7.0" }
検証
移行を検証するには、指定したシンク・ディレクトリに移動し、スキーマとデータを表示します。
-- Exported myTable Data. JSON files are created in the supplied data path
[~/nosqlMigrator]$cat myTable_1_5.json
{
"id" : 2,
"document" : "{\"course\":\"Bio-Technology\",\"name\":\"Raja\",\"studentid\":108}"
}
{
"id" : 7,
"document" : "{\"course\":\"Computer Science\",\"name\":\"Ruby\",\"studentid\":100}"
}
{
"id" : 4,
"document" : "{\"course\":\"Computer Science\",\"name\":\"Ruby\",\"studentid\":100}"
}
{
"id" : 10,
"document" : "{\"course\":\"Computer Science\",\"name\":\"Neena\",\"studentid\":105}"
}
{
"id" : 5,
"document" : "{\"course\":\"Journalism\",\"name\":\"Rani\",\"studentid\":106}"
}
[~/nosqlMigrator]$cat myTable_6_10.json
{
"id" : 8,
"document" : "{\"course\":\"Computer Science\",\"name\":\"Tom\",\"studentid\":103}"
}
{
"id" : 3,
"document" : "{\"course\":\"Computer Science\",\"name\":\"John\",\"studentid\":107}"
}
{
"id" : 9,
"document" : "{\"course\":\"Computer Science\",\"name\":\"Peter\",\"studentid\":109}"
}
{
"id" : 6,
"document" : "{\"course\":\"Bio-Technology\",\"name\":\"Rekha\",\"studentid\":104}"
}
{
"id" : 1,
"document" : "{\"course\":\"Journalism\",\"name\":\"Tracy\",\"studentid\":110}"
}
-- Exported myTable Schema
[~/nosqlMigrator]$cat myTableSchema
CREATE TABLE IF NOT EXISTS myTable (id INTEGER, document JSON, PRIMARY KEY(SHARD(id)))