Command-line Usage

コンペアモード

プロジェクトで使用する/etc/livecompare/template*.ini をコピーし、必要に応じて調整します(以下のSettings セクションを参照)。

cp /etc/livecompare/template_basic.ini my_project.ini

livecompare my_project.ini

LiveCompareの実行中に、 N+1 進行状況バーが表示されます。 N はプロセス数です(設定でプロセス数を指定できます)。最初の進行状況バーは全体的な実行を示し、他の進行状況バーは特定のプロセスによって処理されている現在のテーブルを示します。

各テーブルに表示される情報は、左から右に次のとおりです。

  • プロセス数

  • テーブル名

  • ステータス。比較ラウンドの後に現在のテーブルチャンクが続く場合があります(p1/1 は、テーブルが分割されなかったことを意味します)。ステータスがsetup の場合、テーブルが分析されていることを意味します(行数を確認し、必要に応じて分割します)

  • 処理された行数

  • この比較ラウンドで考慮される合計行数

  • 経過時間

  • 推定所要時間

  • 1秒あたりのレコードの速度

テーブル分割が有効になっている場合(parallel_chunk_rows > 0 )、テーブルにparallel_chunk_rows 設定よりも多くの行がある場合、ハッシュ関数を使用して各行を考慮するジョブが決定されます。これにより、個々の比較が遅くなる可能性がありますが、比較全体では、指定されたテーブルの並列処理が役立つ場合があります。

プログラムの実行中、 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;

再チェックモード

BDR環境では、最終的な一貫性のためにレプリケーションが追いつくため、 BDRが検出した相違が後で存在しない場合があります。いくつかの要因によっては、レプリケーションラグが原因で LiveCompare が誤検出を報告する場合があります。

それを克服するために、レプリケーションの遅延が減少するか、データが既に追いついたときに、ユーザーは以前に見つかった違いのみで再チェックを実行できます。この実行モードは「再チェック」と呼ばれ、次のように実行できます。

livecompare my_project.ini 6 --recheck

このモードでは、LiveCompareは個別の再チェックログを生成し、 lc_session_X ディレクトリに既に存在するすべてのレポートを更新します。

重要 : compare を再開するか、recheck で実行する場合、LiveCompareは設定と接続の属性がセッションが作成されたときと同じかどうかを確認します。相違が見つかった場合、適切なメッセージで実行を終了します。

コンフリクトモード

LiveCompareをconflicts モードで実行するには、次のように呼び出す必要があります。

livecompare my_project.ini --conflicts

conflicts モードの詳細については、 BDRサポートの章を確認してください。

ドライランモード

たとえば、次の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

Output Connection (LiveCompareキャッシュデータベース)のDSNが正しくないため、LiveCompareの実行は最初に次のエラーで失敗します。

Output connection is not reachable.

これを修正した後、 Output Connection に到達できるようになりましたが、データ接続の1つだけが正しく設定されていると想像してください。 LiveCompareは次で再び失敗します。

At least two reachable connections are required.
Following connections are unreachable: first, third.
Following connections are reachable: second.

LiveCompareは、使用可能な少なくとも2つのデータ接続で比較を開始できます。したがって、先に進んでThird Connection を修正しますが、LiveCompareはまだ次のように失敗します。

A difference_tie_breakers host is not a reachable connection: first.

これは、 difference_tie_breakers = first を設定しており、タイブレーカーまたは信頼できるソースとして設定された接続に到達できる必要があるために発生します。

これらの問題をすべて修正した後、LiveCompareは比較を開始できます。

ただし、最初から比較を設定する場合、LiveCompareが構成エラーで中断するかどうかを事前に確認でき、それ以降の中断チェックはすべてLiveCompareによって実行される順序で表示されます。

これは--dry-run モードで可能です。

  • 構成の問題が原因で発生するすべての実行中止を出力します。

  • 接続のリストを、到達可能かどうかを含む詳細とともに出力します。

  • Table Filter を印刷します。

  • Table Filter を適用した後、到達可能な接続に共通するテーブルのリストを出力します。

上記の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   | BDR 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       | -            | -               | -                       |
+---------------------+--------------+-----------------+-------------------------+