PostgreSQL数据库的物理存储结构主要是指硬盘上存储的文件,包括:数据文件、日志文件、参数文件、控制文件、WAL预写日志文件等等。下面重点讨论一下PostgreSQL的服务器日志文件。视频讲解如下:
https://www.bilibili.com/video/BV1ZSsHeLEpR/?aid=113031241532...
通过使用pg_ctl命令启动PostgreSQL数据库实例时,通过指定-l参数来指定PostgreSQL的服务器日志文件。如果不知道该日志文件,错误可能会输出到cmd前台。下图展示了在启动数据库服务器时,使用“-l”参数生成的服务器日志文件,它记录了数据库实例在启动和关闭过程中的重要信息。
服务器日志文件的内容如下:
2024-12-02 16:51:10.955 CST [87485] LOG: starting PostgreSQL 15.3 on x86_64-pc-linux-gnu,
compiled by gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-44),
64-bit
2024-12-02 16:51:10.956 CST [87485] LOG: listening on IPv4 address "0.0.0.0", port 5432
2024-12-02 16:51:10.956 CST [87485] LOG: listening on IPv6 address "::", port 5432
2024-12-02 16:51:10.958 CST [87485] LOG: listening on Unix socket "/tmp/.s.PGSQL.5432"
2024-12-02 16:51:10.965 CST [87488] LOG: database system was shut down at 2024-11-28 09:35:18 CST
2024-12-02 16:51:10.982 CST [87485] LOG: database system is ready to accept connections
2024-12-02 16:51:15.919 CST [87485] LOG: received fast shutdown request
2024-12-02 16:51:15.920 CST [87485] LOG: aborting any active transactions
2024-12-02 16:51:15.921 CST [87485] LOG: background worker "logical replication launcher" (PID 87491)
exited with exit code 1
2024-12-02 16:51:15.922 CST [87486] LOG: shutting down
2024-12-02 16:51:15.922 CST [87486] LOG: checkpoint starting: shutdown immediate
2024-12-02 16:51:15.927 CST [87486] LOG: checkpoint complete: wrote 3 buffers (0.0%);
0 WAL file(s) added, 0 removed, 0 recycled; write=0.002 s,
sync=0.001 s, total=0.006 s; sync files=2, longest=0.001 s,
average=0.001 s; distance=0 kB, estimate=0 kB
2024-12-02 16:51:15.932 CST [87485] LOG: database system is shut down
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。