美文网首页
Docker启动Postgres失败:invalid value

Docker启动Postgres失败:invalid value

作者: 南瓜pump | 来源:发表于2022-09-29 13:06 被阅读0次

服务器运行一段时间后,Pg数据库突然启动不了了,查看了Docker启动日志,报错信息如下:

PostgreSQL Database directory appears to contain a database; Skipping initialization

2022-09-29 02:56:52.809 GMT [1] LOG:  invalid value for parameter "log_timezone": "Etc/UTC"
2022-09-29 02:56:52.810 GMT [1] LOG:  invalid value for parameter "TimeZone": "Etc/UTC"
2022-09-29 02:56:52.810 GMT [1] FATAL:  configuration file "/var/lib/postgresql/data/postgresql.conf" contains errors

查阅了相关资料,发现可能是配置文件的时区配置有误(具体原因也没有找到。。),于是尝试修改pg的配置,最终发现改为"Asia/Shanghai"即可,具体步骤:

  • 拷贝容器里面报错的配置文件
docker cp e93:/var/lib/postgresql/data/postgresql.conf .
  • 修改报错的时区参数为"Asia/Shanghai":
log_timezone = 'Asia/Shanghai'
timezone = 'Asia/Shanghai'
  • 拷贝修改后的配置文件到容器内:
docker cp postgresql.conf e93:/var/lib/postgresql/data/
  • 重新启动pg容器即可:
docker restart e93

启动成功:

PostgreSQL Database directory appears to contain a database; Skipping initialization

2022-09-29 11:27:01.853 CST [1] LOG:  starting PostgreSQL 12.4 (Debian 12.4-1.pgdg100+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 8.3.0-6) 8.3.0, 64-bit
2022-09-29 11:27:01.855 CST [1] LOG:  listening on IPv4 address "0.0.0.0", port 5432
2022-09-29 11:27:01.856 CST [1] LOG:  listening on IPv6 address "::", port 5432
2022-09-29 11:27:01.857 CST [1] LOG:  listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
2022-09-29 11:27:01.872 CST [25] LOG:  database system was interrupted; last known up at 2022-08-10 17:01:10 CST
2022-09-29 11:27:01.905 CST [25] LOG:  database system was not properly shut down; automatic recovery in progress
2022-09-29 11:27:01.907 CST [25] LOG:  redo starts at 0/89034A48
2022-09-29 11:27:01.907 CST [25] LOG:  invalid record length at 0/89034B30: wanted 24, got 0
2022-09-29 11:27:01.907 CST [25] LOG:  redo done at 0/89034AF8
2022-09-29 11:27:01.914 CST [1] LOG:  database system is ready to accept connections

相关文章

网友评论

      本文标题:Docker启动Postgres失败:invalid value

      本文链接:https://www.haomeiwen.com/subject/toxkartx.html