我正在处理 PostgreSQL 10.4 安装中的一个奇怪问题。PostgreSQL 的一个数据库实例在 7 个月没有问题之后停止工作。当这个人看到数据库没有响应时,尝试重新启动数据库并退出操作系统,但没有成功。
于是,我开始查看日志,什么也没发现,只有关闭语句,没有 postgresql_20190208.log
2019-02-08 16:24:07.749 -02 [12878] LOG: could not receive data from client: Connection reset by peer
2019-02-08 16:30:59.421 -02 [27180] LOG: received fast shutdown request
2019-02-08 16:30:59.422 -02 [27180] LOG: aborting any active transactions
2019-02-08 16:30:59.422 -02 [44204] FATAL: terminating connection due to administrator command
2019-02-08 16:30:59.422 -02 [13796] FATAL: terminating autovacuum process due to administrator command
2019-02-08 16:30:59.422 -02 [95589] FATAL: terminating connection due to administrator command
好的,当我检查startup.log时我发现:
2019-02-08 16:31:00.861 -02 [13815] FATAL: could not access file "": No such file or directory
2019-02-08 16:31:00.861 -02 [13815] LOG: database system is shut down
我以前从未见过这种情况。我本以为该消息会向我显示有问题的文件或某些暴露数据损坏的内容,但空文件地址并没有多大帮助。
因此,我尝试自己启动数据库
postgres -D datadir/ -d 5 ;
2019-02-08 22:39:19.010 -02 [45971] DEBUG: postgres: PostmasterMain: initial environment dump:
[some envirounment variables]
2019-02-08 22:39:19.011 -02 [45971] DEBUG: registering background worker "logical replication launcher"
2019-02-08 22:39:19.011 -02 [45971] DEBUG: find_in_dynamic_libpath: trying "/banco/PostgreSQL/10/lib/postgresql/"
2019-02-08 22:39:19.011 -02 [45971] DEBUG: find_in_dynamic_libpath: trying "/banco/PostgreSQL/10/lib/postgresql/.so"
2019-02-08 22:39:19.011 -02 [45971] FATAL: could not access file "": No such file or directory
2019-02-08 22:39:19.011 -02 [45971] DEBUG: shmem_exit(1): 0 before_shmem_exit callbacks to make
2019-02-08 22:39:19.011 -02 [45971] DEBUG: shmem_exit(1): 0 on_shmem_exit callbacks to make
2019-02-08 22:39:19.011 -02 [45971] DEBUG: proc_exit(1): 1 callbacks to make
2019-02-08 22:39:19.011 -02 [45971] LOG: database system is shut down
2019-02-08 22:39:19.011 -02 [45971] DEBUG: exit(1)
2019-02-08 22:39:19.011 -02 [45971] DEBUG: shmem_exit(-1): 0 before_shmem_exit callbacks to make
2019-02-08 22:39:19.011 -02 [45971] DEBUG: shmem_exit(-1): 0 on_shmem_exit callbacks to make
2019-02-08 22:39:19.011 -02 [45971] DEBUG: proc_exit(-1): 0 callbacks to make
看到这个之后,我想:可能是 postgresql 安装已损坏。因此,我备份了数据文件夹并运行 initdb 命令进行测试,结果成功了。
你们中有人见过这种情况吗?我正在尝试另一种策略,即重新安装整个 postgres 并只复制数据文件夹,看看它是否有效。如果不行,我将恢复昨天的备份
你们知道这可能是什么原因造成的吗?
答案1
以下几行非常引人注目:
2019-02-08 22:39:19.011 -02 [45971] DEBUG: find_in_dynamic_libpath: trying "/banco/PostgreSQL/10/lib/postgresql/"
2019-02-08 22:39:19.011 -02 [45971] DEBUG: find_in_dynamic_libpath: trying "/banco/PostgreSQL/10/lib/postgresql/.so"
2019-02-08 22:39:19.011 -02 [45971] FATAL: could not access file "": No such file or directory
它表示postgresql.conf
请求加载一个文件名为空的共享库。这可能发生在这样的声明中,例如:
shared_preload_libraries = '""'
在我自己编译的实例上测试此声明:
2019-02-09 18:42:13 CET DEBUG: registering background worker "logical replication launcher"
2019-02-09 18:42:13 CET DEBUG: find_in_dynamic_libpath: trying "/usr/local/pgsql/lib/"
2019-02-09 18:42:13 CET DEBUG: find_in_dynamic_libpath: trying "/usr/local/pgsql/lib/.so"
2019-02-09 18:42:13 CET FATAL: could not access file "": Aucun fichier ou dossier de ce type
2019-02-09 18:42:13 CET DEBUG: shmem_exit(1): 0 before_shmem_exit callbacks to make
2019-02-09 18:42:13 CET DEBUG: shmem_exit(1): 0 on_shmem_exit callbacks to make
2019-02-09 18:42:13 CET DEBUG: proc_exit(1): 1 callbacks to make
2019-02-09 18:42:13 CET LOG: database system is shut down
2019-02-09 18:42:13 CET DEBUG: exit(1)
与您的结果相同,只是您的结果$libdir
似乎是/banco/PostgreSQL/10/lib/postgresql/
。