Command-line usage#
比較モード#
.ini
ファイルを作成してLiveCompareを構成します。さまざまな構成オプションの説明については、
Connection Settings を参照してください。
例、基本的なテンプレートには次のものが含まれます。
; © Copyright EnterpriseDB UK Limited 2019-2024 - All rights reserved.
[General Settings]
logical_replication_mode = off
max_parallel_workers = 2
[First Connection]
dsn = host=192.168.0.100 port=5432 dbname=live1 user=postgres
[Second Connection]
dsn = host=192.168.0.200 port=5432 dbname=live2 user=postgres
[Third Connection]
dsn = host=192.168.0.200 port=5432 dbname=live3 user=postgres
[Output Connection]
dsn = port=5432 dbname=liveoutput user=postgres
[Table Filter]
schemas = schema_name = public
この基本的なテンプレートは、3つの接続live1 、live2
、およびlive3 を比較し、結果をliveoutput
データベースに出力します。 LiveCompareは、比較でpublic
スキーマのみを使用します。
比較の実行#
比較を実行するには、
livecompareを実行し、設定ファイルの名前を引数として渡します。
my_project.ini ファイルを作成した場合、次のコマンドを実行します。
livecompare my_project.ini
LiveCompareの実行中、N+1の進行状況バーが表示されます。Nはプロセス数です。設定でプロセス数を指定できます。最初の進行状況バーは、全体的な実行を示します。他の進行状況バーは、特定のプロセスによって処理されている現在のテーブルを示します。
各テーブルに表示される情報は、左から右に次のとおりです。
プロセス数
テーブル名
ステータス。現在のテーブルチャンクが後に続く比較ラウンドのIDです。
p1/1は、テーブルが分割されなかったことを意味します。setupのステータスは、テーブルが分析中であることを意味します行数の確認と必要に応じて分割。処理された行数
この比較ラウンドで検討される合計行数
経過時間
完了までの推定時間
1秒あたりのレコードの速度
プログラムの実行中に、 Ctrl-C を押していつでもキャンセルできます。次のようなメッセージが表示されます。
Manually stopping session 6... You can resume the session with:
livecompare my_project.ini 6
重要
LiveCompareがバックグラウンドで実行されている場合、または別のシェルで実行されている場合でも、ソフトに停止できます。セッションフォルダー内のマスタープロセスの`PID` この例では`lc_session_6` を`livemaster.pid` という名前のファイルに保持します。次に、 kill -2 <PID> を呼び出してソフトに停止できます。
次に、以前にキャンセルされたセッションをいつでも再開できます。例
livecompare my_project.ini 6
プログラムの終了時に、矛盾が検出されなかった場合、出力は次のとおりです。
Saved file lc_session_5/summary_20190514.out with the complete table summary.
You can also get the table summary by connecting to the output database and executing:
select * from livecompare.vw_table_summary where session_id = 5;
Elapsed time: 0:02:10.970954
Processed 3919015 rows in 6 tables using 3 processes.
Found 0 inconsistent rows in 0 tables.
不一致が見つかった場合、出力は次のようになります。
Comparison finished, waiting for remaining difference checks...
Outstanding differences:
+--------------+-------------------+-----------------+------------------+----------------------+-------------------+---------------------------+
| session_id | table_name | elapsed_time | num_total_rows | num_processed_rows | num_differences | max_num_ignored_columns |
|--------------+-------------------+-----------------+------------------+----------------------+-------------------+---------------------------|
| 6 | public.categories | 00:00:00.027864 | 18 | 18 | 4 | |
+--------------+-------------------+-----------------+------------------+----------------------+-------------------+---------------------------+
Saved file lc_session_6/summary_20200129.out with the complete table summary.
You can also get the table summary by connecting to the output database and executing:
select * from livecompare.vw_table_summary where session_id = 6;
Elapsed time: 0:00:50.149987
Processed 172718 rows in 8 tables from 3 connections using 2 workers.
Found 4 inconsistent rows in 1 tables.
Saved file lc_session_6/differences_20200129.out with the list of differences per table.
You can also get a list of differences per table with:
select * from livecompare.vw_differences where session_id = 6;
Too see more details on how LiveCompare determined the differences:
select * from livecompare.vw_consensus where session_id = 6;
Script lc_session_6/apply_on_the_first_20200129.sql was generated, which can be applied to the first connection and make it consistent with the majority of connections.
You can also get this script with:
select difference_fix_dml from livecompare.vw_difference_fix where session_id = 6 and connection_id = first;
再チェックモード#
PGD環境では、結果的な一貫性のためにレプリケーションが追いついたため、 PGDが見つけた相違は後で存在することはできません。いくつかの要因によっては、レプリケーションラグにより、LiveCompareが誤検出を報告する場合があります。
それを克服するために、後でレプリケーションラグが減少するか、データが既に追いついているときに、以前に見つかった差分のみに再チェックを手動で実行できます。この実行モードは recheck と呼ばれます。次のように実行できます。
livecompare my_project.ini 6 --recheck
このモードでは、LiveCompareは個別の再チェックログを生成し、
lc_session_X
ディレクトリに既に存在するすべてのレポートを更新します。
重要
compare または`recheck` で実行を再開する場合、LiveCompareは設定と接続属性がセッションが作成されたときと同じかどうかを確認します。発散が見つかった場合、実行を終了し、メッセージを表示します。
競合モード#
conflicts
モードでLiveCompareを実行するには、次のコマンドで呼び出します。
livecompare my_project.ini --conflicts
conflicts モードの詳細については、 EDB Postgres Distributed support を参照してください。
ドライランモード#
ドライランモードでは、実際に実行せずに比較を実行できます。このモードは、比較を実行する前に構成を確認するのに役立ちます。
たとえば、次のINIファイルがあるとします。
[General Settings]
logical_replication_mode = off
difference_tie_breakers = first
[First Connection]
dsn = dbname=testb
[Second Connection]
dsn = dbname=testdb2
[Third Connection]
dsn = dbname=testdb3
[Output Connection]
dsn = dbname=liveoutpu
[Table Filter]
schemas = schema_name = public
liveoutput のスペルミスのため、Output Connection
LiveCompareキャッシュデータベースの下のDSNが正しくないため、LiveCompareの実行は最初に次のエラーで失敗します。
Output connection is not reachable.
これを修正すると、出力接続に到達できるようになります。ただし、データ接続の1つだけが正しく設定されているとします。その場合、LiveCompareは次のエラーで再び失敗します。
At least two reachable connections are required.
Following connections are unreachable: first, third.
Following connections are reachable: second.
LiveCompareは、少なくとも2つのデータ接続が使用可能な状態で比較を開始できます。そこで、3番目の接続を修正します。しかし、LiveCompareは次の場合に失敗します。
A difference_tie_breakers host is not a reachable connection: first.
これは、例がdifference_tie_breakers = first
を設定し、タイブレーカーまたは真実のソースとして設定された接続が到達可能である必要があるために発生します。
これらの問題をすべて修正した後、LiveCompareは比較を開始できます。
ただし、比較を最初からセットアップする場合、LiveCompareが構成エラーで中断するかどうかを事前に確認できます。この種のその他のチェックはすべて、LiveCompareが実行する順序で表示されます。
これは、 --dry-run モードで行うことができます。
構成の問題のために発生するすべての実行中止を出力します。
到達可能かどうかを含む、いくつかの詳細を含む接続のリストを出力します。
テーブルフィルターを印刷します。
テーブルフィルタを適用した後、到達可能な接続に共通するテーブルのリストを出力します。
次に、 .ini
ファイルの例と、到達不能な接続に関するすべての構成エラーを指定した1つのサンプル出力を示します。
$ livecompare test.ini --dry-run
EnterpriseDB LiveCompare 2.2.0, dry-run mode
Output connection is not reachable.
At least two reachable connections are required.
Following connections are unreachable: first, third.
Following connections are reachable: second.
A difference_tie_breakers host is not a reachable connection: first.
Connections
+--------+--------------+-----------+---------------+---------------------+-----------+---------------+-------------------+-------------+
| ID | Technology | Version | PGD Version | Pglogical Version | Initial | Tie Breaker | Source of Truth | Reachable |
|--------+--------------+-----------+---------------+---------------------+-----------+---------------+-------------------+-------------|
| second | postgresql | 110015 | - | - | False | False | False | True |
| first | postgresql | - | - | - | False | True | False | False |
| third | postgresql | - | - | - | False | False | False | False |
| output | postgresql | - | - | - | - | - | - | False |
+--------+--------------+-----------+---------------+---------------------+-----------+---------------+-------------------+-------------+
Table Filter
publications =
replication_sets =
schemas = schema_name = public
tables =
Tables
+---------------------+--------------+-----------------+-------------------------+
| Table Name | Row Filter | Column Filter | Custom Comparison Key |
|---------------------+--------------+-----------------+-------------------------|
| public.categories | - | - | - |
| public.cust_hist | - | - | - |
| public.customers | - | - | - |
| public.departments | - | - | - |
| public.dept_emp | - | - | - |
| public.dept_manager | - | - | - |
| public.employees | - | - | - |
| public.inventory | - | - | - |
| public.orderlines | - | - | - |
| public.orders | - | - | - |
| public.products | - | - | - |
| public.reorder | - | - | - |
| public.salaries | - | - | - |
| public.tbl | - | - | - |
| public.titles | - | - | - |
+---------------------+--------------+-----------------+-------------------------+