binlogctl

Binlog制御 (略してbinlogctl ) は TiDB Binlogのコマンド ライン ツールです。 binlogctlを使用して、TiDB Binlogクラスターを管理できます。

binlogctlは次の目的で使用できます。

  • PumpやDrainerの状態を確認
  • PumpまたはDrainerを一時停止または閉じる
  • PumpやDrainerの異常状態への対応

以下は、その使用シナリオです。

  • データ複製中にエラーが発生したか、 PumpまたはDrainerの実行状態を確認する必要があります。
  • クラスターを維持するときは、 PumpまたはDrainerを一時停止または閉じる必要があります。
  • PumpまたはDrainerプロセスが異常終了し、ノードの状態が更新されていないか、予期しない状態です。これは、データ複製タスクに影響します。

binlogctlダウンロード

binlogctlはTiDB Toolkitに含まれています。 TiDB Toolkitをダウンロードするには、 TiDB ツールをダウンロードを参照してください。

説明

コマンド ライン パラメータ:

Usage of binlogctl:
  -V    prints version and exit
  -cmd string
        operator: "generate_meta", "pumps", "drainers", "update-pump", "update-drainer", "pause-pump", "pause-drainer", "offline-pump", "offline-drainer", "encrypt" (default "pumps")
  -data-dir string
        meta directory path (default "binlog_position")
  -node-id string
        id of node, used to update some nodes with operations update-pump, update-drainer, pause-pump, pause-drainer, offline-pump and offline-drainer
  -pd-urls string
        a comma separated list of PD endpoints (default "http://127.0.0.1:2379")
  -show-offline-nodes
        include offline nodes when querying pumps/drainers
  -ssl-ca string
        Path of file that contains list of trusted SSL CAs for connection with cluster components.
  -ssl-cert string
        Path of file that contains X509 certificate in PEM format for connection with cluster components.
  -ssl-key string
        Path of file that contains X509 key in PEM format for connection with cluster components.
  -state string
        set node's state, can be set to online, pausing, paused, closing or offline.
  -text string
        text to be encrypted when using encrypt command
  -time-zone Asia/Shanghai
        set time zone if you want to save time info in savepoint file; for example, Asia/Shanghai for CST time, `Local` for local time

コマンド例:

  • すべてのPumpノードまたはDrainerノードの状態を確認します。

    cmdpumpsまたはdrainersを設定します。例えば:

    bin/binlogctl -pd-urls=http://127.0.0.1:2379 -cmd pumps
    
    [2019/04/28 09:29:59.016 +00:00] [INFO] [nodes.go:48] ["query node"] [type=pump] [node="{NodeID: 1.1.1.1:8250, Addr: pump:8250, State: online, MaxCommitTS: 408012403141509121, UpdateTime: 2019-04-28 09:29:57 +0000 UTC}"]
    
    bin/binlogctl -pd-urls=http://127.0.0.1:2379 -cmd drainers
    
    [2019/04/28 09:29:59.016 +00:00] [INFO] [nodes.go:48] ["query node"] [type=drainer] [node="{NodeID: 1.1.1.1:8249, Addr: 1.1.1.1:8249, State: online, MaxCommitTS: 408012403141509121, UpdateTime: 2019-04-28 09:29:57 +0000 UTC}"]
    
  • PumpまたはDrainerを一時停止または閉じます。

    次のコマンドを使用して、サービスを一時停止または終了できます。

    指示説明
    一時停止ポンプPumpの一時停止bin/binlogctl -pd-urls=http://127.0.0.1:2379 -cmd pause-pump -node-id ip-127-0-0-1:8250
    一時停止ドレーナーDrainerを一時停止bin/binlogctl -pd-urls=http://127.0.0.1:2379 -cmd pause-drainer -node-id ip-127-0-0-1:8249
    オフラインポンプPumpを閉じるbin/binlogctl -pd-urls=http://127.0.0.1:2379 -cmd offline-pump -node-id ip-127-0-0-1:8250
    オフライン ドレインDrainerを閉じるbin/binlogctl -pd-urls=http://127.0.0.1:2379 -cmd offline-drainer -node-id ip-127-0-0-1:8249

    binlogctlは、HTTP 要求をPumpノードまたはDrainerノードに送信します。リクエストを受信した後、ノードはそれに応じて既存の手順を実行します。

  • 異常な状態のPumpまたはDrainerノードの状態を変更します。

    PumpノードまたはDrainerノードが正常に実行されている場合、または通常のプロセスで一時停止または閉じられている場合は、正常な状態です。異常な状態では、 PumpまたはDrainerノードはその状態を正しく維持できません。これは、データ複製タスクに影響します。この場合、 binlogctlを使用して状態情報を修復します。

    PumpノードまたはDrainerノードの状態を更新するには、 cmdupdate-pumpまたはupdate-drainerに設定します。状態はpausedまたはofflineです。例えば:

    bin/binlogctl -pd-urls=http://127.0.0.1:2379 -cmd update-pump -node-id ip-127-0-0-1:8250 -state paused
    

    ノート:

    PumpノードまたはDrainerノードが正常に実行されると、その状態が定期的に PD に更新されます。上記のコマンドは、PD に保存されているPumpまたはDrainerの状態を直接変更します。そのため、 PumpまたはDrainerノードが正常に動作している場合は、このコマンドを使用しないでください。詳細については、 TiDB Binlog FAQを参照してください。

製品
TiDB Cloud
TiDB
価格
PoC お問い合わせ
エコシステム
TiKV
TiFlash
OSS Insight
© 2023 PingCAP. All Rights Reserved.