本文共 2939 字,大约阅读时间需要 9 分钟。
postgres=# select pg_current_xlog_location(); pg_current_xlog_location ------------------------------------------------------ 138B/A280A860 (1 row)
postgres=# select pg_current_xlog_location(),pg_current_xlog_insert_location(); pg_current_xlog_location | pg_current_xlog_insert_location --------------------------+--------------------------------- 138D/45A84000 | 138D/45AF7300 (1 row)
postgres=# select pg_xlogfile_name('15D2/32414638'); pg_xlogfile_name -------------------------- 00000001000015D200000032 (1 row)
可以在pg_xlog中找到相应的文件
-bash-4.2$ cd pg_xlog/-bash-4.2$ ll 00000001000015D200000032-rw-------. 1 postgres dba 16777216 Jan 24 18:09 00000001000015D200000032
postgres=# select pg_xlogfile_name_offset('15D2/32414638'); pg_xlogfile_name_offset ------------------------------------ (00000001000015D200000032,4277816)(1 row)
postgres=# select pg_xlog_location_diff(pg_current_xlog_location(),pg_current_xlog_insert_location()); pg_xlog_location_diff ----------------------- -126472(1 row)postgres=#
关于两个参数的区别,贴上官方解释:
pg_current_xlog_location displays the current transaction log write location in the same format used by the above functions. Similarly, pg_current_xlog_insert_location displays the current transaction log insertion point. The insertion point is the "logical" end of the transaction log at any instant, while the write location is the end of what has actually been written out from the server's internal buffers. The write location is the end of what can be examined from outside the server, and is usually what you want if you are interested in archiving partially-complete transaction log files. The insertion point is made available primarily for server debugging purposes. These are both read-only operations and do not require superuser permissions.
大概意思是 pg_xlog_location_diff表示已经写入到wal文件中transaction log事物号。
pg_xlogfile_name_offset数据库实例最后的transaction log,可能还未写入到wal文件中。转载地址:http://zavpa.baihongyu.com/