PostgreSQL数据库的物理存储结构主要是指硬盘上存储的文件,包括:数据文件、日志文件、参数文件、控制文件、WAL预写日志文件等等。
下面重点讨论一下PostgreSQL的控制文件。视频讲解如下:
控制文件记录了数据库运行时的一些信息,比如数据库oid、是否是打开状态、WAL的位置、检查点的信息等等。PostgreSQL的控制文件是很重要的数据库文件。控制文件默认保存在$PGDATA/global/pg_control目录下,可以使用命令bin/pg_controldata查看控制文件的内容,具体的操作步骤如下:
(1)进入PostgreSQL的安装目录。
cd /home/postgres/training/pgsql
(2)执行命令查看控制文件的内容。
[postgres@mydb pgsql]$ bin/pg_controldata data/ # 输出的信息如下: pg_control version number: 1300 Catalog version number: 202007201 Database system identifier: 7208875389865427015 Database cluster state: in production pg_control last modified: Fri 21 Apr 2023 05:56:43 PM CST Latest checkpoint location: 0/2000098 Latest checkpoint's REDO location: 0/2000060 Latest checkpoint's REDO WAL file: 000000010000000000000002 Latest checkpoint's TimeLineID: 1 Latest checkpoint's PrevTimeLineID: 1 Latest checkpoint's full_page_writes: on Latest checkpoint's NextXID: 0:492 Latest checkpoint's NextOID: 24576 Latest checkpoint's NextMultiXactId: 1 Latest checkpoint's NextMultiOffset: 0 Latest checkpoint's oldestXID: 478 Latest checkpoint's oldestXID's DB: 1 Latest checkpoint's oldestActiveXID: 492 Latest checkpoint's oldestMultiXid: 1 Latest checkpoint's oldestMulti's DB: 1 Latest checkpoint's oldestCommitTsXid:0 Latest checkpoint's newestCommitTsXid:0 Time of latest checkpoint: Fri 21 Apr 2023 05:56:43 PM CST Fake LSN counter for unlogged rels: 0/3E8 Minimum recovery ending location: 0/0 Min recovery ending loc's timeline: 0 Backup start location: 0/0 Backup end location: 0/0 End-of-backup record required: no wal_level setting: replica wal_log_hints setting: off max_connections setting: 100 max_worker_processes setting: 8 max_wal_senders setting: 10 max_prepared_xacts setting: 0 max_locks_per_xact setting: 64 track_commit_timestamp setting: off Maximum data alignment: 8 Database block size: 8192 Blocks per segment of large relation: 131072 WAL block size: 8192 Bytes per WAL segment: 16777216 Maximum length of identifiers: 64 Maximum columns in an index: 32 Maximum size of a TOAST chunk: 1996 Size of a large-object chunk: 2048 Date/time type storage: 64-bit integers Float8 argument passing: by value Data page checksum version: 0 Mock authentication nonce: 7fda27a3058cbfb6cde2be36c58d96a33787abb79d40f4c07d36b932460def9b