mirror of
https://github.com/EnterpriseDB/repmgr.git
synced 2026-03-23 07:06:30 +00:00
Apply log should be pg_xlog_receive_location() - pg_xlog_replay_location().
Also remove get_last_xlog_replay_timestamp() function and the sql_utils dir, we can readded later if we need. We don't need the column last_wal_standby_timestamp in repl_status, so remove it
This commit is contained in:
19
INSTALL
19
INSTALL
@@ -5,19 +5,13 @@ This module is for monitor a cluster, to install follow next steps
|
||||
|
||||
On Primary:
|
||||
|
||||
1) Install last_xlog_replay_timestamp() function
|
||||
2) Create tables for repmgr configuration and monitor (see repmgr.sql)
|
||||
3) Edit repmgr.conf
|
||||
1) Create tables for repmgr configuration and monitor (see repmgr.sql)
|
||||
2) Edit repmgr.conf
|
||||
|
||||
On Standby:
|
||||
|
||||
1) Install xlog_replay_time module
|
||||
NOTE: this should be done before the standby starts for the first time,
|
||||
the reason is that when the standby tries to replay WAL segment
|
||||
where the function was created this file should exist or it will
|
||||
be an error.
|
||||
2) Start replica
|
||||
3) Edit repmgr.conf
|
||||
1) Start replica
|
||||
2) Edit repmgr.conf
|
||||
|
||||
|
||||
|
||||
@@ -28,11 +22,6 @@ make USE_PGXS=1
|
||||
make install USE_PGXS=1
|
||||
|
||||
|
||||
Installing last_xlog_replay_timestamp() function
|
||||
-------------------------------------------------
|
||||
psql -f $PGDIR/share/contrib/xlog_replay_time.sql
|
||||
|
||||
|
||||
repmgr.conf
|
||||
------------
|
||||
|
||||
|
||||
9
main.c
9
main.c
@@ -195,7 +195,6 @@ MonitorExecute(void)
|
||||
char last_wal_primary_location[MAXLEN];
|
||||
char last_wal_standby_received[MAXLEN];
|
||||
char last_wal_standby_applied[MAXLEN];
|
||||
char last_wal_standby_timestamp[MAXLEN];
|
||||
|
||||
unsigned long long int lsn_primary;
|
||||
unsigned long long int lsn_standby_received;
|
||||
@@ -204,7 +203,7 @@ MonitorExecute(void)
|
||||
/* Get local xlog info */
|
||||
sprintf(sqlquery,
|
||||
"SELECT CURRENT_TIMESTAMP, pg_last_xlog_receive_location(), "
|
||||
"pg_last_xlog_replay_location(), get_last_xlog_replay_timestamp()");
|
||||
"pg_last_xlog_replay_location()");
|
||||
|
||||
res = PQexec(myLocalConn, sqlquery);
|
||||
if (PQresultStatus(res) != PGRES_TUPLES_OK)
|
||||
@@ -217,7 +216,6 @@ MonitorExecute(void)
|
||||
strcpy(monitor_standby_timestamp, PQgetvalue(res, 0, 0));
|
||||
strcpy(last_wal_standby_received , PQgetvalue(res, 0, 1));
|
||||
strcpy(last_wal_standby_applied , PQgetvalue(res, 0, 2));
|
||||
strcpy(last_wal_standby_timestamp, PQgetvalue(res, 0, 3));
|
||||
PQclear(res);
|
||||
|
||||
/* Get primary xlog info */
|
||||
@@ -246,13 +244,12 @@ MonitorExecute(void)
|
||||
"INSERT INTO repl_status "
|
||||
"VALUES(%d, %d, '%s'::timestamp with time zone, "
|
||||
" '%s', '%s', "
|
||||
" '%s'::timestamp with time zone, "
|
||||
" %lld, %lld)",
|
||||
primaryId, myLocalId, monitor_standby_timestamp,
|
||||
last_wal_primary_location,
|
||||
last_wal_standby_received, last_wal_standby_timestamp,
|
||||
last_wal_standby_received,
|
||||
(lsn_primary - lsn_standby_received),
|
||||
(lsn_standby_applied - lsn_standby_received));
|
||||
(lsn_standby_received - lsn_standby_applied));
|
||||
|
||||
/*
|
||||
* Execute the query asynchronously, but don't check for a result. We
|
||||
|
||||
@@ -12,7 +12,6 @@ CREATE TABLE repl_status(
|
||||
last_monitor_timestamp TIMESTAMP WITH TIME ZONE NOT NULL,
|
||||
last_wal_primary_location TEXT NOT NULL,
|
||||
last_wal_standby_location TEXT NOT NULL,
|
||||
last_wal_standby_timestamp TIMESTAMP WITH TIME ZONE NOT NULL,
|
||||
replication_lag BIGINT NOT NULL,
|
||||
apply_lag BIGINT NOT NULL
|
||||
);
|
||||
|
||||
@@ -1,19 +0,0 @@
|
||||
#
|
||||
# Makefile
|
||||
# Copyright (c) 2ndQuadrant, 2010
|
||||
#
|
||||
|
||||
MODULE_big = repmgr_wrapper_funcs
|
||||
DATA_built=repmgr_wrapper_funcs.sql
|
||||
DATA=uninstall_repmgr_wrapper_funcs.sql
|
||||
OBJS=repmgr_wrapper_funcs.o
|
||||
|
||||
ifdef USE_PGXS
|
||||
PGXS := $(shell pg_config --pgxs)
|
||||
include $(PGXS)
|
||||
else
|
||||
subdir = contrib/repmgr/sql_utils
|
||||
top_builddir = ../../..
|
||||
include $(top_builddir)/src/Makefile.global
|
||||
include $(top_srcdir)/contrib/contrib-global.mk
|
||||
endif
|
||||
@@ -1,31 +0,0 @@
|
||||
/*
|
||||
* repmgr_wrapper_funcs.c
|
||||
* Copyright (c) 2ndQuadrant, 2010
|
||||
*
|
||||
* Expose some backend functions in SQL
|
||||
*/
|
||||
|
||||
#include "postgres.h"
|
||||
#include "fmgr.h"
|
||||
#include "access/xlog.h"
|
||||
|
||||
PG_MODULE_MAGIC;
|
||||
|
||||
Datum last_xlog_replay_timestamp(PG_FUNCTION_ARGS);
|
||||
|
||||
PG_FUNCTION_INFO_V1(last_xlog_replay_timestamp);
|
||||
|
||||
Datum
|
||||
last_xlog_replay_timestamp(PG_FUNCTION_ARGS)
|
||||
{
|
||||
TimestampTz rTime;
|
||||
bool fromStream;
|
||||
|
||||
if (!RecoveryInProgress())
|
||||
PG_RETURN_NULL();
|
||||
else
|
||||
{
|
||||
GetXLogReceiptTime(&rTime, &fromStream);
|
||||
PG_RETURN_TIMESTAMPTZ(rTime);
|
||||
}
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
/*
|
||||
* repmgr_wrapper_function.sql
|
||||
* Copyright (c) 2ndQuadrant, 2010
|
||||
*
|
||||
*/
|
||||
|
||||
CREATE FUNCTION get_last_xlog_replay_timestamp() RETURNS timestamp with time zone
|
||||
AS 'MODULE_PATHNAME', 'last_xlog_replay_timestamp'
|
||||
LANGUAGE C STRICT;
|
||||
@@ -1 +0,0 @@
|
||||
DROP FUNCTION get_last_xlog_replay_timestamp();
|
||||
Reference in New Issue
Block a user