17.6. Обновление кластера Postgres Pro Shardman #

В этом разделе описан процесс обновления базы данных Postgres Pro Shardman до более новой версии. Перед обновлением рекомендуется посмотреть Замечания к выпуску и найти те изменения, которые могут вызвать проблемы с вашим приложением. Если нет потенциальных проблем, можно перейти к обновлению.

Процесс обновления Postgres Pro Shardman состоит из нескольких шагов, которые необходимо выполнять последовательно:

  1. Обновить пакеты Postgres Pro Shardman.

  2. Перезапустить все службы Postgres Pro Shardman и экземпляры базы данных.

  3. Обновить расширение базы данных shardman.

17.6.1. Обновление пакетов #

17.6.1.1. Системы с пакетным менеджером APT #

Для обновления пакетов обычно достаточно выполнить следующую команду:

$ apt update && apt --only-upgrade install sdm-18-tools sdm-18-services postgrespro-sdm-18-contrib postgrespro-sdm-18-server

или обновить все пакеты в системе:

$ apt update && apt upgrade

Проверьте, что на каждом узле обновлены все пакеты:

$ dpkg -l | grep -E '(postgres pro|shardman)'

17.6.1.2. RPM-системы #

Для обновления пакетов обычно достаточно выполнить следующую команду:

$ yum update sdm-18-tools sdm-18-services postgrespro-sdm-18-contrib postgrespro-sdm-18-server

или обновить все пакеты в системе:

$ yum update

Проверьте, что на каждом узле обновлены все пакеты:

$ yum list --installed | grep -E  '(postgrespro|shardman)'

17.6.2. Перезапуск служб Postgres Pro Shardman и экземпляров баз данных #

После обновления пакетов необходимо перезапустить все службы кластера. Это можно сделать одной командой shardmanctl restart:

$ shardmanctl --cluster-name cluster0 --store-endpoints http://etcd1:2379,http://etcd2:2379,http://etcd3:2379 restart

Можно пропустить параметры --cluster-name и --store-endpoints, установив переменные среды SDM_CLUSTER_NAME и SDM_STORE_ENDPOINTS, как в примере ниже:

                    export SDM_STORE_ENDPOINTS=http://etcd1:2379,http://etcd2:2379,http://etcd3:2379
                    export SDM_CLUSTER_NAME=cluster0
                

17.6.3. Обновление расширения #

После перезапуска служб кластера следует обновить расширения сервера, выполнив следующую команду:

$ shardmanctl --cluster-name cluster0 --store-endpoints http://etcd1 :2379,http://etcd2:2379,http://etcd3:2379 upgrade

Если версия расширения shardman и версия библиотеки на сервере различаются, распределённые запросы и Postgres Pro Shardman DDL не будут работать.

Расширения Postgres Pro Shardman стараются предотвратить взаимодействие с несовместимым программным обеспечением. Несовместимости могут возникать по нескольким причинам: версия общей библиотеки shardman не соответствует версии расширения или версия удалённого сервера не соответствует версии локального сервера. В случае несовпадения версий расширения и библиотеки, Postgres Pro Shardman не сможет изменить свои метаданные и не будет выполнять операции над управляемыми объектами, пока расширение не будет обновлено. Если версия удалённого сервера не совпадает с версией локального сервера или они принадлежат разным кластерам, Postgres Pro Shardman не будет взаимодействовать с сервером.

17.6.4. Обновление данных с применением репликации #

Методы логической репликации также могут применяться для создания резервного сервера с обновлённой версией Postgres Pro Shardman. Это возможно благодаря тому, что логическая репликация поддерживается между разными основными версиями Postgres Pro Shardman. Резервный сервер может располагаться как на том же компьютере, так и на другом. Как только синхронизация с главным сервером (где работает старая версия Postgres Pro Shardman) будет завершена, можно сделать главным новый сервер, а старый экземпляр базы данных просто отключить. При таком переключении обновление возможно осуществить, прервав работу сервера всего на несколько секунд.

Этот вариант обновления можно осуществить, используя как встроенные средства логической репликации, так и внешние системы логической репликации, такие как pglogical, Slony, Londiste и Bucardo.

17.6. Upgrading a Postgres Pro Shardman Cluster #

This section discusses how to upgrade your database from one Postgres Pro Shardman release to a newer one. It is best to review the Release Notes before an upgrade and look for any changes that may cause issues for your application. You can proceed to upgrade if there are no potential issues.

The process of updating a Postgres Pro Shardman consists of several steps that must be performed sequentially:

  1. Upgrade Postgres Pro Shardman packages.

  2. Restart all Postgres Pro Shardman services and database instances.

  3. Upgrade database shardman extension.

17.6.1. Upgrade Packages #

17.6.1.1. APT-based Systems #

To upgrade packages, typically run the following command:

$ apt update && apt --only-upgrade install sdm-18-tools sdm-18-services postgrespro-sdm-18-contrib postgrespro-sdm-18-server

or upgrade all packages:

$ apt update && apt upgrade

Check that all packages have been updated on each node:

$ dpkg -l | grep -E  '(postgrespro|shardman)'

17.6.1.2. RPM-based systems #

To upgrade packages, typically run the following command:

$ yum update sdm-18-tools sdm-18-services postgrespro-sdm-18-contrib postgrespro-sdm-18-server

or upgrade all packages:

$ yum update

Check that all packages have been updated on each node:

$ yum list --installed | grep -E  '(postgrespro|shardman)'

17.6.2. Restart Postgres Pro Shardman Services and Database Instances #

After updating the packages, you need to restart all cluster services. It can be done with a single shardmanctl restart command:

$ shardmanctl --cluster-name cluster0 --store-endpoints http://etcd1:2379,http://etcd2:2379,http://etcd3:2379 restart

You can skip the --cluster-name and --store-endpoints options by setting the SDM_CLUSTER_NAME and SDM_STORE_ENDPOINTS environment variables as in the example below:

                    export SDM_STORE_ENDPOINTS=http://etcd1:2379,http://etcd2:2379,http://etcd3:2379
                    export SDM_CLUSTER_NAME=cluster0
                

17.6.3. Upgrade the Extension #

After restarting services of the cluster, you should update the server extensions by running the following command:

$ shardmanctl --cluster-name cluster0 --store-endpoints http://etcd1:2379,http://etcd2:2379,http://etcd3:2379 upgrade

In the case when the shardman extension version and server library version are different, distributed queries and Postgres Pro Shardman DDL will not work.

Postgres Pro Shardman extensions try to ensure that they do not communicate with incompatible software. Incompatibilities can arise for several reasons: the shardman shared library version does not match the extension version or the remote server version does not match the local server version. In case when the extension and library versions mismatch, Postgres Pro Shardman cannot modify its metadata and will refuse to perform operations on managed objects until the extension is updated. In case when the remote server version does not match the local server version or when they belong to different clusters, Postgres Pro Shardman will refuse to communicate with the server.

17.6.4. Upgrading Data via Replication #

It is also possible to use logical replication methods to create a standby server with the updated version of Postgres Pro Shardman. This is possible because logical replication supports replication between different major versions of Postgres Pro Shardman. The standby can be on the same computer or a different computer. Once it has synced up with the primary server (running the older version of Postgres Pro Shardman), you can switch primaries and make the standby the primary and shut down the older database instance. Such a switch-over results in only several seconds of downtime for an upgrade.

This method of upgrading can be performed using the built-in logical replication facilities as well as using external logical replication systems such as pglogical, Slony, Londiste, and Bucardo.

FAQ