由于日期格式的不同,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文件的日期调整为该格式即可解决上述问题.