データベース移行

AWS内でのデータベース移行をするための調査をした。 やりたいことはPostgreSQL→MicrosoftSQLServer2017で、
リリース前にコピー同期移行を実施して、リリース後は、逆方向にコピー同期するということ。
AWS Database Migration Service (DMS)を検討したが、
バージョンが対応していないので、SymmetricDSを使うことにしたのが惨劇の始まりだった。

SymmetricDS

とにかく記事がすくなく、苦労したので忘れないうちに記録する。

SymmetricDSパターン別構築メモ(異種データベース)

postgresql(customers, plans) to sqlserver構成の基本設定

engines/corp-000.properties
engines/store-001.properties
engines/store-002.properties

からの変更点としては
corp→postgres
store→sqlserver
とし、下記のようなシンプルな1対1レプリケーション構成にした

engines/postgres-000.properties
engines/sqlserver-001.properties

engines/postgres-000.propertes

#db.driver=org.postgresql.Driver
engine.name=corp-000
db.user=
db.password=
group.id=corp
initial.load.create.first=true

↓サンプルを修正する

db.driver=org.postgresql.Driver
engine.name=postgres-000
db.user=DB接続ユーザ
db.password=DB接続パスワード
group.id=postgres
initial.load.create.first=false#自動生成テーブルは型がいまいちなので自分で用意する

engines/sqlserver-001.properties

#db.driver=org.postgresql.Driver
engine.name=corp-000
db.user=
db.password=
group.id=corp
initial.load.create.first=true

↓サンプルを修正する

db.driver=org.postgresql.Driver
engine.name=postgres-000
db.user=DB接続ユーザ
db.password=DB接続パスワード
group.id=postgres
initial.load.create.first=false#自動生成テーブルは型がいまいちなので自分で用意する

移行実行用の一連のコマンド(windows)

dbimport --engine sqlserver-001 truncate_table.sql
rmdir /S /Q ..\tmp\postgres-000
rmdir /S /Q ..\tmp\sqlserver-001
symadmin --engine postgres-000 uninstall
symadmin --engine sqlserver-001 uninstall
symadmin --engine postgres-000 create-sym-tables
dbimport --engine postgres-000 insert_migration.sql
sym

SymmetricDSパターン別構築メモ(異種データベース)