SlideShare une entreprise Scribd logo
1  sur  20
Télécharger pour lire hors ligne
Rapid Upgrades With Pg_Upgrade

                                  BRUCE MOMJIAN,
                                   ENTERPRISEDB

                                       May, 2010




                               Abstract
   Pg_Upgrade allows migration between major releases of Postgres
   without a data dump/reload. This presentation explains how
   pg_upgrade works.

Creative Commons Attribution License               http://momjian.us/presentations
Traditional Postgres Upgrade Options



    pg_dump (logical dump)/restore
 




    Slony
 




Rapid Upgrades With Pg-Upgrade                          2
Why Upgrading Postgres Is Complex



    New features often require system table changes
 




    However, the internal data format rarely changes
 




Rapid Upgrades With Pg-Upgrade                         3
Why Pg_Upgrade



    Very fast upgrades
 




    Optionally no additional disk space
 




pg_upgrade installs new system tables while using data files from the
previous Postgres version.




Rapid Upgrades With Pg-Upgrade                                         4
How It Works: Initial Setup
                          Old Cluster                     New Cluster


                          System Tables                    System Tables

                  1            4          7       1             4          7

                  2            5          8       2             5          8

                  3            6          9       3             6          9

               pg_class                        pg_class


                           User Tables                      User Tables

                  10           16         22

                  11           17         23

                  12           18         24

                  13           19         25

                  14           20         26

                  15           21         27




                              clog                             clog


Rapid Upgrades With Pg-Upgrade                                                 5
Decouple New Clog Via Freezing
                          Old Cluster                     New Cluster


                          System Tables                    System Tables
                  1            4          7        1            4          7

                  2

                  3
                               5

                               6
                                          8

                                          9
                                                   2

                                                   3
                                                       Freeze   5

                                                                6
                                                                           8

                                                                           9

               pg_class                        pg_class


                           User Tables                      User Tables

                  10           16         22

                  11           17         23

                  12           18         24

                  13           19         25

                  14           20         26

                  15           21         27




                                               X                               X
                              clog                             clog


Rapid Upgrades With Pg-Upgrade                                                     6
Transfer Clog and XID
                             Old Cluster                           New Cluster


                             System Tables                          System Tables

                     1            4          7             1             4          7

                     2            5          8             2             5          8

                     3            6          9             3             6          9

                  pg_class                              pg_class


                              User Tables                            User Tables

                    10            16         22

                    11            17         23

                    12            18         24

                    13            19         25

                    14            20         26

                    15            21         27




                                 clog                                   clog


                              controldata         xid                controldata


Rapid Upgrades With Pg-Upgrade                                                          7
Get Schema Dump
                                                  pg_dumpall - -schema

                            Old Cluster                                             New Cluster


                            System Tables                                            System Tables

                    1            4           7                              1             4          7

                    2            5           8                              2             5          8

                    3            6           9                              3             6          9

                 pg_class                                                pg_class


                             User Tables                                              User Tables

                   10            16          22

                   11            17          23

                   12            18          24

                   13            19          25

                   14            20          26

                   15            21          27




                                clog                                                     clog


Rapid Upgrades With Pg-Upgrade                                                                           8
Restore Schema In New Cluster
                                                 pg_dumpall − −schema

                            Old Cluster                                            New Cluster


                            System Tables                                           System Tables
                    1            4          7                              1             4          7

                    2            5          8                              2             5          8

                    3            6          9                              3             6          9

                 pg_class                                               pg_class


                             User Tables                                             User Tables

                   10            16         22                            10             16         22

                   11            17         23                            11             17         23

                   12            18         24                            12             18         24

                   13            19         25                            13             19         25

                   14            20         26                            14             20         26

                   15            21         27                            15             21         27




                                clog                                                    clog


Rapid Upgrades With Pg-Upgrade                                                                           9
Copy User Heap/Index Files
                          Old Cluster                     New Cluster


                          System Tables                    System Tables
                  1            4          7       1             4          7

                  2            5          8       2             5          8

                  3            6          9       3             6          9

               pg_class                        pg_class


                           User Tables                      User Tables

                  10           16         22     10             16         22

                  11           17         23     11             17         23

                  12           18         24     12             18         24

                  13           19         25     13             19         25

                  14           20         26     14             20         26

                  15           21         27     15             21         27




                              clog                             clog


Rapid Upgrades With Pg-Upgrade                                                  10
Complete
                          Old Cluster                                New Cluster


                          System Tables                               System Tables
                  1            4          7                  1             4          7

                  2            5          8                  2             5          8

                  3            6          9                  3             6          9

               pg_class                                   pg_class


                           User Tables                                 User Tables

                  10           16         22                10             16         22

                  11           17         23                11             17         23

                  12           18         24                12             18         24

                  13           19         25                13             19         25

                  14           20         26                14             20         26

                  15           21         27                15             21         27




                              clog                                        clog


Rapid Upgrades With Pg-Upgrade                                                             11
How It Works: In Detail


    Check for cluster compatability
 




    – locale
    – encoding

    Use pg_dumpall to dump old cluster schema (no data)
 




    Freeze all new cluster rows (remove reference to clog entries)
 




    New cluster uses old xid counter value (see freeze above)
 




    – Set system table frozen xids to match the current xid

    Create new users/databases
 




    Collect cluster information
 




Rapid Upgrades With Pg-Upgrade                                       12
Install support functions that call internal backend functions
 




    Create schema in new cluster
 




    Copy or link files from old cluster to new cluster
 




    Warn about any remaining issues, like REINDEX requirements
 




Rapid Upgrades With Pg-Upgrade                                       13
Sample Run: Performing Consistency Checks

    Performing Consistency Checks
    -----------------------------
    Checking old data directory (/u/pgsql.old/data)          ok
    Checking old bin directory (/u/pgsql.old/bin)            ok
    Checking new data directory (/u/pgsql/data)              ok
    Checking new bin directory (/u/pgsql/bin)                ok
    Checking for /contrib/isn with bigint-passing mismatch   ok
    Checking for large objects                               ok
    Creating catalog dump                                    ok
    Checking for presence of required libraries              ok


    |   If pg_upgrade fails after this point, you must
    |   re-initdb the new cluster before continuing.
    |   You will also need to remove the ".old" suffix
    |   from /u/pgsql.old/data/global/pg_control.old.




Rapid Upgrades With Pg-Upgrade                                    14
Sample Run: Performing Migration

    Performing Migration
    --------------------
    Adding ".old" suffix to old global/pg_control   ok
    Analyzing all rows in the new cluster           ok
    Freezing all rows on the new cluster            ok
    Deleting new commit clogs                       ok
    Copying old commit clogs to new server          ok
    Setting next transaction id for new cluster     ok
    Resetting WAL archives                          ok
    Setting frozenxid counters in new cluster       ok
    Creating databases in the new cluster           ok
    Adding support functions to new cluster         ok
    Restoring database schema to new cluster        ok
    Removing support functions from new cluster     ok
    Restoring user relation files
                                                    ok
    Setting next oid for new cluster                ok
    Creating script to delete old cluster           ok
    Checking for large objects                      ok
Rapid Upgrades With Pg-Upgrade                           15
Sample Run: Completion



    Upgrade complete
    ----------------
    | Optimizer statistics is not transferred by pg_upgrade
    | so consider running:
    |       vacuumdb --all --analyze-only
    | on the newly-upgraded cluster.


    | Running this script will delete the old cluster’s data files:
    |       /u/postgres/pg_upgrade_output/delete_old_cluster.sh




Rapid Upgrades With Pg-Upgrade                                        16
Possible Data
                                  Format Changes


                         Change                    Conversion Method
       clog                                  none
       heap page header, including bitmask   convert to new page format on read
       tuple header, including bitmask       convert to new page format on read
       data value format                     create old data type in new cluster
       index page format                     reindex, or recreate index methods
       TOAST page format                     convert to new page format on read




Rapid Upgrades With Pg-Upgrade                                                     17
Migration Timings


                          Migration Method             Minutes
                          dump/restore                   300.0
                          dump with parallel restore     180.0
                          pg_upgrade in copy mode         44.0
                          pg_upgrade in link mode          0.7

                             Database size: 150GB, 850 tables

The last duration is 44 seconds.

                                                                   Timings courtesy of
                                                                 Stefan Kaltenbrunner
                                                                 (mastermind on IRC)




Rapid Upgrades With Pg-Upgrade                                                     18
PostgreSQL Version Compatibility


                                 New
                    Old            8.3                8.4         9.0+
                    8.3          pg_migrator   pg_migrator(1)   pg_upgrade
                    8.4              x          pg_migrator     pg_upgrade
                    9.0+             x               x          pg_upgrade

1. Unable to migrate composites, arrays, and enums.




Rapid Upgrades With Pg-Upgrade                                               19
Conclusion




                                              http://momjian.us/presentations
Rapid Upgrades With Pg-Upgrade                                            20

Contenu connexe

Similaire à Rapid upgrades with pg upgrade (Bruce Momjian)

Rapid Upgrades With Pg_Upgrade, Bruce Momjian
Rapid Upgrades With Pg_Upgrade, Bruce MomjianRapid Upgrades With Pg_Upgrade, Bruce Momjian
Rapid Upgrades With Pg_Upgrade, Bruce MomjianFuenteovejuna
 
Rapid Upgrades with Pg_Upgrade
Rapid Upgrades with Pg_UpgradeRapid Upgrades with Pg_Upgrade
Rapid Upgrades with Pg_UpgradeEDB
 
Pg upgrade employer
Pg upgrade employerPg upgrade employer
Pg upgrade employerEDB
 
Meeting the challenges of OLTP Big Data with Scylla
Meeting the challenges of OLTP Big Data with ScyllaMeeting the challenges of OLTP Big Data with Scylla
Meeting the challenges of OLTP Big Data with ScyllaScyllaDB
 
Image Recognition on Streaming Data
Image Recognition  on Streaming DataImage Recognition  on Streaming Data
Image Recognition on Streaming DataSingleStore
 
コミュニティ開発に参加しよう!
コミュニティ開発に参加しよう!コミュニティ開発に参加しよう!
コミュニティ開発に参加しよう!Takahiro Itagaki
 
Mongo db v3_deep_dive
Mongo db v3_deep_diveMongo db v3_deep_dive
Mongo db v3_deep_diveBryan Reinero
 

Similaire à Rapid upgrades with pg upgrade (Bruce Momjian) (7)

Rapid Upgrades With Pg_Upgrade, Bruce Momjian
Rapid Upgrades With Pg_Upgrade, Bruce MomjianRapid Upgrades With Pg_Upgrade, Bruce Momjian
Rapid Upgrades With Pg_Upgrade, Bruce Momjian
 
Rapid Upgrades with Pg_Upgrade
Rapid Upgrades with Pg_UpgradeRapid Upgrades with Pg_Upgrade
Rapid Upgrades with Pg_Upgrade
 
Pg upgrade employer
Pg upgrade employerPg upgrade employer
Pg upgrade employer
 
Meeting the challenges of OLTP Big Data with Scylla
Meeting the challenges of OLTP Big Data with ScyllaMeeting the challenges of OLTP Big Data with Scylla
Meeting the challenges of OLTP Big Data with Scylla
 
Image Recognition on Streaming Data
Image Recognition  on Streaming DataImage Recognition  on Streaming Data
Image Recognition on Streaming Data
 
コミュニティ開発に参加しよう!
コミュニティ開発に参加しよう!コミュニティ開発に参加しよう!
コミュニティ開発に参加しよう!
 
Mongo db v3_deep_dive
Mongo db v3_deep_diveMongo db v3_deep_dive
Mongo db v3_deep_dive
 

Plus de Ontico

One-cloud — система управления дата-центром в Одноклассниках / Олег Анастасье...
One-cloud — система управления дата-центром в Одноклассниках / Олег Анастасье...One-cloud — система управления дата-центром в Одноклассниках / Олег Анастасье...
One-cloud — система управления дата-центром в Одноклассниках / Олег Анастасье...Ontico
 
Масштабируя DNS / Артем Гавриченков (Qrator Labs)
Масштабируя DNS / Артем Гавриченков (Qrator Labs)Масштабируя DNS / Артем Гавриченков (Qrator Labs)
Масштабируя DNS / Артем Гавриченков (Qrator Labs)Ontico
 
Создание BigData-платформы для ФГУП Почта России / Андрей Бащенко (Luxoft)
Создание BigData-платформы для ФГУП Почта России / Андрей Бащенко (Luxoft)Создание BigData-платформы для ФГУП Почта России / Андрей Бащенко (Luxoft)
Создание BigData-платформы для ФГУП Почта России / Андрей Бащенко (Luxoft)Ontico
 
Готовим тестовое окружение, или сколько тестовых инстансов вам нужно / Алекса...
Готовим тестовое окружение, или сколько тестовых инстансов вам нужно / Алекса...Готовим тестовое окружение, или сколько тестовых инстансов вам нужно / Алекса...
Готовим тестовое окружение, или сколько тестовых инстансов вам нужно / Алекса...Ontico
 
Новые технологии репликации данных в PostgreSQL / Александр Алексеев (Postgre...
Новые технологии репликации данных в PostgreSQL / Александр Алексеев (Postgre...Новые технологии репликации данных в PostgreSQL / Александр Алексеев (Postgre...
Новые технологии репликации данных в PostgreSQL / Александр Алексеев (Postgre...Ontico
 
PostgreSQL Configuration for Humans / Alvaro Hernandez (OnGres)
PostgreSQL Configuration for Humans / Alvaro Hernandez (OnGres)PostgreSQL Configuration for Humans / Alvaro Hernandez (OnGres)
PostgreSQL Configuration for Humans / Alvaro Hernandez (OnGres)Ontico
 
Inexpensive Datamasking for MySQL with ProxySQL — Data Anonymization for Deve...
Inexpensive Datamasking for MySQL with ProxySQL — Data Anonymization for Deve...Inexpensive Datamasking for MySQL with ProxySQL — Data Anonymization for Deve...
Inexpensive Datamasking for MySQL with ProxySQL — Data Anonymization for Deve...Ontico
 
Опыт разработки модуля межсетевого экранирования для MySQL / Олег Брославский...
Опыт разработки модуля межсетевого экранирования для MySQL / Олег Брославский...Опыт разработки модуля межсетевого экранирования для MySQL / Олег Брославский...
Опыт разработки модуля межсетевого экранирования для MySQL / Олег Брославский...Ontico
 
ProxySQL Use Case Scenarios / Alkin Tezuysal (Percona)
ProxySQL Use Case Scenarios / Alkin Tezuysal (Percona)ProxySQL Use Case Scenarios / Alkin Tezuysal (Percona)
ProxySQL Use Case Scenarios / Alkin Tezuysal (Percona)Ontico
 
MySQL Replication — Advanced Features / Петр Зайцев (Percona)
MySQL Replication — Advanced Features / Петр Зайцев (Percona)MySQL Replication — Advanced Features / Петр Зайцев (Percona)
MySQL Replication — Advanced Features / Петр Зайцев (Percona)Ontico
 
Внутренний open-source. Как разрабатывать мобильное приложение большим количе...
Внутренний open-source. Как разрабатывать мобильное приложение большим количе...Внутренний open-source. Как разрабатывать мобильное приложение большим количе...
Внутренний open-source. Как разрабатывать мобильное приложение большим количе...Ontico
 
Подробно о том, как Causal Consistency реализовано в MongoDB / Михаил Тюленев...
Подробно о том, как Causal Consistency реализовано в MongoDB / Михаил Тюленев...Подробно о том, как Causal Consistency реализовано в MongoDB / Михаил Тюленев...
Подробно о том, как Causal Consistency реализовано в MongoDB / Михаил Тюленев...Ontico
 
Балансировка на скорости проводов. Без ASIC, без ограничений. Решения NFWare ...
Балансировка на скорости проводов. Без ASIC, без ограничений. Решения NFWare ...Балансировка на скорости проводов. Без ASIC, без ограничений. Решения NFWare ...
Балансировка на скорости проводов. Без ASIC, без ограничений. Решения NFWare ...Ontico
 
Перехват трафика — мифы и реальность / Евгений Усков (Qrator Labs)
Перехват трафика — мифы и реальность / Евгений Усков (Qrator Labs)Перехват трафика — мифы и реальность / Евгений Усков (Qrator Labs)
Перехват трафика — мифы и реальность / Евгений Усков (Qrator Labs)Ontico
 
И тогда наверняка вдруг запляшут облака! / Алексей Сушков (ПЕТЕР-СЕРВИС)
И тогда наверняка вдруг запляшут облака! / Алексей Сушков (ПЕТЕР-СЕРВИС)И тогда наверняка вдруг запляшут облака! / Алексей Сушков (ПЕТЕР-СЕРВИС)
И тогда наверняка вдруг запляшут облака! / Алексей Сушков (ПЕТЕР-СЕРВИС)Ontico
 
Как мы заставили Druid работать в Одноклассниках / Юрий Невиницин (OK.RU)
Как мы заставили Druid работать в Одноклассниках / Юрий Невиницин (OK.RU)Как мы заставили Druid работать в Одноклассниках / Юрий Невиницин (OK.RU)
Как мы заставили Druid работать в Одноклассниках / Юрий Невиницин (OK.RU)Ontico
 
Разгоняем ASP.NET Core / Илья Вербицкий (WebStoating s.r.o.)
Разгоняем ASP.NET Core / Илья Вербицкий (WebStoating s.r.o.)Разгоняем ASP.NET Core / Илья Вербицкий (WebStoating s.r.o.)
Разгоняем ASP.NET Core / Илья Вербицкий (WebStoating s.r.o.)Ontico
 
100500 способов кэширования в Oracle Database или как достичь максимальной ск...
100500 способов кэширования в Oracle Database или как достичь максимальной ск...100500 способов кэширования в Oracle Database или как достичь максимальной ск...
100500 способов кэширования в Oracle Database или как достичь максимальной ск...Ontico
 
Apache Ignite Persistence: зачем Persistence для In-Memory, и как он работает...
Apache Ignite Persistence: зачем Persistence для In-Memory, и как он работает...Apache Ignite Persistence: зачем Persistence для In-Memory, и как он работает...
Apache Ignite Persistence: зачем Persistence для In-Memory, и как он работает...Ontico
 
Механизмы мониторинга баз данных: взгляд изнутри / Дмитрий Еманов (Firebird P...
Механизмы мониторинга баз данных: взгляд изнутри / Дмитрий Еманов (Firebird P...Механизмы мониторинга баз данных: взгляд изнутри / Дмитрий Еманов (Firebird P...
Механизмы мониторинга баз данных: взгляд изнутри / Дмитрий Еманов (Firebird P...Ontico
 

Plus de Ontico (20)

One-cloud — система управления дата-центром в Одноклассниках / Олег Анастасье...
One-cloud — система управления дата-центром в Одноклассниках / Олег Анастасье...One-cloud — система управления дата-центром в Одноклассниках / Олег Анастасье...
One-cloud — система управления дата-центром в Одноклассниках / Олег Анастасье...
 
Масштабируя DNS / Артем Гавриченков (Qrator Labs)
Масштабируя DNS / Артем Гавриченков (Qrator Labs)Масштабируя DNS / Артем Гавриченков (Qrator Labs)
Масштабируя DNS / Артем Гавриченков (Qrator Labs)
 
Создание BigData-платформы для ФГУП Почта России / Андрей Бащенко (Luxoft)
Создание BigData-платформы для ФГУП Почта России / Андрей Бащенко (Luxoft)Создание BigData-платформы для ФГУП Почта России / Андрей Бащенко (Luxoft)
Создание BigData-платформы для ФГУП Почта России / Андрей Бащенко (Luxoft)
 
Готовим тестовое окружение, или сколько тестовых инстансов вам нужно / Алекса...
Готовим тестовое окружение, или сколько тестовых инстансов вам нужно / Алекса...Готовим тестовое окружение, или сколько тестовых инстансов вам нужно / Алекса...
Готовим тестовое окружение, или сколько тестовых инстансов вам нужно / Алекса...
 
Новые технологии репликации данных в PostgreSQL / Александр Алексеев (Postgre...
Новые технологии репликации данных в PostgreSQL / Александр Алексеев (Postgre...Новые технологии репликации данных в PostgreSQL / Александр Алексеев (Postgre...
Новые технологии репликации данных в PostgreSQL / Александр Алексеев (Postgre...
 
PostgreSQL Configuration for Humans / Alvaro Hernandez (OnGres)
PostgreSQL Configuration for Humans / Alvaro Hernandez (OnGres)PostgreSQL Configuration for Humans / Alvaro Hernandez (OnGres)
PostgreSQL Configuration for Humans / Alvaro Hernandez (OnGres)
 
Inexpensive Datamasking for MySQL with ProxySQL — Data Anonymization for Deve...
Inexpensive Datamasking for MySQL with ProxySQL — Data Anonymization for Deve...Inexpensive Datamasking for MySQL with ProxySQL — Data Anonymization for Deve...
Inexpensive Datamasking for MySQL with ProxySQL — Data Anonymization for Deve...
 
Опыт разработки модуля межсетевого экранирования для MySQL / Олег Брославский...
Опыт разработки модуля межсетевого экранирования для MySQL / Олег Брославский...Опыт разработки модуля межсетевого экранирования для MySQL / Олег Брославский...
Опыт разработки модуля межсетевого экранирования для MySQL / Олег Брославский...
 
ProxySQL Use Case Scenarios / Alkin Tezuysal (Percona)
ProxySQL Use Case Scenarios / Alkin Tezuysal (Percona)ProxySQL Use Case Scenarios / Alkin Tezuysal (Percona)
ProxySQL Use Case Scenarios / Alkin Tezuysal (Percona)
 
MySQL Replication — Advanced Features / Петр Зайцев (Percona)
MySQL Replication — Advanced Features / Петр Зайцев (Percona)MySQL Replication — Advanced Features / Петр Зайцев (Percona)
MySQL Replication — Advanced Features / Петр Зайцев (Percona)
 
Внутренний open-source. Как разрабатывать мобильное приложение большим количе...
Внутренний open-source. Как разрабатывать мобильное приложение большим количе...Внутренний open-source. Как разрабатывать мобильное приложение большим количе...
Внутренний open-source. Как разрабатывать мобильное приложение большим количе...
 
Подробно о том, как Causal Consistency реализовано в MongoDB / Михаил Тюленев...
Подробно о том, как Causal Consistency реализовано в MongoDB / Михаил Тюленев...Подробно о том, как Causal Consistency реализовано в MongoDB / Михаил Тюленев...
Подробно о том, как Causal Consistency реализовано в MongoDB / Михаил Тюленев...
 
Балансировка на скорости проводов. Без ASIC, без ограничений. Решения NFWare ...
Балансировка на скорости проводов. Без ASIC, без ограничений. Решения NFWare ...Балансировка на скорости проводов. Без ASIC, без ограничений. Решения NFWare ...
Балансировка на скорости проводов. Без ASIC, без ограничений. Решения NFWare ...
 
Перехват трафика — мифы и реальность / Евгений Усков (Qrator Labs)
Перехват трафика — мифы и реальность / Евгений Усков (Qrator Labs)Перехват трафика — мифы и реальность / Евгений Усков (Qrator Labs)
Перехват трафика — мифы и реальность / Евгений Усков (Qrator Labs)
 
И тогда наверняка вдруг запляшут облака! / Алексей Сушков (ПЕТЕР-СЕРВИС)
И тогда наверняка вдруг запляшут облака! / Алексей Сушков (ПЕТЕР-СЕРВИС)И тогда наверняка вдруг запляшут облака! / Алексей Сушков (ПЕТЕР-СЕРВИС)
И тогда наверняка вдруг запляшут облака! / Алексей Сушков (ПЕТЕР-СЕРВИС)
 
Как мы заставили Druid работать в Одноклассниках / Юрий Невиницин (OK.RU)
Как мы заставили Druid работать в Одноклассниках / Юрий Невиницин (OK.RU)Как мы заставили Druid работать в Одноклассниках / Юрий Невиницин (OK.RU)
Как мы заставили Druid работать в Одноклассниках / Юрий Невиницин (OK.RU)
 
Разгоняем ASP.NET Core / Илья Вербицкий (WebStoating s.r.o.)
Разгоняем ASP.NET Core / Илья Вербицкий (WebStoating s.r.o.)Разгоняем ASP.NET Core / Илья Вербицкий (WebStoating s.r.o.)
Разгоняем ASP.NET Core / Илья Вербицкий (WebStoating s.r.o.)
 
100500 способов кэширования в Oracle Database или как достичь максимальной ск...
100500 способов кэширования в Oracle Database или как достичь максимальной ск...100500 способов кэширования в Oracle Database или как достичь максимальной ск...
100500 способов кэширования в Oracle Database или как достичь максимальной ск...
 
Apache Ignite Persistence: зачем Persistence для In-Memory, и как он работает...
Apache Ignite Persistence: зачем Persistence для In-Memory, и как он работает...Apache Ignite Persistence: зачем Persistence для In-Memory, и как он работает...
Apache Ignite Persistence: зачем Persistence для In-Memory, и как он работает...
 
Механизмы мониторинга баз данных: взгляд изнутри / Дмитрий Еманов (Firebird P...
Механизмы мониторинга баз данных: взгляд изнутри / Дмитрий Еманов (Firebird P...Механизмы мониторинга баз данных: взгляд изнутри / Дмитрий Еманов (Firebird P...
Механизмы мониторинга баз данных: взгляд изнутри / Дмитрий Еманов (Firebird P...
 

Dernier

ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDropbox
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024The Digital Insurer
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...apidays
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...apidays
 
Cyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdfCyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdfOverkill Security
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024The Digital Insurer
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdfSandro Moreira
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobeapidays
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesrafiqahmad00786416
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Angeliki Cooney
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingEdi Saputra
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamUiPathCommunity
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Victor Rentea
 
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKSpring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKJago de Vreede
 

Dernier (20)

ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Cyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdfCyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdf
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKSpring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
 

Rapid upgrades with pg upgrade (Bruce Momjian)

  • 1. Rapid Upgrades With Pg_Upgrade BRUCE MOMJIAN, ENTERPRISEDB May, 2010 Abstract Pg_Upgrade allows migration between major releases of Postgres without a data dump/reload. This presentation explains how pg_upgrade works. Creative Commons Attribution License http://momjian.us/presentations
  • 2. Traditional Postgres Upgrade Options pg_dump (logical dump)/restore   Slony   Rapid Upgrades With Pg-Upgrade 2
  • 3. Why Upgrading Postgres Is Complex New features often require system table changes   However, the internal data format rarely changes   Rapid Upgrades With Pg-Upgrade 3
  • 4. Why Pg_Upgrade Very fast upgrades   Optionally no additional disk space   pg_upgrade installs new system tables while using data files from the previous Postgres version. Rapid Upgrades With Pg-Upgrade 4
  • 5. How It Works: Initial Setup Old Cluster New Cluster System Tables System Tables 1 4 7 1 4 7 2 5 8 2 5 8 3 6 9 3 6 9 pg_class pg_class User Tables User Tables 10 16 22 11 17 23 12 18 24 13 19 25 14 20 26 15 21 27 clog clog Rapid Upgrades With Pg-Upgrade 5
  • 6. Decouple New Clog Via Freezing Old Cluster New Cluster System Tables System Tables 1 4 7 1 4 7 2 3 5 6 8 9 2 3 Freeze 5 6 8 9 pg_class pg_class User Tables User Tables 10 16 22 11 17 23 12 18 24 13 19 25 14 20 26 15 21 27 X X clog clog Rapid Upgrades With Pg-Upgrade 6
  • 7. Transfer Clog and XID Old Cluster New Cluster System Tables System Tables 1 4 7 1 4 7 2 5 8 2 5 8 3 6 9 3 6 9 pg_class pg_class User Tables User Tables 10 16 22 11 17 23 12 18 24 13 19 25 14 20 26 15 21 27 clog clog controldata xid controldata Rapid Upgrades With Pg-Upgrade 7
  • 8. Get Schema Dump pg_dumpall - -schema Old Cluster New Cluster System Tables System Tables 1 4 7 1 4 7 2 5 8 2 5 8 3 6 9 3 6 9 pg_class pg_class User Tables User Tables 10 16 22 11 17 23 12 18 24 13 19 25 14 20 26 15 21 27 clog clog Rapid Upgrades With Pg-Upgrade 8
  • 9. Restore Schema In New Cluster pg_dumpall − −schema Old Cluster New Cluster System Tables System Tables 1 4 7 1 4 7 2 5 8 2 5 8 3 6 9 3 6 9 pg_class pg_class User Tables User Tables 10 16 22 10 16 22 11 17 23 11 17 23 12 18 24 12 18 24 13 19 25 13 19 25 14 20 26 14 20 26 15 21 27 15 21 27 clog clog Rapid Upgrades With Pg-Upgrade 9
  • 10. Copy User Heap/Index Files Old Cluster New Cluster System Tables System Tables 1 4 7 1 4 7 2 5 8 2 5 8 3 6 9 3 6 9 pg_class pg_class User Tables User Tables 10 16 22 10 16 22 11 17 23 11 17 23 12 18 24 12 18 24 13 19 25 13 19 25 14 20 26 14 20 26 15 21 27 15 21 27 clog clog Rapid Upgrades With Pg-Upgrade 10
  • 11. Complete Old Cluster New Cluster System Tables System Tables 1 4 7 1 4 7 2 5 8 2 5 8 3 6 9 3 6 9 pg_class pg_class User Tables User Tables 10 16 22 10 16 22 11 17 23 11 17 23 12 18 24 12 18 24 13 19 25 13 19 25 14 20 26 14 20 26 15 21 27 15 21 27 clog clog Rapid Upgrades With Pg-Upgrade 11
  • 12. How It Works: In Detail Check for cluster compatability   – locale – encoding Use pg_dumpall to dump old cluster schema (no data)   Freeze all new cluster rows (remove reference to clog entries)   New cluster uses old xid counter value (see freeze above)   – Set system table frozen xids to match the current xid Create new users/databases   Collect cluster information   Rapid Upgrades With Pg-Upgrade 12
  • 13. Install support functions that call internal backend functions   Create schema in new cluster   Copy or link files from old cluster to new cluster   Warn about any remaining issues, like REINDEX requirements   Rapid Upgrades With Pg-Upgrade 13
  • 14. Sample Run: Performing Consistency Checks Performing Consistency Checks ----------------------------- Checking old data directory (/u/pgsql.old/data) ok Checking old bin directory (/u/pgsql.old/bin) ok Checking new data directory (/u/pgsql/data) ok Checking new bin directory (/u/pgsql/bin) ok Checking for /contrib/isn with bigint-passing mismatch ok Checking for large objects ok Creating catalog dump ok Checking for presence of required libraries ok | If pg_upgrade fails after this point, you must | re-initdb the new cluster before continuing. | You will also need to remove the ".old" suffix | from /u/pgsql.old/data/global/pg_control.old. Rapid Upgrades With Pg-Upgrade 14
  • 15. Sample Run: Performing Migration Performing Migration -------------------- Adding ".old" suffix to old global/pg_control ok Analyzing all rows in the new cluster ok Freezing all rows on the new cluster ok Deleting new commit clogs ok Copying old commit clogs to new server ok Setting next transaction id for new cluster ok Resetting WAL archives ok Setting frozenxid counters in new cluster ok Creating databases in the new cluster ok Adding support functions to new cluster ok Restoring database schema to new cluster ok Removing support functions from new cluster ok Restoring user relation files ok Setting next oid for new cluster ok Creating script to delete old cluster ok Checking for large objects ok Rapid Upgrades With Pg-Upgrade 15
  • 16. Sample Run: Completion Upgrade complete ---------------- | Optimizer statistics is not transferred by pg_upgrade | so consider running: | vacuumdb --all --analyze-only | on the newly-upgraded cluster. | Running this script will delete the old cluster’s data files: | /u/postgres/pg_upgrade_output/delete_old_cluster.sh Rapid Upgrades With Pg-Upgrade 16
  • 17. Possible Data Format Changes Change Conversion Method clog none heap page header, including bitmask convert to new page format on read tuple header, including bitmask convert to new page format on read data value format create old data type in new cluster index page format reindex, or recreate index methods TOAST page format convert to new page format on read Rapid Upgrades With Pg-Upgrade 17
  • 18. Migration Timings Migration Method Minutes dump/restore 300.0 dump with parallel restore 180.0 pg_upgrade in copy mode 44.0 pg_upgrade in link mode 0.7 Database size: 150GB, 850 tables The last duration is 44 seconds. Timings courtesy of Stefan Kaltenbrunner (mastermind on IRC) Rapid Upgrades With Pg-Upgrade 18
  • 19. PostgreSQL Version Compatibility New Old 8.3 8.4 9.0+ 8.3 pg_migrator pg_migrator(1) pg_upgrade 8.4 x pg_migrator pg_upgrade 9.0+ x x pg_upgrade 1. Unable to migrate composites, arrays, and enums. Rapid Upgrades With Pg-Upgrade 19
  • 20. Conclusion http://momjian.us/presentations Rapid Upgrades With Pg-Upgrade 20