|
| 1 | +--- |
| 2 | +title: Upgrade a Cluster Running PCR |
| 3 | +summary: Upgrade your primary and standby clusters when using PCR. |
| 4 | +toc: true |
| 5 | +docs_area: manage |
| 6 | +--- |
| 7 | + |
| 8 | +To safely perform a major version upgrade on a cluster with [**physical cluster replication (PCR)**]({% link {{ page.version.version }}/physical-cluster-replication-overview.md %}), you must upgrade the standby cluster before the primary cluster to avoid version incompatibility. You cannot replicate data from a cluster on a newer version to a cluster on an older version. |
| 9 | + |
| 10 | +This page describes the process for safely performing a major version upgrade on a pair of clusters that have PCR enabled. |
| 11 | + |
| 12 | +{{site.data.alerts.callout_info}} |
| 13 | +The entire standby cluster must be on the same major version as the primary cluster or a major version the primary cluster [can directly upgrade to]({% link {{ page.version.version }}/upgrade-cockroach-version.md %}#compatible-versions). Within the primary and standby CockroachDB clusters, the _system virtual cluster (system VC)_ must be at a cluster major version greater than or equal to the _application virtual cluster (app VC)_. |
| 14 | +{{site.data.alerts.end}} |
| 15 | + |
| 16 | +## Minor version upgrades |
| 17 | + |
| 18 | +Minor versions are not relevant when determining PCR compatibility. There is no need to consider PCR compatibility when upgrading to a specific minor version within a major version, so you can follow the normal [patch upgrade process]({% link {{ page.version.version }}/upgrade-cockroach-version.md %}#perform-a-patch-upgrade). |
| 19 | + |
| 20 | +## Upgrade primary and standby clusters |
| 21 | + |
| 22 | +To upgrade your primary and standby clusters: |
| 23 | + |
| 24 | +1. Ensure that the virtual clusters on both your primary cluster and your standby cluster are [finalized]({% link {{ page.version.version }}/upgrade-cockroach-version.md %}#finalize-a-major-version-upgrade-manually) on the current version before beginning the upgrade process. |
| 25 | + |
| 26 | +1. [Upgrade the binaries]({% link {{ page.version.version }}/upgrade-cockroach-version.md %}#perform-a-major-version-upgrade) on the standby cluster. On each node of the cluster, replace the binary and restart the node. |
| 27 | + |
| 28 | +1. [Connect]({% link {{ page.version.version }}/work-with-virtual-clusters.md %}#connect-to-the-system-virtual-cluster) to the standby cluster's system VC: |
| 29 | + |
| 30 | + {% include_cached copy-clipboard.html %} |
| 31 | + ~~~ shell |
| 32 | + cockroach sql --url \ |
| 33 | + "postgresql://root@{standby node IP or hostname}:26257?options=-ccluster=system&sslmode=verify-full" \ |
| 34 | + --certs-dir "certs" |
| 35 | + ~~~ |
| 36 | + |
| 37 | +1. [Finalize]({% link {{ page.version.version }}/upgrade-cockroach-version.md %}#finalize-a-major-version-upgrade-manually) the upgrade on the standby cluster's system VC: |
| 38 | + |
| 39 | + {% include_cached copy-clipboard.html %} |
| 40 | + ~~~ sql |
| 41 | + SET CLUSTER SETTING version '{VERSION}'; |
| 42 | + ~~~ |
| 43 | + |
| 44 | + {{site.data.alerts.callout_info}} |
| 45 | + If you need to [roll back]({% link {{ page.version.version }}/upgrade-cockroach-version.md %}#roll-back-a-major-version-upgrade) an upgrade, you must do so before the upgrade has been finalized. |
| 46 | + {{site.data.alerts.end}} |
| 47 | + |
| 48 | +1. Confirm that finalization is complete on the standby cluster's system VC: |
| 49 | +
|
| 50 | + {% include_cached copy-clipboard.html %} |
| 51 | + ~~~ sql |
| 52 | + > SHOW CLUSTER SETTING version; |
| 53 | + ~~~ |
| 54 | +
|
| 55 | +1. [Upgrade the binaries]({% link {{ page.version.version }}/upgrade-cockroach-version.md %}#perform-a-major-version-upgrade) on the primary cluster. On each node of the cluster, replace the binary and restart the node. |
| 56 | +
|
| 57 | +1. [Connect]({% link {{ page.version.version }}/work-with-virtual-clusters.md %}#connect-to-the-system-virtual-cluster) to the primary cluster's system VC: |
| 58 | + |
| 59 | + {% include_cached copy-clipboard.html %} |
| 60 | + ~~~ shell |
| 61 | + cockroach sql --url \ |
| 62 | + "postgresql://root@{primary node IP or hostname}:26257?options=-ccluster=system&sslmode=verify-full" \ |
| 63 | + --certs-dir "certs" |
| 64 | + ~~~ |
| 65 | + |
| 66 | +1. [Finalize]({% link {{ page.version.version }}/upgrade-cockroach-version.md %}#finalize-a-major-version-upgrade-manually) the upgrade on the primary cluster's system VC: |
| 67 | + |
| 68 | + {% include_cached copy-clipboard.html %} |
| 69 | + ~~~ sql |
| 70 | + SET CLUSTER SETTING version '{VERSION}'; |
| 71 | + ~~~ |
| 72 | + |
| 73 | + {{site.data.alerts.callout_info}} |
| 74 | + If you need to [roll back]({% link {{ page.version.version }}/upgrade-cockroach-version.md %}#roll-back-a-major-version-upgrade) an upgrade, you must do so before the upgrade has been finalized. Rolling back the upgrade on the primary cluster does not roll back the standby cluster. |
| 75 | + {{site.data.alerts.end}} |
| 76 | + |
| 77 | +1. Confirm that finalization is complete on the primary cluster's system VC: |
| 78 | +
|
| 79 | + {% include_cached copy-clipboard.html %} |
| 80 | + ~~~ sql |
| 81 | + > SHOW CLUSTER SETTING version; |
| 82 | + ~~~ |
| 83 | +
|
| 84 | +1. [Connect]({% link {{ page.version.version }}/work-with-virtual-clusters.md %}#connect-to-the-system-virtual-cluster) to the primary cluster's app VC: |
| 85 | + |
| 86 | + {% include_cached copy-clipboard.html %} |
| 87 | + ~~~ shell |
| 88 | + cockroach sql --url \ |
| 89 | + "postgresql://root@{primary node IP or hostname}:26257?options=-ccluster={app_virtual_cluster_name}&sslmode=verify-full" \ |
| 90 | + --certs-dir "certs" |
| 91 | + ~~~ |
| 92 | + |
| 93 | +1. [Finalize]({% link {{ page.version.version }}/upgrade-cockroach-version.md %}#finalize-a-major-version-upgrade-manually) the upgrade on the primary cluster's app VC: |
| 94 | + |
| 95 | + {% include_cached copy-clipboard.html %} |
| 96 | + ~~~ sql |
| 97 | + SET CLUSTER SETTING version '{VERSION}'; |
| 98 | + ~~~ |
| 99 | + |
| 100 | + Upgrading the primary cluster's app VC also upgrades the standby cluster's app VC, since it replicates from the primary. |
| 101 | + |
| 102 | +1. Confirm that finalization is complete on the primary cluster's app VC: |
| 103 | +
|
| 104 | + {% include_cached copy-clipboard.html %} |
| 105 | + ~~~ sql |
| 106 | + > SHOW CLUSTER SETTING version; |
| 107 | + ~~~ |
| 108 | +
|
| 109 | +## Upgrade reader VC |
| 110 | +
|
| 111 | +If you have a _reader virtual cluster (reader VC)_, you must drop and recreate it to upgrade after completing the main upgrade process on the primary and standby clusters. Follow these steps to upgrade your reader VC: |
| 112 | +
|
| 113 | +1. After upgrading the app VC on your primary cluster, wait for the replicated time to pass the time at which the upgrade completed. |
| 114 | +1. On the standby cluster, stop the reader VC service: |
| 115 | +
|
| 116 | + {% include_cached copy-clipboard.html %} |
| 117 | + ~~~ sql |
| 118 | + ALTER VIRTUAL CLUSTER <readervc-name> STOP SERVICE; |
| 119 | + ~~~ |
| 120 | +
|
| 121 | +1. Drop the reader VC: |
| 122 | +
|
| 123 | + {% include_cached copy-clipboard.html %} |
| 124 | + ~~~ sql |
| 125 | + DROP VIRTUAL CLUSTER <readervc-name>; |
| 126 | + ~~~ |
| 127 | +
|
| 128 | +1. On the standby cluster, re-create the reader VC: |
| 129 | +
|
| 130 | + {% include_cached copy-clipboard.html %} |
| 131 | + ~~~ sql |
| 132 | + ALTER VIRTUAL CLUSTER dest-system SET REPLICATION READ VIRTUAL CLUSTER; |
| 133 | + ~~~ |
| 134 | +
|
| 135 | +At this point, the reader VC is on the same version as the standby cluster. |
| 136 | +
|
| 137 | +## Failover and fast failback during upgrade |
| 138 | +
|
| 139 | +If needed, you can perform a [failover]({% link {{ page.version.version }}/failover-replication.md %}) while upgrading your clusters. |
| 140 | +
|
| 141 | +However, after performing a failover you cannot perform a [fast failback]({% link {{ page.version.version }}/failover-replication.md %}#failback) to the original primary cluster while the standby cluster version is newer than the primary cluster version. This is because you cannot replicate data from a cluster on a newer version to a cluster on an older version. |
0 commit comments