2023/04/04

PostgreSQL 14から15へのpg_upgrade時のメモ

何度もやっているものの、いつも確認するのでメモ。  

 

root@edo /data/lib/postgresql Tue 04 Apr 2023 09:30:26 PM JST JST(+0900)
# rm -fr /data/lib/postgresql/data15

root@edo /data/lib/postgresql Tue 04 Apr 2023 09:30:57 PM JST JST(+0900)
# cp -a /etc/postgresql-14/*.conf /etc/postgresql-15/

root@edo /data/lib/postgresql Tue 04 Apr 2023 09:31:01 PM JST JST(+0900)
# sudo -u postgres initdb15 -E UTF8 --locale=en_US.UTF-8 --lc-collate=C /data/lib/postgresql/data15
The files belonging to this database system will be owned by user "postgres".
This user must also own the server process.

The database cluster will be initialized with this locale configuration:
  provider:    libc
  LC_COLLATE:  C
  LC_CTYPE:    en_US.UTF-8
  LC_MESSAGES: en_US.UTF-8
  LC_MONETARY: en_US.UTF-8
  LC_NUMERIC:  en_US.UTF-8
  LC_TIME:     en_US.UTF-8
The default text search configuration will be set to "english".

Data page checksums are disabled.

creating directory /data/lib/postgresql/data15 ... ok
creating subdirectories ... ok
selecting dynamic shared memory implementation ... posix
selecting default max_connections ... 100
selecting default shared_buffers ... 128MB
selecting default time zone ... JST-09
creating configuration files ... ok
running bootstrap script ... ok
performing post-bootstrap initialization ... ok
syncing data to disk ... ok

initdb15: warning: enabling "trust" authentication for local connections
initdb15: hint: You can change this by editing pg_hba.conf or using the option -A, or --auth-local and --auth-host, the next time you run initdb.

Success. You can now start the database server using:

    pg_ctl -D /data/lib/postgresql/data15 -l logfile start


root@edo /data/lib/postgresql Tue 04 Apr 2023 09:31:08 PM JST JST(+0900)
# sudo -u postgres pg_upgrade15 -b /usr/lib64/postgresql-14/bin -B /usr/lib64/postgresql-15/bin -d /data/lib/postgresql/data14 -D /data/lib/postgresql/data15
Performing Consistency Checks
-----------------------------
Checking cluster versions                                   ok
Checking database user is the install user                  ok
Checking database connection settings                       ok
Checking for prepared transactions                          ok
Checking for system-defined composite types in user tables  ok
Checking for reg* data types in user tables                 ok
Checking for contrib/isn with bigint-passing mismatch       ok
Creating dump of global objects                             ok
Creating dump of database schemas
                                                            ok
Checking for presence of required libraries                 ok
Checking database user is the install user                  ok
Checking for prepared transactions                          ok
Checking for new cluster tablespace directories             ok

If pg_upgrade fails after this point, you must re-initdb the
new cluster before continuing.

Performing Upgrade
------------------
Analyzing all rows in the new cluster                       ok
Freezing all rows in the new cluster                        ok
Deleting files from new pg_xact                             ok
Copying old pg_xact to new server                           ok
Setting oldest XID for new cluster                          ok
Setting next transaction ID and epoch for new cluster       ok
Deleting files from new pg_multixact/offsets                ok
Copying old pg_multixact/offsets to new server              ok
Deleting files from new pg_multixact/members                ok
Copying old pg_multixact/members to new server              ok
Setting next multixact ID and offset for new cluster        ok
Resetting WAL archives                                      ok
Setting frozenxid and minmxid counters in new cluster       ok
Restoring global objects in the new cluster                 ok
Restoring database schemas in the new cluster
                                                            ok
Copying user relation files
                                                            ok
Setting next OID for new cluster                            ok
Sync data directory to disk                                 ok
Creating script to delete old cluster                       ok
Checking for extension updates                              ok

Upgrade Complete
----------------
Optimizer statistics are not transferred by pg_upgrade.
Once you start the new server, consider running:
    /usr/lib64/postgresql-15/bin/vacuumdb --all --analyze-in-stages

Running this script will delete the old cluster's data files:
    ./delete_old_cluster.sh

root@edo /data/lib/postgresql Tue 04 Apr 2023 09:31:18 PM JST JST(+0900)
# /etc/init.d/postgresql-15 start
 * /run/postgresql: creating directory
 * /run/postgresql: correcting mode
 * /run/postgresql: correcting owner
 * Starting PostgreSQL 15 ...                                                                                                                                         [ ok ]

root@edo /data/lib/postgresql Tue 04 Apr 2023 09:31:25 PM JST JST(+0900)
# /usr/lib64/postgresql-15/bin/vacuumdb --all --analyze-in-stages
vacuumdb: error: connection to server on socket "/run/postgresql/.s.PGSQL.5432" failed: FATAL:  role "root" does not exist

root@edo /data/lib/postgresql Tue 04 Apr 2023 09:32:16 PM JST JST(+0900)
# sudo -u postgres /usr/lib64/postgresql-15/bin/vacuumdb --all --analyze-in-stages
vacuumdb: processing database "postgres": Generating minimal optimizer statistics (1 target)
vacuumdb: processing database "template1": Generating minimal optimizer statistics (1 target)
vacuumdb: processing database "postgres": Generating medium optimizer statistics (10 targets)
vacuumdb: processing database "template1": Generating medium optimizer statistics (10 targets)
vacuumdb: processing database "postgres": Generating default (full) optimizer statistics
vacuumdb: processing database "template1": Generating default (full) optimizer statistics

root@edo /data/lib/postgresql Tue 04 Apr 2023 09:32:32 PM JST JST(+0900)
#

0 件のコメント:

コメントを投稿