PostgreSQLのシーケンスで増やす値を1から2に変更する

ap2=# \d campaignlist_id_seq
                    Sequence "public.campaignlist_id_seq"
  Type  | Start | Minimum |       Maximum       | Increment | Cycles? | Cache
--------+-------+---------+---------------------+-----------+---------+-------
 bigint |     1 |       1 | 9223372036854775807 |         1 | no      |     1
Owned by: public.campaignlist.id

ap2=# ALTER SEQUENCE public.campaignlist_id_seq INCREMENT 2;
ALTER SEQUENCE
ap2=# \d campaignlist_id_seq
                    Sequence "public.campaignlist_id_seq"
  Type  | Start | Minimum |       Maximum       | Increment | Cycles? | Cache
--------+-------+---------+---------------------+-----------+---------+-------
 bigint |     1 |       1 | 9223372036854775807 |         2 | no      |     1
Owned by: public.campaignlist.id

ドキュメント

.pgpassの書式

pg_basebackupコマンドに--write-recovery-confオプションをつけて実行すると、postgresql.auto.confが生成されます。
その中身は
# Do not edit this file manually!
# It will be overwritten by the ALTER SYSTEM command.
primary_conninfo = 'user=[ユーザー名] passfile=''/var/lib/pgsql/.pgpass'' channel_binding=prefer host=[ホスト名] port=5432 sslmode=prefer sslcompression=0 sslsni=1 ssl_min_protocol_version=TLSv1.2 gssencmode=prefer krbsrvname=postgres target_session_attrs=any'
のようになっています。
pg_basebackupをするためのユーザーがバックアップ元に接続するためにパスワードが必要な場合、そのパスワードを.pgpassに書くことができます。
.pgpassの書式は、34.16. パスワードファイルの通りです。
具体的には
erogamescape.dyndns.org:5432:replication:[ユーザー名]:[パスワード]
となります。
また、.pgpassの権限は600でなければなりません。
600でないとログにエラーが出力されます。
WARNING: password file "/var/lib/pgsql/.pgpass" has group or world access; permissions should be u=rw (0600) or less


PostgreSQL13からpg_basebackupコマンドの進捗を確認できるようになりました。


PostgreSQL13からpg_basebackupコマンドの進捗をバックアップ元でも確認できるようになりました。

pg_basebackupコマンドの実行の際に-Pオプションをつけて実行すれば、実行の進捗を確認できるので、バックアップ元で進捗状況を確認できなくてもいいとは思うのですが、-Pをつけわすれて実行してしまった場合、
pg_basebackup: starting background WAL receiver
と表示されてから何も応答がなくて、いつバックアップが終わるのかわからなくなった…というときに重宝します。
バックアップ元で
[postgres@sakura 15]$ psql
psql (15.1)
Type "help" for help.

postgres=# \x
Expanded display is on.
postgres=#  SELECT * FROM pg_stat_progress_basebackup;
(0 rows)
とSELECT * FROM pg_stat_progress_basebackup;で確認できます。
バックアップ先でpg_basebackupコマンドを実行してから、バックアップ元でSELECT * FROM pg_stat_progress_basebackup;を実行すると
Sun 13 Nov 2022 11:45:38 AM JST (every 2s)

-[ RECORD 1 ]--------+---------------------------------
pid                  | 2700275
phase                | waiting for checkpoint to finish
backup_total         | 
backup_streamed      | 0
tablespaces_total    | 0
tablespaces_streamed | 0
と進捗が表示されます。
このとき
postgres=#  \watch
とwatchコマンドを実行すると、SELECT * FROM pg_stat_progress_basebackup;を淡々と実行してくれます。
実行の様子は以下の通りです。
Sun 13 Nov 2022 11:45:54 AM JST (every 2s)

-[ RECORD 1 ]--------+---------------------------------
pid                  | 2700275
phase                | waiting for checkpoint to finish
backup_total         | 
backup_streamed      | 0
tablespaces_total    | 0
tablespaces_streamed | 0

Sun 13 Nov 2022 11:45:56 AM JST (every 2s)

-[ RECORD 1 ]--------+-------------------------
pid                  | 2700275
phase                | streaming database files
backup_total         | 13075364864
backup_streamed      | 15485440
tablespaces_total    | 1
tablespaces_streamed | 0

Sun 13 Nov 2022 11:45:58 AM JST (every 2s)

-[ RECORD 1 ]--------+-------------------------
pid                  | 2700275
phase                | streaming database files
backup_total         | 13075364864
backup_streamed      | 36467200
tablespaces_total    | 1
tablespaces_streamed | 0

Sun 13 Nov 2022 11:46:00 AM JST (every 2s)

-[ RECORD 1 ]--------+-------------------------
pid                  | 2700275
phase                | streaming database files
backup_total         | 13075364864
backup_streamed      | 57504768
tablespaces_total    | 1
tablespaces_streamed | 0

[参考文書]
PostgreSQL13 検証レポート

standby.signalを作成したのにPostgreSQLがスタンバイモード(standby mode)で起動しない

standby.signalを作成したのにPostgreSQLがスタンバイモード(standby mode)で起動しませんでした。
[postgres@localhost data]$ touch standby.signal
[postgres@localhost data]$ exit ログアウト
[root@localhost data]# systemctl start postgresql-15.service [root@localhost data]# systemctl status postgresql-15.service ● postgresql-15.service - PostgreSQL 15 database server Loaded: loaded (/usr/lib/systemd/system/postgresql-15.service; disabled; vendor preset: disabled) Active: active (running) since Fri 2022-10-21 23:47:47 JST; 3min 0s ago Docs: https://www.postgresql.org/docs/15/static/ Process: 9282 ExecStartPre=/usr/pgsql-15/bin/postgresql-15-check-db-dir ${PGDATA} (code=exited, status=0/SUCCESS) Main PID: 9288 (postmaster) Tasks: 7 (limit: 49457) Memory: 92.7M CGroup: /system.slice/postgresql-15.service ├─9288 /usr/pgsql-15/bin/postmaster -D /var/lib/pgsql/15/data/ ├─9289 postgres: logger ├─9290 postgres: checkpointer ├─9291 postgres: background writer ├─9293 postgres: walwriter ├─9294 postgres: autovacuum launcher └─9295 postgres: logical replication launcher
[root@localhost data]# su - postgres [postgres@localhost data]$ /usr/pgsql-15/bin/pg_ctl -p 5433 promote pg_ctl: サーバーを昇格できません; サーバーはスタンバイモードではありません
PostgreSQL 12の新機能をいくつか試してみたの「recovery.confのpostgresql.confへの統合」を拝見したところ、
$ ls -l rep/data/standby.signal
-rw------- 1 kazu kazu 0 12月 18 14:43 rep/data/standby.signal

と、standby.signalの権限が600でしたので、600にしたところスタンバイモードで立ち上がりました。
[postgres@localhost data]$ ls -l standby.signal
-rw-r--r-- 1 postgres postgres 0 10月 21 23:50 standby.signal
[postgres@localhost data]$ chmod 600 standby.signal
[root@localhost data]# systemctl start postgresql-15.service
[root@localhost data]# systemctl status postgresql-15.service
● postgresql-15.service - PostgreSQL 15 database server
   Loaded: loaded (/usr/lib/systemd/system/postgresql-15.service; disabled; vendor preset: disabled)
   Active: active (running) since Fri 2022-10-21 23:53:44 JST; 2s ago
     Docs: https://www.postgresql.org/docs/15/static/
  Process: 9950 ExecStartPre=/usr/pgsql-15/bin/postgresql-15-check-db-dir ${PGDATA} (code=exited, status=0/SUCCESS)
 Main PID: 9955 (postmaster)
    Tasks: 6 (limit: 49457)
   Memory: 93.0M
   CGroup: /system.slice/postgresql-15.service
           ├─9955 /usr/pgsql-15/bin/postmaster -D /var/lib/pgsql/15/data/
           ├─9957 postgres: logger
           ├─9958 postgres: checkpointer
           ├─9959 postgres: background writer
           ├─9960 postgres: startup recovering 0000000100000005000000BD
           └─9961 postgres: walreceiver


[解決]libpq5.x86_64 15.0-42PGDG.rhel8 pgdg-common がインストールできない

libpq5.x86_64 15.0-42PGDG.rhel8 pgdg-common がインストールできません。

[環境]
# cat /etc/almalinux-release
AlmaLinux release 8.6 (Sky Tiger)

# cat /etc/yum.repos.d/pgdg-redhat-all.repo
[pgdg-common]
name=PostgreSQL common RPMs for RHEL / Rocky $releasever - $basearch
baseurl=https://download.postgresql.org/pub/repos/yum/common/redhat/rhel-$releasever-$basearch
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-PGDG
repo_gpgcheck = 1
[やったこと]
# dnf check-update
Last metadata expiration check: 1:34:46 ago on Fri 21 Oct 2022 07:06:30 AM JST.

libpq5.x86_64                                         15.0-42PGDG.rhel8                                          pgdg-common
# dnf update
Last metadata expiration check: 1:34:22 ago on Fri 21 Oct 2022 07:06:30 AM JST.
Error:
 Problem: package perl-DBD-Pg-3.7.4-4.module_el8.6.0+2829+05d1a4fc.x86_64 requires libpq.so.5(RHPG_9.6)(64bit), but none of the providers can be installed
  - cannot install both libpq5-15.0-42PGDG.rhel8.x86_64 and libpq5-14.5-42PGDG.rhel8.x86_64
  - package libpq5-15.0-42PGDG.rhel8.x86_64 obsoletes libpq provided by libpq-13.5-1.el8.x86_64
  - cannot install the best update candidate for package perl-DBD-Pg-3.7.4-4.module_el8.6.0+2829+05d1a4fc.x86_64
  - cannot install the best update candidate for package libpq5-14.5-42PGDG.rhel8.x86_64
(try to add '--allowerasing' to command line to replace conflicting packages or '--skip-broken' to skip uninstallable packages or '--nobest' to use not only best candidate packages)
# rpm -qa | grep perl-DBD-Pg
perl-DBD-Pg-3.7.4-4.module_el8.6.0+2829+05d1a4fc.x86_64
# yum info perl-DBD-Pg
メタデータの期限切れの最終確認: 2:11:46 時間前の 2022年10月18日 02時55分28秒 に実施しました。
インストール済みパッケージ
名前         : perl-DBD-Pg
バージョン   : 3.7.4
リリース     : 4.module_el8.6.0+2829+05d1a4fc
Arch         : x86_64
サイズ       : 567 k
ソース       : perl-DBD-Pg-3.7.4-4.module_el8.6.0+2829+05d1a4fc.src.rpm
リポジトリー : @System
repo から    : appstream
概要         : A PostgreSQL interface for perl
URL          : http://search.cpan.org/dist/DBD-Pg/
ライセンス   : GPLv2+ or Artistic
説明         : DBD::Pg is a Perl module that works with the DBI module to provide access
             : to PostgreSQL databases.
perl-DBD-Pg-3.7.4-4.module_el8.6.0+2829+05d1a4fc.x86_64にはlibpq.so.5(RHPG_9.6)(64bit)が必要だけど、インストールしようとしているlibpq5.x86_64 15.0-42PGDG.rhel8はNGなのだろうと思います。
今は、libpq5-14.5-42PGDG.rhel8.x86_64が入っています。
どうすればいいのかわかりません…
いつか、libpq5.x86_64 15.0-42PGDG.rhel8に対応した、perl-DBD-Pgがリリースされるのを待つ…でいいのでしょうか。



記事検索