我正在通过Docker运行Postgres v10.3(特别是docker-compose)。它没有回头。当我尝试打开它时收到以下错误消息:
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)
答案 0 :(得分:0)
我们通过bash
输入postgres泊坞广告容器,然后su postgres
,最后postgres --single -D /var/lib/postgresql/data/pgdata -P -d 5
从那里花了大约15分钟,但它有效!
答案 1 :(得分:0)
我认为有什么值得担心的:
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设置会给你太少的资源......