> ## Documentation Index
> Fetch the complete documentation index at: https://private-7c7dfe99-mintlify-8c05c8a2.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

> ローカルサーバー上に存在するレプリケートテーブルに関する情報と状態を含むシステムテーブルです。監視に役立ちます。

# system.replicas

<div id="description">
  ## 説明
</div>

ローカルサーバー上にあるレプリケートテーブルの情報と状態を保持しています。
このテーブルは監視に利用できます。Replicated\* テーブルごとに1行が含まれます。

<div id="columns">
  ## カラム
</div>

* `database` ([String](/ja/reference/data-types/index)) — データベース名。
* `table` ([String](/ja/reference/data-types/index)) — テーブル名。
* `uuid` ([UUID](/ja/reference/data-types/index)) — テーブル UUID。
* `engine` ([String](/ja/reference/data-types/index)) — テーブルエンジン名。
* `is_leader` ([UInt8](/ja/reference/data-types/index)) — レプリカがリーダーかどうか。複数のレプリカが同時にリーダーになることがあります。レプリカがリーダーになるのを防ぐには、merge\_tree 設定 `replicated&#95;can&#95;become&#95;leader` を使用できます。リーダーはバックグラウンドマージのスケジューリングを担当します。なお、書き込みは、リーダーかどうかに関係なく、利用可能で ZK にセッションを持つ任意のレプリカに対して実行できます。
* `can_become_leader` ([UInt8](/ja/reference/data-types/index)) — レプリカがリーダーになれるかどうか。
* `is_readonly` ([UInt8](/ja/reference/data-types/index)) — レプリカが read-only モードかどうか。このモードは、config に ClickHouse Keeper のセクションがない場合、ClickHouse Keeper でセッションを再初期化する際に不明なエラーが発生した場合、および ClickHouse Keeper でのセッション再初期化中に有効になります。
* `readonly_start_time` ([Nullable(DateTime)](/ja/reference/data-types/index)) — レプリカが readonly モードに移行した timestamp。レプリカが readonly モードでない場合は NULL。
* `is_session_expired` ([UInt8](/ja/reference/data-types/index)) — ClickHouse Keeper とのセッションが期限切れかどうか。基本的には `is_readonly` と同じです。
* `future_parts` ([UInt32](/ja/reference/data-types/index)) — まだ実行されていない INSERT やマージの結果として作成されるパーツ数。
* `parts_to_check` ([UInt32](/ja/reference/data-types/index)) — 検証待ちキュー内のデータパーツ数。パーツが破損している疑いがある場合、そのパーツは検証キューに追加されます。
* `zookeeper_name` ([String](/ja/reference/data-types/index)) — テーブルのメタデータが保存されている \[Zoo]Keeper クラスター (補助的なものを含む場合があります) の名前
* `zookeeper_path` ([String](/ja/reference/data-types/index)) — ClickHouse Keeper 内のテーブルデータへのパス。
* `replica_name` ([String](/ja/reference/data-types/index)) — ClickHouse Keeper 内のレプリカ名。同じテーブルの各レプリカはそれぞれ異なる名前を持ちます。
* `replica_path` ([String](/ja/reference/data-types/index)) — ClickHouse Keeper 内のレプリカデータへのパス。'zookeeper\_path/replicas/replica\_path' を連結したものと同じです。
* `columns_version` ([Int32](/ja/reference/data-types/index)) — テーブル構造のバージョン番号。ALTER が何回実行されたかを示します。レプリカ間でバージョンが異なる場合、一部のレプリカではまだすべての ALTER が実行されていないことを意味します。
* `queue_size` ([UInt32](/ja/reference/data-types/index)) — 実行待ちの操作キューのサイズ。操作には、データブロックの挿入、マージ、および一部のその他の操作が含まれます。通常は future\_parts と一致します。
* `inserts_in_queue` ([UInt32](/ja/reference/data-types/index)) — 実行が必要なデータブロックの挿入数。挿入は通常かなり速くレプリケーションされます。この数が大きい場合は、何らかの問題があることを意味します。
* `merges_in_queue` ([UInt32](/ja/reference/data-types/index)) — 実行待ちのマージ数。マージには時間がかかることがあるため、この値が長時間 0 より大きいままになる場合があります。
* `part_mutations_in_queue` ([UInt32](/ja/reference/data-types/index)) — 実行待ちの mutations 数。
* `queue_oldest_time` ([DateTime](/ja/reference/data-types/index)) — `queue_size` が 0 より大きい場合、最も古い操作がキューに追加された時刻を示します。
* `inserts_oldest_time` ([DateTime](/ja/reference/data-types/index)) — `queue_oldest_time` を参照してください。
* `merges_oldest_time` ([DateTime](/ja/reference/data-types/index)) — `queue_oldest_time` を参照してください。
* `part_mutations_oldest_time` ([DateTime](/ja/reference/data-types/index)) — `queue_oldest_time` を参照してください。
* `oldest_part_to_get` ([String](/ja/reference/data-types/index)) — レプリケーションキュー内で最も古い GET\_PARTS エントリから取得される、他のレプリカから fetch する対象のパーツ名。
* `oldest_part_to_merge_to` ([String](/ja/reference/data-types/index)) — レプリケーションキュー内で最も古い MERGE\_PARTS エントリから取得された、マージ後の結果パーツ名。
* `oldest_part_to_mutate_to` ([String](/ja/reference/data-types/index)) — レプリケーションキュー内で最も古い MUTATE\_PARTS エントリから取得された、変更後の結果パーツ名。
* `log_max_index` ([UInt64](/ja/reference/data-types/index)) — 一般アクティビティのログにおける最大エントリ番号。このカラムと後続の 3 つ (`log_pointer`、`total_replicas`、`active_replicas`) は、ClickHouse Keeper とのアクティブなセッションがある場合にのみ 0 以外の値になります。
* `log_pointer` ([UInt64](/ja/reference/data-types/index)) — レプリカが実行キューにコピーした一般アクティビティのログ内の最大エントリ番号に 1 を加えた値。log\_pointer が log\_max\_index より大幅に小さい場合は、何らかの問題があります。
* `last_queue_update` ([DateTime](/ja/reference/data-types/index)) — キューが最後に更新された日時。
* `absolute_delay` ([UInt64](/ja/reference/data-types/index)) — 現在のレプリカの遅延量 (秒) 。
* `total_replicas` ([UInt32](/ja/reference/data-types/index)) — このテーブルで認識されているレプリカの総数。
* `active_replicas` ([UInt32](/ja/reference/data-types/index)) — ClickHouse Keeper にセッションを持つこのテーブルのレプリカ数 (つまり、正常に動作しているレプリカ数) 。
* `lost_part_count` ([UInt64](/ja/reference/data-types/index)) — テーブル作成以降、全レプリカ合計でこのテーブル内で失われたデータパーツの数。値は ClickHouse Keeper に永続化され、増加することしかありません。
* `last_queue_update_exception` ([String](/ja/reference/data-types/index)) — キューに不正なエントリが含まれている場合の情報。特に、ClickHouse がバージョン間の後方互換性を破り、新しいバージョンによって書き込まれたログエントリを古いバージョンで解析できない場合に重要です。
* `zookeeper_exception` ([String](/ja/reference/data-types/index)) — ClickHouse Keeper から情報を取得中にエラーが発生した場合の、最後の例外メッセージ。
* `replica_is_active` ([Map(String, UInt8)](/ja/reference/data-types/index)) — レプリカ名と、そのレプリカがアクティブかどうかの対応を表す Map。

<div id="example">
  ## 例
</div>

```sql theme={null}
SELECT *
FROM system.replicas
WHERE table = 'test_table'
FORMAT Vertical
```

```text theme={null}
Query id: dc6dcbcb-dc28-4df9-ae27-4354f5b3b13e

Row 1:
───────
database:                    db
table:                       test_table
engine:                      ReplicatedMergeTree
is_leader:                   1
can_become_leader:           1
is_readonly:                 0
is_session_expired:          0
future_parts:                0
parts_to_check:              0
zookeeper_path:              /test/test_table
replica_name:                r1
replica_path:                /test/test_table/replicas/r1
columns_version:             -1
queue_size:                  27
inserts_in_queue:            27
merges_in_queue:             0
part_mutations_in_queue:     0
queue_oldest_time:           2021-10-12 14:48:48
inserts_oldest_time:         2021-10-12 14:48:48
merges_oldest_time:          1970-01-01 03:00:00
part_mutations_oldest_time:  1970-01-01 03:00:00
oldest_part_to_get:          1_17_17_0
oldest_part_to_merge_to:
oldest_part_to_mutate_to:
log_max_index:               206
log_pointer:                 207
last_queue_update:           2021-10-12 14:50:08
absolute_delay:              99
total_replicas:              5
active_replicas:             5
lost_part_count:             0
last_queue_update_exception:
zookeeper_exception:
replica_is_active:           {'r1':1,'r2':1}
```
