database “template0“ is not currently accepting connections
template0 数据库默认是不允许登录的,做 vacuumdb 减少 age 时报错。
postgres=# select datfrozenxid,datname,age(datfrozenxid),txid_current() from pg_database;
datfrozenxid | datname | age | txid_current
--------------+--------------------+--------+--------------
289572 | postgres | 22 | 289594
289572 | peiybdb | 22 | 289594
289571 | template1 | 23 | 289594
561 | template0 | 289033 | 289594
289574 | pgbenchdb | 20 | 289594
289570 | yewudb | 24 | 289594
289593 | pgbench_plprofiler | 1 | 289594
(7 rows)
$ /usr/pgsql-11/bin/vacuumdb --freeze template0
vacuumdb: could not connect to database template0: FATAL: database "template0" is not currently accepting connections
需要 superuser 执行下更新命令。
postgres=# update pg_database set datallowconn = TRUE where datname = 'template0';
$ /usr/pgsql-11/bin/vacuumdb --freeze template0
vacuumdb: vacuuming database "template0"
postgres=# select datfrozenxid,datname,age(datfrozenxid),txid_current() from pg_database;
datfrozenxid | datname | age | txid_current
--------------+--------------------+-----+--------------
289572 | postgres | 24 | 289596
289572 | peiybdb | 24 | 289596
289571 | template1 | 25 | 289596
289574 | pgbenchdb | 22 | 289596
289570 | yewudb | 26 | 289596
289593 | pgbench_plprofiler | 3 | 289596
289596 | template0 | 0 | 289596
(7 rows)
使用 superuser 还原一下。
postgres=# update pg_database set datallowconn = FALSE where datname = 'template0';
还没有评论,来说两句吧...