服务端启动异常

异常原因:数据库无法连接
数据库地址:127.0.0.1:5432
配置目录:/config 读写权限正常
数据库目录:/config/pgsql

请参考官网解决方法https://mtmt.tech/docs/advanced/ifix

Debug信息:

# id postgres

uid=103(postgres) gid=105(postgres) groups=105(postgres),103(ssl-cert)

# stat /config/pgsql

  File: /config/pgsql
  Size: 47        	Blocks: 0          IO Block: 4096   directory
Device: 38h/56d	Inode: 6790        Links: 1
Access: (0700/drwx------)  Uid: (  103/postgres)   Gid: (  105/postgres)
Access: 2024-04-11 15:08:43.040481595 +0800
Modify: 2024-02-26 18:14:44.463413313 +0800
Change: 2025-03-10 00:30:10.090561315 +0800
 Birth: -

请根据 下方红色 提示,检查 上方Debug信息 中,uid是否一致,以及Access是否为0700

# id postgres

uid=103(postgres) gid=105(postgres) ...

# stat /config/pgsql

Access: (0700/drwx------) Uid: ( 103/postgres) Gid: ( 105/postgres)

如果Debug信息中的目录权限没问题
请查看数据库最新的日志/config/pgsql/serverlog
寻找FATALPANIC开头的日志;

# cat /config/pgsql/serverlog

2025-03-29 00:01:33.649 CST [13486] LOG:  could not link file "pg_wal/xlogtemp.13486" to "pg_wal/000000010000000000000022": Function not implemented
2025-03-29 00:01:33.652 CST [13486] PANIC:  could not open file "pg_wal/000000010000000000000022": No such file or directory
2025-03-29 00:01:33.653 CST [34] LOG:  startup process (PID 13486) was terminated by signal 6: Aborted
2025-03-29 00:01:33.653 CST [34] LOG:  aborting startup due to startup process failure
2025-03-29 00:01:33.656 CST [34] LOG:  database system is shut down
2025-03-29 00:05:27.031 CST [13494] LOG:  starting PostgreSQL 14.12 (Debian 14.12-1.pgdg110+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 10.2.1-6) 10.2.1 20210110, 64-bit
2025-03-29 00:05:27.057 CST [13494] LOG:  listening on IPv4 address "127.0.0.1", port 5432
2025-03-29 00:05:27.158 CST [13494] LOG:  listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
2025-03-29 00:05:27.195 CST [13494] WARNING:  autovacuum not started because of misconfiguration
2025-03-29 00:05:27.195 CST [13494] HINT:  Enable the "track_counts" option.
2025-03-29 00:05:27.250 CST [13495] LOG:  database system was interrupted while in recovery at 2025-03-29 00:01:33 CST
2025-03-29 00:05:27.250 CST [13495] HINT:  This probably means that some data is corrupted and you will have to use the last backup for recovery.
2025-03-29 00:05:27.505 CST [13495] LOG:  database system was not properly shut down; automatic recovery in progress
2025-03-29 00:05:27.545 CST [13495] LOG:  redo starts at 0/21FFEE28
2025-03-29 00:05:27.545 CST [13495] LOG:  redo done at 0/21FFEED8 system usage: CPU: user: 0.00 s, system: 0.00 s, elapsed: 0.00 s
2025-03-29 00:05:27.741 CST [13495] LOG:  could not link file "pg_wal/xlogtemp.13495" to "pg_wal/000000010000000000000022": Function not implemented
2025-03-29 00:05:27.744 CST [13495] PANIC:  could not open file "pg_wal/000000010000000000000022": No such file or directory
2025-03-29 00:05:27.745 CST [13494] LOG:  startup process (PID 13495) was terminated by signal 6: Aborted
2025-03-29 00:05:27.745 CST [13494] LOG:  aborting startup due to startup process failure
2025-03-29 00:05:27.748 CST [13494] LOG:  database system is shut down