診断と障害対応#

ツールに必要な機能の1つは、効率的な方法で問題をトラブルシューティングする機能です。 Barmanは、問題を診断およびトラブルシューティングする複数の方法を提供します。

通常、問題は barman check から返されたエラーまたは警告メッセージから発生しますが、他のソースから発生する場合もあります。

Barmanステータス#

barman status コマンドを使用して、特定のPostgresサーバーのステータスを確認できます。このコマンドは、PostgreSQLバージョン、現在のデータサイズ、PostgreSQLデータディレクトリ、現在のWAL、archiveコマンド、最後にアーカイブされたWAL、使用可能なバックアップの数など、サーバーのステータスの詳細ビューを提供します:

$ barman status pg16
Server pg16:
    Description: PostgreSQL 16 Database (via SSH)
    Active: True
    Disabled: False
    PostgreSQL version: 16.4
    Cluster state: in production
    Current data size: 31.9 MiB
    PostgreSQL Data directory: /var/lib/pgsql/16/data
    Current WAL segment: 000000010000003B00000010
    PostgreSQL 'archive_command' setting: barman-wal-archive barman_server pg16 %p
    Last archived WAL: 000000010000003B0000000F, at Mon Nov 18 07:54:54 2024
    Failures of WAL archiver: 0
    Passive node: False
    Retention policies: not enforced
    No. of available backups: 2
    First available backup: 20240911T085206
    Last available backup: 20240911T085736
    Minimum redundancy requirements: satisfied (2/0)

これは、サーバーの構成がbarmanサーバーの構成と連携するための良いツールです。

Barmanショーサーバー#

barman show-servers コマンドを使用して、バックアップ用に構成された特定のPostgresサーバーのすべての構成オプションと値をリストできます。

$ barman show-servers pg16
Server local16:
    active: True
    archive_command: barman-wal-archive barman-server pg16 %p
    archive_mode: on
    archive_timeout: 0
    archived_count: 1
    ...

Barman複製ステータス#

barman replication-status コマンドを使用して、特定のPostgresサーバーのレプリケーションステータスをすばやく確認できます。このコマンドは、レプリケーションのステータスの詳細なビューを提供します。

$ barman replication-status pg16
Status of streaming clients for server 'pg16':
Current LSN on master: 3B/10000148
Number of streaming clients: 1

1. Async WAL streamer
    Application name: barman_receive_wal
    Sync stage      : 3/3 Remote write
    Communication   : Unix domain socket
    User name       : barman
    Current state   : streaming (async)
    Replication slot: standby
    WAL sender PID  : 165959
    Started at      : 2024-11-18 07:49:01.837787+00:00
    Sent LSN   : 3B/10000148 (diff: 0 B)
    Write LSN  : 3B/10000148 (diff: 0 B)
    Flush LSN  : 3B/10000000 (diff: -328 B)

Barman診断#

barman diagnose コマンドは、構成されているすべてのサーバーのステータスに関する重要な情報を収集します。これは、 Barmanによってバックアップされている構成済みのPostgresサーバーの全体図です。

barman diagnose

diagnose コマンド出力はbarmanサーバーの完全なスナップショットであり、グローバル構成、SSHバージョン、Pythonバージョン、 rsync バージョン、PostgreSQLクライアントバージョン、すべてのサーバーの現在の構成とステータスなどの役立つ情報を提供します。

diagnose コマンドは、 Barmanインストールのステータスに関するグローバルビューを提供するため、問題のトラブルシューティングに非常に役立ちます。