postgresql - Postgres 10.3 无法绑定 IPv6 地址,数据库系统未正确关闭
问题描述
我正在通过 Docker(特别是 docker-compose)运行 Postgres v10.3。它没有重新打开。当我尝试打开它时,我收到以下错误消息:
postgres | pg_ctl: another server might be running; trying to start server anyway
postgres | waiting for server to start....2018-05-15 12:37:07.552 UTC [22] LOG: listening on IPv4 address "127.0.0.1", port 5432
postgres | 2018-05-15 12:37:07.552 UTC [22] LOG: could not bind IPv6 address "::1": Address not available
postgres | 2018-05-15 12:37:07.552 UTC [22] HINT: Is another postmaster already running on port 5432? If not, wait a few seconds and retry.
postgres | 2018-05-15 12:37:07.558 UTC [22] LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
postgres | 2018-05-15 12:37:07.804 UTC [23] LOG: database system was interrupted while in recovery at 2018-05-15 12:35:58 UTC
postgres | 2018-05-15 12:37:07.804 UTC [23] HINT: This probably means that some data is corrupted and you will have to use the last backup for recovery.
postgres | .........2018-05-15 12:37:17.735 UTC [23] LOG: database system was not properly shut down; automatic recovery in progress
postgres | .2018-05-15 12:37:17.935 UTC [23] LOG: redo starts at 1/5E964BA8
postgres | pg_ctl: server did not start in time
postgres | ................................................. stopped waiting
我可能在写入数据库时关闭了数据库,这是我能想到的唯一会导致这种情况的事情。我没有备份,这就是为什么我想恢复我已经完成的工作(除了我在关闭时写入的表)。
我尝试过的事情:
重新启动 docker 容器并清除缓存 (
docker system prune -f
)删除
postmaster.pid
文件并重新启动- 这给了我一个
could not open file "postmaster.pid": No such file or directory
错误并生成一个postmaster.pid
文件,然后让我回到原来的错误
- 这给了我一个
当运行single_user_mode
更多日志时,我得到
/ $ postgres --single -D /var/lib/postgresql/data/pgdata -P -d 5
2018-05-15 15:16:09.978 UTC [12] DEBUG: invoking IpcMemoryCreate(size=148537344)
2018-05-15 15:16:09.978 UTC [12] DEBUG: mmap(148897792) with MAP_HUGETLB failed, huge pages disabled: Out of memory
2018-05-15 15:16:09.999 UTC [12] DEBUG: SlruScanDirectory invoking callback on pg_notify/0000
2018-05-15 15:16:09.999 UTC [12] DEBUG: removing file "pg_notify/0000"
2018-05-15 15:16:10.005 UTC [12] DEBUG: dynamic shared memory system will support 288 segments
2018-05-15 15:16:10.005 UTC [12] DEBUG: created dynamic shared memory control segment 262836907 (6928 bytes)
2018-05-15 15:16:10.005 UTC [12] DEBUG: InitPostgres
2018-05-15 15:16:10.005 UTC [12] DEBUG: my backend ID is 1
2018-05-15 15:16:10.010 UTC [12] LOG: database system was shut down in recovery at 2018-05-15 15:16:04 UTC
2018-05-15 15:16:10.014 UTC [12] DEBUG: checkpoint record is at 1/64CA6F18
2018-05-15 15:16:10.025 UTC [12] DEBUG: redo record is at 1/5E964BA8; shutdown FALSE
2018-05-15 15:16:10.025 UTC [12] DEBUG: next transaction ID: 0:681710; next OID: 311511
2018-05-15 15:16:10.025 UTC [12] DEBUG: next MultiXactId: 155; next MultiXactOffset: 312
2018-05-15 15:16:10.025 UTC [12] DEBUG: oldest unfrozen transaction ID: 547, in database 1
2018-05-15 15:16:10.025 UTC [12] DEBUG: oldest MultiXactId: 1, in database 1
2018-05-15 15:16:10.025 UTC [12] DEBUG: commit timestamp Xid oldest/newest: 0/0
2018-05-15 15:16:10.025 UTC [12] DEBUG: transaction ID wrap limit is 2147484194, limited by database with OID 1
2018-05-15 15:16:10.025 UTC [12] DEBUG: MultiXactId wrap limit is 2147483648, limited by database with OID 1
2018-05-15 15:16:10.025 UTC [12] DEBUG: starting up replication slots
2018-05-15 15:16:10.028 UTC [12] DEBUG: starting up replication origin progress state
2018-05-15 15:16:10.031 UTC [12] LOG: database system was not properly shut down; automatic recovery in progress
2018-05-15 15:16:10.037 UTC [12] DEBUG: resetting unlogged relations: cleanup 1 init 0
2018-05-15 15:16:10.334 UTC [12] LOG: redo starts at 1/5E964BA8
我的 dockerfile 扩展了这个:https ://github.com/docker-library/postgres/blob/fe8c9a4a309a889dc057d53bf3769c25c1522c65/10/alpine/Dockerfile
这是ifconfig
:
MacBook-Pro:backend zebrainatree$ docker-compose demo run postgres ifconfig -a
eth0 Link encap:Ethernet HWaddr 02:42:AC:12:00:03
inet addr:172.18.0.3 Bcast:172.18.255.255 Mask:255.255.0.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:1 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:90 (90.0 B) TX bytes:0 (0.0 B)
ip6tnl0 Link encap:UNSPEC HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00
NOARP MTU:1452 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
tunl0 Link encap:UNSPEC HWaddr 00-00-00-00-00-00-10-8B-00-00-00-00-00-00-00-00
NOARP MTU:1480 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
解决方案
我认为没有什么可担心的:
could not bind IPv6 address "::1": Address not available
这意味着作为 的 IP 地址
getaddrinfo
返回,但 IPv6 不起作用。::1
localhost
您的 DNS 设置配置错误,但这不是什么大问题——您只是无法使用 IPv6 连接到环回接口。
waiting for server to start.....stopped waiting
启动花费的时间比
pg_ctl
等待的时间长。烦人,但本身没有问题。看下一点。在这种情况下,您应该始终查阅 PostgreSQL 日志。
LOG: database system was interrupted while in recovery at 2018-05-15 12:35:58 UTC HINT: This probably means that some data is corrupted and you will have to use the last backup for recovery.
这只是意味着您不耐烦并打断了之前的启动尝试,不是吗?
提示就在那里,因为如果在没有惊慌失措的系统管理员中断启动过程的情况下发生这种情况,则可能意味着恢复崩溃,可能是因为数据库文件中的数据不正确。
崩溃恢复的 15 分钟并不短。
也许自上次检查点以来有很多活动(并且max_wal_size
设置得非常高),也许您的磁盘非常慢,也许您的限制性 cgroups 设置给您的资源太少......
推荐阅读
- excel - 用于更改查询 xls 源提示的 vba 代码
- postgresql - 如何使用悲观锁实现 SKIP LOCKED 功能?
- python - 将不均匀的字典写入单独的 csv 文件
- google-apps-script - 如何通过电子表格创建谷歌表单
- java - 以编程方式将 use="required" 字段添加到 XML Schema 属性
- kubernetes - 在启动之前编辑 kubernetes 映像上的文件
- scala - Spark:在数据框的同一列中解析具有不同格式(MM-dd-yyyy HH:mm, MM/dd/yy H:mm)的日期/时间戳
- r - if_else 和 case_when 与 group_by 之间的行为差异
- c# - 在 c# 中正确使用 async/await
- node.js - HTML 未提取 NODEJS