我正在通过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
入口点改为:https://github.com/docker-library/postgres/blob/fe8c9a4a309a889dc057d53bf3769c25c1522c65/10/alpine/docker-entrypoint.sh
这是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)
我们通过bash
进入 postgres docker 容器来让它工作,然后是su postgres
,最后是postgres --single -D /var/lib/postgresql/data/pgdata -P -d 5
从那里花了大约 15 分钟,但它奏效了!
我认为没有什么可担心的:
could not bind IPv6 address "::1": Address not available
这意味着
getaddrinfo
返回::1
作为localhost
的IP地址,但IPv6不起作用。您的 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 设置为您提供的资源太少......