github.com/1aal/kubeblocks@v0.0.0-20231107070852-e1c03e598921/docs/user_docs/kubeblocks-for-postgresql/cluster-management/restart-a-postgresql-cluster.md (about) 1 --- 2 title: Restart PostgreSQL cluster 3 description: How to restart a PostgreSQL cluster 4 keywords: [postgresql, restart] 5 sidebar_position: 4 6 sidebar_label: Restart 7 --- 8 9 10 # Restart PostgreSQL cluster 11 12 You can restart all pods of the cluster. When an exception occurs in a database, you can try to restart it. 13 14 :::note 15 16 Restarting a PostgreSQL cluster triggers a concurrent restart and the leader may change after the cluster restarts. 17 18 ::: 19 20 ## Steps 21 22 1. Restart a cluster. 23 24 You can use `kbcli` or create an OpsRequest to restart a cluster. 25 26 **Option 1.** (**Recommended**) Use kbcli 27 28 Configure the values of `components` and `ttlSecondsAfterSucceed` and run the command below to restart a specified cluster. 29 30 ```bash 31 kbcli cluster restart NAME --components="postgresql" \ 32 --ttlSecondsAfterSucceed=30 33 ``` 34 35 - `components` describes the component name that needs to be restarted. 36 - `ttlSecondsAfterSucceed` describes the time to live of an OpsRequest job after the restarting succeeds. 37 38 **Option 2.** Create an OpsRequest 39 40 Run the command below to apply the restarting to a cluster. 41 42 ```bash 43 kubectl apply -f - <<EOF 44 apiVersion: apps.kubeblocks.io/v1alpha1 45 kind: OpsRequest 46 metadata: 47 name: ops-restart 48 spec: 49 clusterRef: pg-cluster 50 type: Restart 51 restart: 52 - componentName: postgresql 53 EOF 54 ``` 55 56 2. Validate the restarting. 57 58 Run the command below to check the cluster status to check the restarting status. 59 60 ```bash 61 kbcli cluster list <name> 62 ``` 63 64 ***Example*** 65 66 ```bash 67 kbcli cluster list pg-cluster 68 > 69 NAME NAMESPACE CLUSTER-DEFINITION VERSION TERMINATION-POLICY STATUS CREATED-TIME 70 pg-cluster default postgresql-cluster postgresql-14.7.0 Delete Running Mar 03,2023 18:28 UTC+0800 71 ``` 72 73 * STATUS=Restarting: it means the cluster restart is in progress. 74 * STATUS=Running: it means the cluster has been restarted. 75