ITPub博客

首页 > 数据库 > PostgreSQL > PostgreSQL DBA(29) - Backup&Recovery#2(日期格式导致的错误)

PostgreSQL DBA(29) - Backup&Recovery#2(日期格式导致的错误)

原创 PostgreSQL 作者:husthxd 时间:2019-03-11 15:14:00 0 删除 编辑

由于日期格式的不同,PostgreSQL在执行恢复读取recovery.conf的时候会出现问题.
错误信息
在recovery.conf文件,recovery_target_time的设置


recovery_target_time='2019-3-11 14:40:00'

如按上述设置,则会出现错误


[xdb@localhost testdb]$ pg_ctl start
waiting for server to start....2019-03-11 14:04:45.121 CST [21749] LOG:  listening on IPv4 address "0.0.0.0", port 5432
2019-03-11 14:04:45.121 CST [21749] LOG:  listening on IPv6 address "::", port 5432
2019-03-11 14:04:45.123 CST [21749] LOG:  listening on Unix socket "/tmp/.s.PGSQL.5432"
2019-03-11 14:04:45.135 CST [21749] LOG:  redirecting log output to logging collector process
2019-03-11 14:04:45.135 CST [21749] HINT:  Future log output will appear in directory "log".
 stopped waiting
pg_ctl: could not start server
Examine the log output.

日志提示


[xdb@localhost log]$ cat postgresql-2019-03-11_122129.csv
2019-03-11 12:21:29.233 CST,,,1680,,5c85e249.690,1,,2019-03-11 12:21:29 CST,,0,LOG,00000,"ending log output to stderr",,"Futu
2019-03-11 12:21:29.236 CST,,,1682,,5c85e249.692,1,,2019-03-11 12:21:29 CST,,0,LOG,00000,"database system was interrupted; la
2019-03-11 12:21:29.249 CST,,,1682,,5c85e249.692,2,,2019-03-11 12:21:29 CST,,0,FATAL,42601,"syntax error in file ""recovery.c
2019-03-11 12:21:29.250 CST,,,1680,,5c85e249.690,2,,2019-03-11 12:21:29 CST,,0,LOG,00000,"startup process (PID 1682) exited w
2019-03-11 12:21:29.250 CST,,,1680,,5c85e249.690,3,,2019-03-11 12:21:29 CST,,0,LOG,00000,"aborting startup due to startup pro
2019-03-11 12:21:29.252 CST,,,1680,,5c85e249.690,4,,2019-03-11 12:21:29 CST,,0,LOG,00000,"database system is shut down",,,,,,

在recovery.conf文件的第3行有语法错误,猜测是日期格式问题

日期格式


testdb=# show datestyle;
 DateStyle 
-----------
 ISO, MDY
(1 row)

PG日期格式为月-日-年,recovery.conf文件的日期调整为该格式即可解决上述问题.

参考资料
Base Backup & Point-in-Time Recovery

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

请登录后发表评论 登录
全部评论
长期从事政务、金融等行业产品研发和架构设计工作,对Oracle、PostgreSQL以及大数据等相关技术有深入研究。现就职于广州云图数据技术有限公司,系统架构师。

注册时间:2007-12-28

  • 博文量
    1196
  • 访问量
    3665239