產生來源與目標資料庫之間的類型對應
必須要有類型對應,才能瞭解不同來源和目標資料庫之間進行複寫時的資料行為。Oracle GoldenGate 支援許多來源和目標資料庫複製組合。您可以使用 MappingGenerator.py 指令碼來決定這些組合的類型對應。
MappingGenerator.py 是 Python 命令檔,可根據可用的 JSON 組態檔產生來源與目標資料庫之間的類型對應。
先決條件
MappingGenerator.py 程序檔的使用先決條件如下:
- 必須安裝 Python 3.x。
json和txt程式庫 (Python 標準程式庫的一部分) 必須存在。argparse程式庫 (Python Standard 程式庫的一部分) 必須存在。
執行 MappingGenerator.py 指令碼
若要執行 MappingGenerator.py 指令碼,請使用下列指令:
python MappingGenerator.py source_json_file target_json_file output_txt_file>
在此命令中:
source_json_file:來源 JSON 組態檔的路徑。target_json_file:目標 JSON 組態檔的路徑。output_txt_file:將包含所產生對應之輸出文字檔的路徑。
附註:請確定輸出路徑與包含 MappingGenerator.py 及任何輸入 JSON 檔案的路徑不同。{. :infoboxnote}
您可以使用 MappingJSON 目錄下的 source_json_file 和 target_json_file。source_json_file 檔案名稱看起來類似於 AutoSchemadatabase_nameSourceMappings.json,而 target_json_file 檔案名稱看起來類似於 AutoSchemadatabase_nameTargetMappings.json。
您可以選擇 Oracle GoldenGate Autoschema 對應所支援之任何資料庫的 source_json_file 和 target_json_file。
範例
下列範例示範將 MySQL 產生至 Oracle 自動綱要類型對應:
python MappingGenerator.py ./MappingJSON/AutoSchemaMySQLSourceMappings.json ./MappingJSON/AutoSchemaOracleTargetMappings.json /tmp/MySQL_to_Oracle_autoschema_mappings.txt
此命令檔會產生第三個引數中指定之名稱的文字檔。此檔案包含以人為可讀格式產生的類型對應。如需對映類型的範例,請參閱資料類型對映
使用 MappingGenerator.py 的準則
使用 MappingGenerator.py 程序檔時,下列考量十分重要:
- 確定輸入 JSON 檔案有效且遵循預期的格式。
- 檢查輸出目錄是否存在且可寫入。