提交 eeaf3fc3 编写于 作者: T Tom Lane

First cut at XLOG file reset utility.

Could do with more testing, but it works in the simple cases.
上级 f192da1b
# $Header: /cvsroot/pgsql/contrib/Makefile,v 1.17 2001/03/13 19:28:02 petere Exp $
# $Header: /cvsroot/pgsql/contrib/Makefile,v 1.18 2001/03/14 00:57:43 tgl Exp $
subdir = contrib
top_builddir = ..
......@@ -18,8 +18,10 @@ WANTED_DIRS = \
miscutil \
noupdate \
oid2name \
pg_controldata \
pg_dumplo \
pg_logger \
pg_resetxlog \
pgbench \
pgcrypto \
rserv \
......
......@@ -52,6 +52,10 @@ intarray -
by Teodor Sigaev <teodor@stack.net> and Oleg Bartunov
<oleg@sai.msu.su>.
ipc_check -
Simple test script to help in configuring IPC.
FreeBSD only, for now.
isbn_issn -
PostgreSQL type extensions for ISBN (books) and ISSN (serials)
by Garrett A. Wollman <wollman@khavrinen.lcs.mit.edu>
......@@ -86,7 +90,7 @@ oid2name -
by B Palmer <bpalmer@crimelabs.net>
pg_controldata -
Dump internal database site structures
Dump contents of pg_control (database master file)
by Oliver Elphick <olly@lfix.co.uk>
pg_dumplo -
......@@ -97,6 +101,10 @@ pg_logger -
Stdin-to-syslog gateway for PostgreSQL
by Nathan Myers <ncm@nospam.cantrip.org>
pg_resetxlog -
Reset the WAL log (pg_xlog) to recover from crash or format change
by Tom Lane <tgl@sss.pgh.pa.us>
pgbench -
TPC-B like benchmarking tool
by Tatsuo Ishii <t-ishii@sra.co.jp>
......
#
# $Header: /cvsroot/pgsql/contrib/pg_resetxlog/Attic/Makefile,v 1.1 2001/03/14 00:57:43 tgl Exp $
#
subdir = contrib/pg_resetxlog
top_builddir = ../..
include $(top_builddir)/src/Makefile.global
OBJS = pg_resetxlog.o pg_crc.o
all: pg_resetxlog
pg_resetxlog: $(OBJS)
$(CC) $(CFLAGS) $(OBJS) $(LDFLAGS) $(LIBS) -o $@
pg_crc.c: $(top_builddir)/src/backend/utils/hash/pg_crc.c
rm -f $@ && $(LN_S) $< .
install: all installdirs
$(INSTALL_PROGRAM) pg_resetxlog$(X) $(bindir)
$(INSTALL_DATA) README.pg_resetxlog $(docdir)/contrib
installdirs:
$(mkinstalldirs) $(bindir) $(docdir)/contrib
uninstall:
rm -f $(bindir)/pg_resetxlog$(X) $(docdir)/contrib/README.pg_resetxlog
clean distclean maintainer-clean:
rm -f pg_resetxlog$(X) $(OBJS) pg_crc.c
depend dep:
$(CC) -MM -MG $(CFLAGS) *.c > depend
ifeq (depend,$(wildcard depend))
include depend
endif
pg_resetxlog is a program to clear the WAL transaction log (stored in
$PGDATA/pg_xlog/), replacing whatever had been in it with just a dummy
shutdown-checkpoint record. It also regenerates the pg_control file
if necessary.
THIS PROGRAM WILL DESTROY VALUABLE LOG DATA!!! Don't run it unless you
really need it!!!
pg_resetxlog is primarily intended for disaster recovery --- that is,
if your pg_control and/or xlog are hosed badly enough that Postgres refuses
to start up, this program will get you past that problem and let you get to
your data files. But realize that without the xlog, your data files may be
corrupt due to partially-applied transactions, incomplete index-file
updates, etc. You should dump your data, check it for accuracy, then initdb
and reload.
A secondary purpose is to cope with xlog format changes without requiring
initdb. To use pg_resetxlog for this purpose, just be sure that you have
cleanly shut down your old postmaster (if you're not sure, see the contrib
module pg_controldata and run it to be sure the DB state is SHUTDOWN).
Then run pg_resetxlog, and finally install and start the new version of
the database software.
To run the program, make sure your postmaster is not running, then
(as the Postgres admin user) do
pg_resetxlog $PGDATA
As a safety measure, the target data directory must be specified on the
command line, it cannot be defaulted.
If pg_resetxlog complains that it can't reconstruct valid data for pg_control,
you can force it to invent plausible data values with
pg_resetxlog -f $PGDATA
If this turns out to be necessary then you *definitely* should plan on
immediate dump, initdb, reload --- any modifications you do to the database
after "pg_resetxlog -f" would be likely to corrupt things even worse.
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册