Important
Lakebase 自動スケールは、自動スケール コンピューティング、ゼロへのスケール、分岐、インスタント リストアを備えた最新バージョンの Lakebase です。 サポートされているリージョンについては、「 リージョンの可用性」を参照してください。 Lakebase プロビジョニング済みユーザーの場合は、「 Lakebase Provisioned」を参照してください。
このガイドでは、Lakebase エンドポイントの高可用性の有効化と管理について説明します。 高可用性のしくみとセカンダリ コンピューティング インスタンスとスタンドアロン読み取りレプリカの違いの背景については、「 高可用性」を参照してください。
高可用性を有効にする
高可用性を有効にするには、UI でコンピューティングの種類と HA 構成を設定するか、API を使用してエンドポイントの EndpointGroupSpec を構成します。
前提条件
- ゼロへのスケールは無効にする必要があります。 UI で、コンピューティング ドロワーの編集で [スケール]を 0 に [オフ] に設定します。 API を使用して、エンドポイント スペックで
no_suspension: trueを設定します (更新マスクとしてspec.suspensionを使用します)。
UI
プロジェクトを作成したら、プロジェクト ダッシュボードからプライマリ コンピューティング リンクをクリックして、コンピューティング ドロワーの編集を開きます。
コンピューティングの種類を [高可用性] に設定し、[高可用性] で [構成] を選択します。
- 2 (1 プライマリ、1 セカンダリ)
- 3 (プライマリ 1、セカンダリ 2)
- または 4 (1 プライマリ、3 セカンダリ) の合計コンピューティング インスタンス。
Lakebase は、異なる可用性ゾーンにセカンダリ コンピューティング インスタンスをプロビジョニングします。 すべてのコンピューティング インスタンスがアクティブになると、エンドポイントには自動フェールオーバーがあります。
Python SDK
from databricks.sdk import WorkspaceClient
from databricks.sdk.service.postgres import (
Endpoint, EndpointSpec, EndpointType, EndpointGroupSpec, FieldMask
)
w = WorkspaceClient()
endpoint_name = "projects/my-project/branches/production/endpoints/my-endpoint"
result = w.postgres.update_endpoint(
name=endpoint_name,
endpoint=Endpoint(
name=endpoint_name,
spec=EndpointSpec(
endpoint_type=EndpointType.ENDPOINT_TYPE_READ_WRITE,
group=EndpointGroupSpec(
min=2,
max=2,
enable_readable_secondaries=True
)
)
),
update_mask=FieldMask(field_mask=["spec.group"])
).wait()
print(f"Group size: {result.status.group.max}")
print(f"Host: {result.status.hosts.host}")
print(f"Read-only host: {result.status.hosts.read_only_host}")
CLI
databricks postgres update-endpoint \
projects/my-project/branches/production/endpoints/my-endpoint \
"spec.group" \
--json '{
"spec": {
"group": {
"min": 2,
"max": 2,
"enable_readable_secondaries": true
}
}
}'
curl
curl -X PATCH "$DATABRICKS_HOST/api/2.0/postgres/projects/my-project/branches/production/endpoints/my-endpoint?update_mask=spec.group" \
-H "Authorization: Bearer $DATABRICKS_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"name": "projects/my-project/branches/production/endpoints/my-endpoint",
"spec": {
"group": {
"min": 2,
"max": 2,
"enable_readable_secondaries": true
}
}
}' | jq
セカンダリ コンピューティング インスタンスへの読み取り専用アクセスを構成する
読み取り専用コンピューティング インスタンスへのアクセスの制限は、セカンダリ コンピューティング インスタンスが -ro 接続文字列 経由で読み取りトラフィックを処理するかどうかを制御します。
UI
- [コンピューティング] タブ で 、プライマリ コンピューティングの [編集 ] をクリックします。
- [ 高可用性] で、[ 読み取り専用コンピューティング インスタンスへのアクセスを許可する] チェック ボックスをオンまたはオフにします。
- [保存] をクリックします。
Python SDK
from databricks.sdk import WorkspaceClient
from databricks.sdk.service.postgres import (
Endpoint, EndpointSpec, EndpointType, EndpointGroupSpec, FieldMask
)
w = WorkspaceClient()
endpoint_name = "projects/my-project/branches/production/endpoints/my-endpoint"
# Get current group size first
current = w.postgres.get_endpoint(name=endpoint_name)
current_size = current.status.group.max
w.postgres.update_endpoint(
name=endpoint_name,
endpoint=Endpoint(
name=endpoint_name,
spec=EndpointSpec(
endpoint_type=EndpointType.ENDPOINT_TYPE_READ_WRITE,
group=EndpointGroupSpec(
min=current_size,
max=current_size,
enable_readable_secondaries=True # set False to disable
)
)
),
update_mask=FieldMask(field_mask=["spec.group.enable_readable_secondaries"])
).wait()
CLI
# Replace 2 with your current group size
databricks postgres update-endpoint \
projects/my-project/branches/production/endpoints/my-endpoint \
"spec.group.enable_readable_secondaries" \
--json '{
"spec": {
"group": {
"min": 2,
"max": 2,
"enable_readable_secondaries": true
}
}
}'
curl
# Replace 2 with your current group size
curl -X PATCH "$DATABRICKS_HOST/api/2.0/postgres/projects/my-project/branches/production/endpoints/my-endpoint?update_mask=spec.group.enable_readable_secondaries" \
-H "Authorization: Bearer $DATABRICKS_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"name": "projects/my-project/branches/production/endpoints/my-endpoint",
"spec": {
"group": {
"min": 2,
"max": 2,
"enable_readable_secondaries": true
}
}
}' | jq
Warnung
セカンダリ コンピューティング インスタンス1のみが有効になっており、読み取りアクセスが有効になっている場合、-ro 接続文字列 上のすべての読み取りトラフィックは、置換が追加されるまでフェールオーバー中に中断されます。 回復性のある読み取りアクセスを実現するには、読み取りアクセスが有効になっている 2 つ以上 のセカンダリ コンピューティング インスタンスを構成します。
セカンダリ コンピューティング インスタンスの数を変更する
UI
- [コンピューティング] タブ で 、プライマリ コンピューティングの [編集 ] をクリックします。
- [ 高可用性] で、ドロップダウンから新しい コンピューティング構成 を選択します (合計コンピューティング インスタンス数は 2、 3、または 4 )。
- [保存] をクリックします。
注
高可用性を無効にするには、コンピューティングの 種類 を [単一コンピューティング] に戻します。 これにより、すべてのセカンダリ コンピューティング インスタンスが削除され、エンドポイントが単一コンピューティング構成に戻ります。
Python SDK
from databricks.sdk import WorkspaceClient
from databricks.sdk.service.postgres import (
Endpoint, EndpointSpec, EndpointType, EndpointGroupSpec, FieldMask
)
w = WorkspaceClient()
endpoint_name = "projects/my-project/branches/production/endpoints/my-endpoint"
# Scale to 3 compute instances (1 primary + 2 secondaries)
w.postgres.update_endpoint(
name=endpoint_name,
endpoint=Endpoint(
name=endpoint_name,
spec=EndpointSpec(
endpoint_type=EndpointType.ENDPOINT_TYPE_READ_WRITE,
group=EndpointGroupSpec(min=3, max=3)
)
),
update_mask=FieldMask(field_mask=["spec.group.min", "spec.group.max"])
).wait()
CLI
# Scale to 3 compute instances (1 primary + 2 secondaries)
databricks postgres update-endpoint \
projects/my-project/branches/production/endpoints/my-endpoint \
"spec.group.min,spec.group.max" \
--json '{
"spec": {
"group": { "min": 3, "max": 3 }
}
}'
curl
curl -X PATCH "$DATABRICKS_HOST/api/2.0/postgres/projects/my-project/branches/production/endpoints/my-endpoint?update_mask=spec.group.min,spec.group.max" \
-H "Authorization: Bearer $DATABRICKS_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"name": "projects/my-project/branches/production/endpoints/my-endpoint",
"spec": {
"group": { "min": 3, "max": 3 }
}
}' | jq
高可用性の状態とロールを表示する
[ コンピューティング ] タブには、現在のロール、状態、アクセス レベルを持つ高可用性構成内のすべてのコンピューティング インスタンスが表示されます。
| コラム | 価値観 |
|---|---|
| 役割 | プライマリ、セカンダリ |
| 地位 | 開始状態、アクティブ |
| Access | 読み取り/書き込み (プライマリ)、読み取り専用 (アクセスが有効なセカンダリ コンピューティング インスタンス)、無効 (読み取りアクセス権のないセカンダリ コンピューティング インスタンス) |
プライマリ コンピューティング ヘッダーには、エンドポイント ID、自動スケール範囲、セカンダリカウント ( 8 ↔ 16 CU · 3 secondaries など) も表示されます。
接続文字列を取得する
UI
プライマリ コンピューティングで [ 接続 ] をクリックして、接続の詳細ダイアログを開きます。 [ コンピューティング] ドロップダウンには、高可用性エンドポイントの両方の接続オプションが一覧表示されます。
| コンピューティング オプション | 接続文字列 | 使用対象 |
|---|---|---|
Primary (name) ● Active |
{endpoint-id}.database.{region}.databricks.com |
すべての書き込みと読み取り/書き込み接続 |
Secondary (name) ● Active RO |
{endpoint-id}-ro.database.{region}.databricks.com |
第二の計算インスタンスへの負荷分散読み取り |
-ro 接続文字列は、読み取り専用コンピューティング インスタンスへのアクセス権が有効になっている場合にのみ使用できます。
Python SDK
from databricks.sdk import WorkspaceClient
w = WorkspaceClient()
endpoint = w.postgres.get_endpoint(
name="projects/my-project/branches/production/endpoints/my-endpoint"
)
print(f"Read/write host: {endpoint.status.hosts.host}")
print(f"Read-only host: {endpoint.status.hosts.read_only_host}")
CLI
databricks postgres get-endpoint \
projects/my-project/branches/production/endpoints/my-endpoint \
-o json | jq '{rw_host: .status.hosts.host, ro_host: .status.hosts.read_only_host}'
curl
curl -X GET "$DATABRICKS_HOST/api/2.0/postgres/projects/my-project/branches/production/endpoints/my-endpoint" \
-H "Authorization: Bearer $DATABRICKS_TOKEN" \
| jq '{rw_host: .status.hosts.host, ro_host: .status.hosts.read_only_host}'
完全な接続文字列リファレンスについては、接続文字列を参照してください。