pg_controldata /pgdata/data/vastbase-55d7a76f
根据提供的信息,这是关于一个 PostgreSQL 数据库集群中 /pgdata/data/vastbase-55d7a76f
目录下的 pg_controldata
命令的输出结果。
以下是输出中的一些重要信息的解释:
pg_control version number: 923
:这是pg_control
文件的版本号,它对应于 PostgreSQL 9.2.3 版本。Catalog version number: 201611171
:这是数据库目录的目录版本号,指明数据库使用的系统目录的格式。Database system identifier: 4246795137288642501
:这是数据库系统的唯一标识符(Database System Identifier,简称为 “DBOID”),用于识别一个特定的数据库集群。Database cluster state: in production
:这表示数据库集群处于 “in production”(生产中)状态,即正在运行并提供服务。pg_control last modified: Tue 27 Jun 2023 05:48:08 PM CST
:这是pg_control
文件最后修改的时间。Latest checkpoint location: 2/4931F2D0
:这是最新检查点(checkpoint)的位置,用于恢复和故障恢复操作。Latest checkpoint's REDO location: 2/4931F250
:这是最新检查点的 REDO(重做)位置,用于数据恢复。Latest checkpoint's TimeLineID: 1
:这是最新检查点的时间线标识符(Timeline ID),指明数据库的时间线。Latest checkpoint's full_page_writes: off
:这表示最新检查点的全页写(full_page_writes)选项为关闭状态,这意味着在检查点期间只写入修改的数据页,而不是全部数据页。Latest checkpoint's NextXID: 19427
:这是下一个事务ID(XID)的值,用于标识将要执行的下一个事务。Latest checkpoint's oldestXID: 9792
:这是最旧活动事务的XID值,用于确定最早还未完成的事务。Current wal_level setting: hot_standby
:这是当前的WAL级别设置,指明WAL(Write-Ahead Log)的详细记录级别。在这种情况下,设置为 “hot_standby”,表示启用了热备用服务器功能。Current max_connections setting: 250
:这是当前的最大连接数设置,表示同时允许的最大客户端连接数。Database block size: 8192
:这是数据库块的大小,以字节为单位,用于存储数据库中的数据。WAL block size: 8192
:这是WAL(Write-Ahead Log)块的大小,以字节为单位,用于记录数据库的变更。Bytes per WAL segment: 16777216
:这是每个WAL段的字节数,指定了WAL文件的大小限制。Database system TimeLine: 6
:这是数据库系统的时间线(Timeline)标识符。
这些信息可以提供有关数据库集群的各种配置和状态的详细信息,供管理员和开发人员使用。
pg_xlogfile_name
pg_xlogfile_name
是一个 PostgreSQL 内置函数,用于生成指定 WAL (Write-Ahead Log) 文件的文件名。
该函数接受两个参数:
lsn
:表示 WAL 日志位置的参数,通常以x/y
的格式表示,其中x
是一个十六进制数,表示段(segment)号,y
也是一个十六进制数,表示段内偏移量(segment offset)。timeline
:表示时间线标识符(Timeline ID)的参数。
函数将根据提供的 LSN 和时间线信息生成对应 WAL 文件的文件名。
例如,如果调用 pg_xlogfile_name('2/4931F2D0', 1)
,它将返回与 2/4931F2D0
位置和时间线 1 相关联的 WAL 文件的文件名。
请注意,pg_xlogfile_name
是一个内部函数,主要用于 PostgreSQL 内部和系统管理目的。在大多数情况下,通常不需要手动调用此函数。
删除3天前的wal
cd path/pg_xlog
find . -name “00000*” -type f -mtime +3 -exec rm -f {} ;
解释
pg_controldata
is a utility in PostgreSQL that provides information about the current state of the database cluster. Based on the provided output, here is an explanation of each field:
-
pg_control version number (1300): The version number of the
pg_control
file format. This indicates the format used to store control information about the database cluster. -
Catalog version number (202107181): The version number of the system catalog, which stores metadata about databases, tables, indexes, etc. This number represents the timestamp when the catalog was last updated.
-
Database system identifier (7259624880255705248): A unique identifier for the database cluster. This value is used to ensure that different clusters do not accidentally connect to each other.
-
Database cluster state (in production): Indicates the current state of the database cluster. In this case, it shows that the cluster is in production.
-
pg_control last modified (Tue Jul 25 13:40:54 2023): The timestamp when the
pg_control
file was last modified. -
Latest checkpoint location (0/4000220): The location of the most recent checkpoint in the Write-Ahead Log (WAL). Checkpoints are used to mark a point where all data files have been flushed to disk, ensuring durability.
-
Latest checkpoint’s REDO location (0/40001E8): The location in the WAL from which recovery would start after a crash or shutdown. REDO records contain changes that need to be replayed during recovery.
-
Latest checkpoint’s REDO WAL file (000000020000000000000004): The name of the WAL file associated with the latest checkpoint’s REDO location.
-
Latest checkpoint’s TimeLineID (2): The identifier of the timeline in which the checkpoint occurred. Timelines help keep track of changes in database history.
-
Latest checkpoint’s PrevTimeLineID (2): The identifier of the timeline that precedes the current timeline.
-
Latest checkpoint’s full_page_writes (on): Indicates whether full-page writes are enabled for the cluster. Full-page writes ensure that modifications to a page are written in their entirety during checkpoints, even if only a portion has changed.
-
Latest checkpoint’s NextXID (0:743): The ID of the next transaction to be assigned. Each transaction in PostgreSQL is identified by a unique transaction ID.
-
Latest checkpoint’s NextOID (16417): The next Object ID to be assigned. Object IDs are used to identify system objects like tables and indexes.
-
Latest checkpoint’s NextMultiXactId (1): The next MultiXact ID to be assigned. MultiXact IDs are used to identify transactions involving multiple concurrent operations.
-
Latest checkpoint’s NextMultiOffset (0): The next offset within the MultiXact ID to be assigned.
-
Latest checkpoint’s oldestXID (727): The oldest transaction ID still active in the database cluster.
-
Latest checkpoint’s oldestXID’s DB (1): The database ID of the database to which the oldest transaction ID belongs.
-
Latest checkpoint’s oldestActiveXID (743): The oldest active transaction ID in the database cluster.
-
Latest checkpoint’s oldestMultiXid (1): The oldest MultiXact ID still active in the database cluster.
-
Latest checkpoint’s oldestMulti’s DB (1): The database ID of the database to which the oldest MultiXact ID belongs.
-
Latest checkpoint’s oldestCommitTsXid (0): The oldest transaction ID with a committed timestamp. This field is related to commit timestamp tracking, which allows associating a timestamp with each committed transaction.
-
Latest checkpoint’s newestCommitTsXid (0): The newest transaction ID with a committed timestamp.
-
Time of latest checkpoint (Tue Jul 25 13:40:54 2023): The timestamp when the latest checkpoint occurred.
-
Fake LSN counter for unlogged rels (0/3E8): A fake Log Sequence Number (LSN) counter used for unlogged relations, which are not part of the WAL and do not provide crash recovery.
-
Minimum recovery ending location (0/0): The minimum location in the WAL required for recovery to finish.
-
Min recovery ending loc’s timeline (0): The timeline associated with the minimum recovery ending location.
-
Backup start location (0/0): The starting location of the backup. This indicates where the backup process began.
-
Backup end location (0/0): The ending location of the backup. This indicates where the backup process finished.
-
End-of-backup record required (no): Indicates whether an end-of-backup record is required for crash recovery.
-
wal_level setting (logical): The current value of the
wal_level
configuration parameter. It determines the amount of information written to the WAL. -
wal_log_hints setting (on): The current value of the
wal_log_hints
configuration parameter. When enabled, it provides hints to optimize logging for full-page writes. -
max_connections setting (200): The maximum number of concurrent connections allowed to the database cluster.
-
max_worker_processes setting (8): The maximum number of background processes that can be started by PostgreSQL.
-
max_wal_senders setting (10): The maximum number of WAL sender processes that can send changes to remote replicas.
-
max_prepared_xacts setting (0): The maximum number of prepared transactions that can be active at the same time.
-
max_locks_per_xact setting (64): The maximum number of locks that a single transaction can hold simultaneously.
-
track_commit_timestamp setting (off): The current value of the
track_commit_timestamp
configuration parameter. When enabled, it tracks the commit timestamp of each transaction. -
Maximum data alignment (8): The maximum byte alignment required for data storage.
-
Database block size (8192): The size of a database block in bytes. It is the basic unit of data storage within PostgreSQL.
-
Blocks per segment of large relation (131072): The number of blocks allocated per segment for large relations.
-
WAL block size (8192): The size of a WAL block in bytes. The WAL stores changes made to the database for durability and crash recovery.
-
Bytes per WAL segment (16777216): The number of bytes allocated per WAL segment.
-
Maximum length of identifiers (64): The maximum length of identifiers like table names and column names.
-
Maximum columns in an index (32): The maximum number of columns that can be included in an index.
-
Maximum size of a TOAST chunk (1996): The maximum size of a compressed TOAST (The Oversized-Attribute Storage Technique) chunk.
-
Size of a large-object chunk (2048): The size of a chunk used for large objects.
-
Date/time type storage (64-bit integers): The method used to store date/time types, which in this case is using 64-bit integers.
-
Float8 argument passing (by value): The way floating-point arguments are passed, which in this case is “by value.”
-
Data page checksum version (0): The version number of the data page checksum algorithm.
-
Mock authentication nonce (0a12314f4c8492ae60df53b46f16f77b1e6c99ca571e81e6291e74a1cf058e4a): A random value used for mocking authentication nonces.