ITPub博客

首页 > 数据库 > PostgreSQL > template0 的 age 问题. vacuum template0

template0 的 age 问题. vacuum template0

原创 PostgreSQL 作者:babyyellow 时间:2021-12-01 13:29:55 0 删除 编辑



template0  template1  数据库 是模板数据库. 


template0 是不允许链接的. 


数据库频繁的更新后. xid 用完了.  


  datname  |  xid_age  | av_wrap_pct | shutdown_pct | gb_size 

-----------+-----------+-------------+--------------+---------

 template0 | 198697852 |        99.3 |          9.0 |    59.9

(1 行记录)



怎么搞呢 .


需要 vacuum freeze  了 . 


select  * from pg_database;

pconline=> select * from pg_database where datname='template0'; 

-[ RECORD 1 ]-+------------------------------------

datname       | template0

datdba        | 10

encoding      | 6

datcollate    | C

datctype      | C

datistemplate | t

datallowconn  | f

datconnlimit  | -1

datlastsysoid | 13157

datfrozenxid  | 866733911

datminmxid    | 6

dattablespace | 1663

datacl        | {=c/postgres,postgres=CTc/postgres}



update  pg_database set datallowconn='t' where datname='template0';     



\c  template0 


template0=# vacuum freeze ;

VACUUM

 

update  pg_database set datallowconn='f' where datname='template0';     


    

切记 , 处理完后, 一定要把 允许登录关闭.  不要给自己找不自在. 





来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/133735/viewspace-2845101/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论
oracle MySQL Postgresql 专职数据库dba。 系统架构师。 mysql 官方认知dba 。 15年专职dba 经验。 潜意识沟通实证者 心理咨询师。 禅修布道者, 禅修指导员。 禅定实证者。

注册时间:2010-12-02

  • 博文量
    367
  • 访问量
    1908662