Managing Sharded PostgreSQL shards
Note
The service is at the Preview stage.
Creating a shard
Sharded PostgreSQL shards are based on existing Yandex Managed Service for PostgreSQL clusters residing in the same folder and cloud network as the Sharded PostgreSQL cluster.
Warning
For the router to be able to connect to your shard hosts, the Managed Service for Sharded PostgreSQL cluster and the shards and must be in the same security group that allows incoming and outgoing TCP connections to port 6432.
- In the management console
, select the folder where you want to create a shard. - Navigate to the Yandex Managed Service for Sharded PostgreSQL service.
- Click the name of your cluster and select the Shards tab.
- Click Create shard.
- Specify a shard name and select the PostgreSQL cluster whose hosts will serve as data hosts in the Sharded PostgreSQL cluster.
- Click Create.
-
Get an IAM token for API authentication and put it into an environment variable:
export IAM_TOKEN="<IAM_token>" -
Call the Cluster.AddShard method, e.g., via the following cURL
request:curl \ --request POST \ --header "Authorization: Bearer $IAM_TOKEN" \ --header "Content-Type: application/json" \ --url 'https://mdb.api.cloud.yandex.net/managed-spqr/v1/clusters/<cluster_ID>/shards' \ --data '{ "shardSpec": { "shardName": "<shard_name>", "mdbPostgresql": { "clusterId": "<PostgreSQL_cluster_ID>" } } }'Where
mdbPostgresql.clusterIdis the Managed Service for PostgreSQL cluster ID within the shard. -
Check the server response to make sure your request was successful.
-
Get an IAM token for API authentication and put it into an environment variable:
export IAM_TOKEN="<IAM_token>" -
Clone the cloudapi
repository:cd ~/ && git clone --depth=1 https://github.com/yandex-cloud/cloudapiBelow, we assume that the repository contents reside in the
~/cloudapi/directory. -
Call the ClusterService.AddShard method, e.g., via the following gRPCurl
request:grpcurl \ -format json \ -import-path ~/cloudapi/ \ -import-path ~/cloudapi/third_party/googleapis/ \ -proto ~/cloudapi/yandex/cloud/mdb/spqr/v1/cluster_service.proto \ -rpc-header "Authorization: Bearer $IAM_TOKEN" \ -d '{ "cluster_id": <cluster_ID> "shard_spec": { "shard_name": "<shard_name>", "mdb_postgresql": { "cluster_id": "<PostgreSQL_cluster_ID>" } } }' \ mdb.api.cloud.yandex.net:443 \ yandex.cloud.mdb.spqr.v1.ClusterService.AddShardWhere
mdb_postgresql.cluster_idis the Managed Service for PostgreSQL cluster ID within the shard.
Deleting a shard
Deleting a Sharded PostgreSQL shard does not affect the Managed Service for PostgreSQL cluster.
- In the management console
, select the folder where you want to delete a shard. - Navigate to the Yandex Managed Service for Sharded PostgreSQL service.
- Click the name of your cluster and select the Shards tab.
- Find the shard you need in the list, click
in its row, and select Delete. - In the window that opens, click Delete.
-
Get an IAM token for API authentication and put it into an environment variable:
export IAM_TOKEN="<IAM_token>" -
Call the Cluster.DeleteShard method, e.g., via the following cURL
request:curl \ --request DELETE \ --header "Authorization: Bearer $IAM_TOKEN" \ --header "Content-Type: application/json" \ --url 'https://mdb.api.cloud.yandex.net/managed-spqr/v1/clusters/<cluster_ID>/shards/<shard_name>' -
Check the server response to make sure your request was successful.
-
Get an IAM token for API authentication and put it into an environment variable:
export IAM_TOKEN="<IAM_token>" -
Clone the cloudapi
repository:cd ~/ && git clone --depth=1 https://github.com/yandex-cloud/cloudapiBelow, we assume that the repository contents reside in the
~/cloudapi/directory. -
Call the ClusterService.DeleteShard method, e.g., via the following gRPCurl
request:grpcurl \ -format json \ -import-path ~/cloudapi/ \ -import-path ~/cloudapi/third_party/googleapis/ \ -proto ~/cloudapi/yandex/cloud/mdb/spqr/v1/cluster_service.proto \ -rpc-header "Authorization: Bearer $IAM_TOKEN" \ -d '{ "cluster_id": <cluster_ID>, "shard_name": "<shard_name>" }' \ mdb.api.cloud.yandex.net:443 \ yandex.cloud.mdb.spqr.v1.ClusterService.DeleteShard -
Check the server response to make sure your request was successful.