Implement WAL log location control using "-X" or PGXLOG.
This commit is contained in:
parent
a19d9d3c4c
commit
af704cdfb4
@ -8,7 +8,7 @@
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/bootstrap/bootstrap.c,v 1.135 2002/08/02 22:36:05 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/bootstrap/bootstrap.c,v 1.136 2002/08/04 06:26:38 thomas Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -223,6 +223,7 @@ BootstrapMain(int argc, char *argv[])
|
||||
int flag;
|
||||
int xlogop = BS_XLOG_NOP;
|
||||
char *potential_DataDir = NULL;
|
||||
char *potential_XLogDir = NULL;
|
||||
|
||||
/*
|
||||
* initialize globals
|
||||
@ -250,17 +251,22 @@ BootstrapMain(int argc, char *argv[])
|
||||
if (!IsUnderPostmaster)
|
||||
{
|
||||
InitializeGUCOptions();
|
||||
potential_DataDir = getenv("PGDATA"); /* Null if no PGDATA
|
||||
* variable */
|
||||
/* Null if no PGDATA variable */
|
||||
potential_DataDir = getenv("PGDATA");
|
||||
/* Null if no PGXLOG variable */
|
||||
potential_XLogDir = getenv("PGXLOG");
|
||||
}
|
||||
|
||||
while ((flag = getopt(argc, argv, "B:d:D:Fo:px:")) != -1)
|
||||
while ((flag = getopt(argc, argv, "B:d:D:X:Fo:px:")) != -1)
|
||||
{
|
||||
switch (flag)
|
||||
{
|
||||
case 'D':
|
||||
potential_DataDir = optarg;
|
||||
break;
|
||||
case 'X':
|
||||
potential_XLogDir = optarg;
|
||||
break;
|
||||
case 'd':
|
||||
{
|
||||
/* Turn on debugging for the bootstrap process. */
|
||||
@ -315,6 +321,7 @@ BootstrapMain(int argc, char *argv[])
|
||||
proc_exit(1);
|
||||
}
|
||||
SetDataDir(potential_DataDir);
|
||||
SetXLogDir(potential_XLogDir);
|
||||
}
|
||||
|
||||
/* Validate we have been given a reasonable-looking DataDir */
|
||||
|
@ -37,7 +37,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/postmaster/postmaster.c,v 1.281 2002/07/13 01:02:14 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/postmaster/postmaster.c,v 1.282 2002/08/04 06:26:38 thomas Exp $
|
||||
*
|
||||
* NOTES
|
||||
*
|
||||
@ -347,6 +347,7 @@ PostmasterMain(int argc, char *argv[])
|
||||
int status;
|
||||
char original_extraoptions[MAXPGPATH];
|
||||
char *potential_DataDir = NULL;
|
||||
char *potential_XLogDir = NULL;
|
||||
|
||||
*original_extraoptions = '\0';
|
||||
|
||||
@ -405,10 +406,11 @@ PostmasterMain(int argc, char *argv[])
|
||||
InitializeGUCOptions();
|
||||
|
||||
potential_DataDir = getenv("PGDATA"); /* default value */
|
||||
potential_XLogDir = getenv("PGXLOG"); /* default value */
|
||||
|
||||
opterr = 1;
|
||||
|
||||
while ((opt = getopt(argc, argv, "A:a:B:b:c:D:d:Fh:ik:lm:MN:no:p:Ss-:")) != -1)
|
||||
while ((opt = getopt(argc, argv, "A:a:B:b:c:D:X:d:Fh:ik:lm:MN:no:p:Ss-:")) != -1)
|
||||
{
|
||||
switch (opt)
|
||||
{
|
||||
@ -431,6 +433,9 @@ PostmasterMain(int argc, char *argv[])
|
||||
case 'D':
|
||||
potential_DataDir = optarg;
|
||||
break;
|
||||
case 'X':
|
||||
potential_XLogDir = optarg;
|
||||
break;
|
||||
case 'd':
|
||||
{
|
||||
/* Turn on debugging for the postmaster. */
|
||||
@ -565,6 +570,7 @@ PostmasterMain(int argc, char *argv[])
|
||||
|
||||
checkDataDir(potential_DataDir); /* issues error messages */
|
||||
SetDataDir(potential_DataDir);
|
||||
SetXLogDir(potential_XLogDir);
|
||||
|
||||
ProcessConfigFile(PGC_POSTMASTER);
|
||||
|
||||
|
@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/tcop/postgres.c,v 1.277 2002/08/04 04:31:44 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/tcop/postgres.c,v 1.278 2002/08/04 06:26:33 thomas Exp $
|
||||
*
|
||||
* NOTES
|
||||
* this is the "main" module of the postgres backend and
|
||||
@ -1146,6 +1146,7 @@ PostgresMain(int argc, char *argv[], const char *username)
|
||||
StringInfo parser_input;
|
||||
|
||||
char *potential_DataDir = NULL;
|
||||
char *potential_XLogDir = NULL;
|
||||
|
||||
/*
|
||||
* Catch standard options before doing much else. This even works on
|
||||
@ -1190,6 +1191,7 @@ PostgresMain(int argc, char *argv[], const char *username)
|
||||
{
|
||||
InitializeGUCOptions();
|
||||
potential_DataDir = getenv("PGDATA");
|
||||
potential_XLogDir = getenv("PGXLOG");
|
||||
}
|
||||
|
||||
/* ----------------
|
||||
@ -1214,7 +1216,7 @@ PostgresMain(int argc, char *argv[], const char *username)
|
||||
ctx = PGC_POSTMASTER;
|
||||
gucsource = PGC_S_ARGV; /* initial switches came from command line */
|
||||
|
||||
while ((flag = getopt(argc, argv, "A:B:c:CD:d:Eef:FiNOPo:p:S:st:v:W:x:-:")) != -1)
|
||||
while ((flag = getopt(argc, argv, "A:B:c:CD:X:d:Eef:FiNOPo:p:S:st:v:W:x:-:")) != -1)
|
||||
switch (flag)
|
||||
{
|
||||
case 'A':
|
||||
@ -1246,6 +1248,11 @@ PostgresMain(int argc, char *argv[], const char *username)
|
||||
potential_DataDir = optarg;
|
||||
break;
|
||||
|
||||
case 'X': /* PGXLOG directory */
|
||||
if (secure)
|
||||
potential_XLogDir = optarg;
|
||||
break;
|
||||
|
||||
case 'd': /* debug level */
|
||||
{
|
||||
/* Set server debugging level. */
|
||||
@ -1537,8 +1544,10 @@ PostgresMain(int argc, char *argv[], const char *username)
|
||||
proc_exit(1);
|
||||
}
|
||||
SetDataDir(potential_DataDir);
|
||||
SetXLogDir(potential_XLogDir);
|
||||
}
|
||||
Assert(DataDir);
|
||||
Assert(strlen(XLogDir) > 0);
|
||||
|
||||
/*
|
||||
* Set up signal handlers and masks.
|
||||
@ -1693,7 +1702,7 @@ PostgresMain(int argc, char *argv[], const char *username)
|
||||
if (!IsUnderPostmaster)
|
||||
{
|
||||
puts("\nPOSTGRES backend interactive interface ");
|
||||
puts("$Revision: 1.277 $ $Date: 2002/08/04 04:31:44 $\n");
|
||||
puts("$Revision: 1.278 $ $Date: 2002/08/04 06:26:33 $\n");
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -27,7 +27,7 @@
|
||||
# Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
|
||||
# Portions Copyright (c) 1994, Regents of the University of California
|
||||
#
|
||||
# $Header: /cvsroot/pgsql/src/bin/initdb/Attic/initdb.sh,v 1.163 2002/07/29 22:14:11 tgl Exp $
|
||||
# $Header: /cvsroot/pgsql/src/bin/initdb/Attic/initdb.sh,v 1.164 2002/08/04 06:26:38 thomas Exp $
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
|
||||
@ -252,6 +252,19 @@ do
|
||||
-D*)
|
||||
PGDATA=`echo $1 | sed 's/^-D//'`
|
||||
;;
|
||||
# Directory to hold WAL log files.
|
||||
--pgxlog|-X)
|
||||
PGXLOG="$2"
|
||||
defined_pgxlog=yes
|
||||
shift;;
|
||||
--pgxlog=*)
|
||||
PGXLOG=`echo $1 | sed 's/^--pgxlog=//'`
|
||||
defined_pgxlog=yes
|
||||
;;
|
||||
-X*)
|
||||
PGXLOG=`echo $1 | sed 's/^-X//'`
|
||||
defined_pgxlog=yes
|
||||
;;
|
||||
# The directory where the .bki input files are stored. Normally
|
||||
# they are in PREFIX/share and this option should be unnecessary.
|
||||
-L)
|
||||
@ -341,6 +354,7 @@ if [ "$usage" ]; then
|
||||
echo
|
||||
echo "Options:"
|
||||
echo " [-D, --pgdata] DATADIR Location for this database cluster"
|
||||
echo " [-X, --pgxlog] XLOGDIR Location for the cluster transaction logs"
|
||||
echo " -W, --pwprompt Prompt for a password for the new superuser"
|
||||
if [ -n "$MULTIBYTE" ] ; then
|
||||
echo " -E, --encoding ENCODING Set default encoding for new databases"
|
||||
@ -369,7 +383,7 @@ fi
|
||||
if [ "$MULTIBYTE" ]
|
||||
then
|
||||
MULTIBYTEID=`$PGPATH/pg_encoding -b $MULTIBYTE`
|
||||
if [ "$?" -ne 0 ]
|
||||
if [ "$?" -ne 0 ]
|
||||
then
|
||||
(
|
||||
echo "$CMDNAME: pg_encoding failed"
|
||||
@ -401,6 +415,11 @@ then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -z "$PGXLOG" ]
|
||||
then
|
||||
PGXLOG="$PGDATA"/pg_xlog
|
||||
fi
|
||||
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
# Find the input files
|
||||
@ -418,7 +437,7 @@ then
|
||||
(
|
||||
echo
|
||||
echo "initdb variables:"
|
||||
for var in PGDATA datadir PGPATH MULTIBYTE MULTIBYTEID \
|
||||
for var in PGDATA PGXLOG datadir PGPATH MULTIBYTE MULTIBYTEID \
|
||||
POSTGRES_SUPERUSERNAME POSTGRES_BKI \
|
||||
POSTGRES_DESCR POSTGRESQL_CONF_SAMPLE \
|
||||
PG_HBA_SAMPLE PG_IDENT_SAMPLE ; do
|
||||
@ -503,44 +522,61 @@ then
|
||||
echo "$CMDNAME: The directory $PGDATA exists but is not empty."
|
||||
echo "If you want to create a new database system, either remove or empty"
|
||||
echo "the directory $PGDATA or run initdb with"
|
||||
echo "an argument other than $PGDATA."
|
||||
echo "an argument for -D other than $PGDATA."
|
||||
) 1>&2
|
||||
exit 1
|
||||
else
|
||||
if [ ! -d "$PGDATA" ]; then
|
||||
$ECHO_N "creating directory $PGDATA... "$ECHO_C
|
||||
mkdir -p "$PGDATA" >/dev/null 2>&1 || mkdir "$PGDATA" || exit_nicely
|
||||
made_new_pgdata=yes
|
||||
else
|
||||
$ECHO_N "Fixing permissions on existing directory $PGDATA... "$ECHO_C
|
||||
chmod go-rwx "$PGDATA" || exit_nicely
|
||||
fi
|
||||
echo "ok"
|
||||
fi
|
||||
|
||||
if [ ! -d "$PGDATA"/base ]
|
||||
then
|
||||
$ECHO_N "creating directory $PGDATA/base... "$ECHO_C
|
||||
mkdir "$PGDATA"/base || exit_nicely
|
||||
echo "ok"
|
||||
fi
|
||||
if [ ! -d "$PGDATA"/global ]
|
||||
then
|
||||
$ECHO_N "creating directory $PGDATA/global... "$ECHO_C
|
||||
mkdir "$PGDATA"/global || exit_nicely
|
||||
echo "ok"
|
||||
fi
|
||||
if [ ! -d "$PGDATA"/pg_xlog ]
|
||||
then
|
||||
$ECHO_N "creating directory $PGDATA/pg_xlog... "$ECHO_C
|
||||
mkdir "$PGDATA"/pg_xlog || exit_nicely
|
||||
echo "ok"
|
||||
fi
|
||||
if [ ! -d "$PGDATA"/pg_clog ]
|
||||
then
|
||||
$ECHO_N "creating directory $PGDATA/pg_clog... "$ECHO_C
|
||||
mkdir "$PGDATA"/pg_clog || exit_nicely
|
||||
echo "ok"
|
||||
fi
|
||||
# find out if transaction log directory is empty
|
||||
pgxlog_contents=`ls -A "$PGXLOG" 2>/dev/null`
|
||||
if [ x"$pgxlog_contents" != x ]
|
||||
then
|
||||
(
|
||||
echo "$CMDNAME: The directory $PGXLOG exists but is not empty."
|
||||
echo "If you want to create a new transaction log, either remove or empty"
|
||||
echo "the directory $PGXLOG or run initdb with"
|
||||
echo "an argument for -X other than $PGXLOG."
|
||||
) 1>&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ ! -d "$PGDATA" ]; then
|
||||
$ECHO_N "creating directory $PGDATA... "$ECHO_C
|
||||
mkdir -p "$PGDATA" >/dev/null 2>&1 || mkdir "$PGDATA" || exit_nicely
|
||||
made_new_pgdata=yes
|
||||
else
|
||||
$ECHO_N "Fixing permissions on existing directory $PGDATA... "$ECHO_C
|
||||
chmod go-rwx "$PGDATA" || exit_nicely
|
||||
fi
|
||||
echo "ok"
|
||||
|
||||
if [ ! -d "$PGXLOG" ]; then
|
||||
$ECHO_N "creating directory $PGXLOG... "$ECHO_C
|
||||
mkdir -p "$PGXLOG" >/dev/null 2>&1 || mkdir "$PGXLOG" || exit_nicely
|
||||
made_new_pgxlog=yes
|
||||
else
|
||||
$ECHO_N "Fixing permissions on existing directory $PGXLOG... "$ECHO_C
|
||||
chmod go-rwx "$PGXLOG" || exit_nicely
|
||||
fi
|
||||
echo "ok"
|
||||
|
||||
if [ ! -d "$PGDATA"/base ]
|
||||
then
|
||||
$ECHO_N "creating directory $PGDATA/base... "$ECHO_C
|
||||
mkdir "$PGDATA"/base || exit_nicely
|
||||
echo "ok"
|
||||
fi
|
||||
if [ ! -d "$PGDATA"/global ]
|
||||
then
|
||||
$ECHO_N "creating directory $PGDATA/global... "$ECHO_C
|
||||
mkdir "$PGDATA"/global || exit_nicely
|
||||
echo "ok"
|
||||
fi
|
||||
if [ ! -d "$PGDATA"/pg_clog ]
|
||||
then
|
||||
$ECHO_N "creating directory $PGDATA/pg_clog... "$ECHO_C
|
||||
mkdir "$PGDATA"/pg_clog || exit_nicely
|
||||
echo "ok"
|
||||
fi
|
||||
|
||||
|
||||
@ -549,7 +585,7 @@ fi
|
||||
# RUN BKI SCRIPT IN BOOTSTRAP MODE TO CREATE TEMPLATE1
|
||||
|
||||
# common backend options
|
||||
PGSQL_OPT="-F -D$PGDATA"
|
||||
PGSQL_OPT="-F -D$PGDATA -X$PGXLOG"
|
||||
|
||||
if [ "$debug" = yes ]
|
||||
then
|
||||
@ -677,7 +713,6 @@ EOF
|
||||
echo "ok"
|
||||
fi
|
||||
|
||||
|
||||
$ECHO_N "enabling unlimited row size for system tables... "$ECHO_C
|
||||
|
||||
"$PGPATH"/postgres $PGSQL_OPT template1 >/dev/null <<EOF
|
||||
@ -1058,14 +1093,24 @@ echo "ok"
|
||||
#
|
||||
# FINISHED
|
||||
|
||||
postmaster_startup="$PGPATH/postmaster -D $PGDATA"
|
||||
if [ x"$defined_pgxlog" != x ]; then
|
||||
postmaster_startup="$postmaster_startup -X $PGXLOG"
|
||||
fi
|
||||
pg_ctl_startup="$PGPATH/pg_ctl -D $PGDATA"
|
||||
if [ x"$defined_pgxlog" != x ]; then
|
||||
pg_ctl_startup="$pg_ctl_startup -X $PGXLOG"
|
||||
fi
|
||||
pg_ctl_startup="$pg_ctl_startup -l logfile start"
|
||||
|
||||
echo
|
||||
echo "Success. You can now start the database server using:"
|
||||
echo ""
|
||||
echo " $PGPATH/postmaster -D $PGDATA"
|
||||
echo " $postmaster_startup"
|
||||
echo "or"
|
||||
# (Advertise -l option here, otherwise we have a background
|
||||
# process writing to the terminal.)
|
||||
echo " $PGPATH/pg_ctl -D $PGDATA -l logfile start"
|
||||
echo " $pg_ctl_startup"
|
||||
echo
|
||||
|
||||
exit 0
|
||||
|
@ -8,7 +8,7 @@
|
||||
#
|
||||
#
|
||||
# IDENTIFICATION
|
||||
# $Header: /cvsroot/pgsql/src/bin/pg_ctl/Attic/pg_ctl.sh,v 1.27 2002/07/19 15:31:42 momjian Exp $
|
||||
# $Header: /cvsroot/pgsql/src/bin/pg_ctl/Attic/pg_ctl.sh,v 1.28 2002/08/04 06:26:38 thomas Exp $
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
|
||||
@ -19,20 +19,23 @@ $CMDNAME is a utility to start, stop, restart, reload configuration files,
|
||||
or report the status of a PostgreSQL server.
|
||||
|
||||
Usage:
|
||||
$CMDNAME start [-w] [-D DATADIR] [-s] [-l FILENAME] [-o \"OPTIONS\"]
|
||||
$CMDNAME start [-w] [-D DATADIR] [-s] [-X PGXLOG] [-l FILENAME] [-o \"OPTIONS\"]
|
||||
$CMDNAME stop [-W] [-D DATADIR] [-s] [-m SHUTDOWN-MODE]
|
||||
$CMDNAME restart [-w] [-D DATADIR] [-s] [-m SHUTDOWN-MODE] [-o \"OPTIONS\"]
|
||||
$CMDNAME restart [-w] [-D DATADIR] [-s] [-X PGXLOG] [-m SHUTDOWN-MODE] [-o \"OPTIONS\"]
|
||||
$CMDNAME reload [-D DATADIR] [-s]
|
||||
$CMDNAME status [-D DATADIR]
|
||||
|
||||
Common options:
|
||||
-D DATADIR Location of the database storage area
|
||||
-X XLOGDIR Location of the WAL log file storage area
|
||||
-s Only print errors, no informational messages
|
||||
-w Wait until operation completes
|
||||
-W Do not wait until operation completes
|
||||
(The default is to wait for shutdown, but not for start or restart.)
|
||||
|
||||
If the -D option is omitted, the environment variable PGDATA is used.
|
||||
If the -X option is omitted, the environment variable PGXLOG is used
|
||||
or the postmaster defaults to looking in $PGDATA/pg_xlog.
|
||||
|
||||
Options for start or restart:
|
||||
-l FILENAME Write (or append) server log to FILENAME. The
|
||||
@ -132,6 +135,12 @@ do
|
||||
PGDATA="$1"
|
||||
export PGDATA
|
||||
;;
|
||||
-X)
|
||||
shift
|
||||
# pass environment into new postmaster
|
||||
PGXLOG="$1"
|
||||
export PGXLOG
|
||||
;;
|
||||
-l)
|
||||
logfile="$2"
|
||||
shift;;
|
||||
|
@ -6,7 +6,7 @@
|
||||
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* $Id: xlog.h,v 1.31 2002/06/20 20:29:43 momjian Exp $
|
||||
* $Id: xlog.h,v 1.32 2002/08/04 06:26:38 thomas Exp $
|
||||
*/
|
||||
#ifndef XLOG_H
|
||||
#define XLOG_H
|
||||
@ -175,6 +175,9 @@ typedef struct XLogRecData
|
||||
struct XLogRecData *next;
|
||||
} XLogRecData;
|
||||
|
||||
/* XLOG directory name */
|
||||
extern char XLogDir[];
|
||||
|
||||
extern StartUpID ThisStartUpID; /* current SUI */
|
||||
extern bool InRecovery;
|
||||
extern XLogRecPtr MyLastRecPtr;
|
||||
@ -189,6 +192,7 @@ extern int XLOG_DEBUG;
|
||||
extern char *XLOG_sync_method;
|
||||
extern const char XLOG_sync_method_default[];
|
||||
|
||||
extern void SetXLogDir(char *path);
|
||||
|
||||
extern XLogRecPtr XLogInsert(RmgrId rmid, uint8 info, XLogRecData *rdata);
|
||||
extern void XLogFlush(XLogRecPtr RecPtr);
|
||||
|
Loading…
x
Reference in New Issue
Block a user