mirror of
https://github.com/EnterpriseDB/repmgr.git
synced 2026-03-24 07:36:30 +00:00
Merge commit '3ef1fa126d9c9b9ba3b29deab7f67218cdf7ce10'
Conflicts: .gitignore Makefile README.rst check_dir.c config.c config.h dbutils.h repmgr.c repmgr.conf repmgr.h repmgrd.c
This commit is contained in:
36
repmgr.sql
36
repmgr.sql
@@ -1,3 +1,10 @@
|
||||
/*
|
||||
* repmgr.sql
|
||||
*
|
||||
* Copyright (C) 2ndQuadrant, 2011
|
||||
*
|
||||
*/
|
||||
|
||||
CREATE USER repmgr;
|
||||
CREATE SCHEMA repmgr;
|
||||
|
||||
@@ -5,27 +12,25 @@ CREATE SCHEMA repmgr;
|
||||
* The table repl_nodes keeps information about all machines in
|
||||
* a cluster
|
||||
*/
|
||||
drop table if exists repl_nodes cascade;
|
||||
CREATE TABLE repl_nodes (
|
||||
id integer primary key,
|
||||
cluster text not null, -- Name to identify the cluster
|
||||
conninfo text not null
|
||||
id integer primary key,
|
||||
cluster text not null, -- Name to identify the cluster
|
||||
conninfo text not null
|
||||
);
|
||||
ALTER TABLE repl_nodes OWNER TO repmgr;
|
||||
|
||||
/*
|
||||
* Keeps monitor info about every node and their relative "position"
|
||||
* Keeps monitor info about every node and their relative "position"
|
||||
* to primary
|
||||
*/
|
||||
drop table if exists repl_monitor cascade;
|
||||
CREATE TABLE repl_monitor (
|
||||
primary_node INTEGER NOT NULL,
|
||||
standby_node INTEGER NOT NULL,
|
||||
last_monitor_time TIMESTAMP WITH TIME ZONE NOT NULL,
|
||||
last_wal_primary_location TEXT NOT NULL,
|
||||
last_monitor_time TIMESTAMP WITH TIME ZONE NOT NULL,
|
||||
last_wal_primary_location TEXT NOT NULL,
|
||||
last_wal_standby_location TEXT NOT NULL,
|
||||
replication_lag BIGINT NOT NULL,
|
||||
apply_lag BIGINT NOT NULL
|
||||
replication_lag BIGINT NOT NULL,
|
||||
apply_lag BIGINT NOT NULL
|
||||
);
|
||||
ALTER TABLE repl_monitor OWNER TO repmgr;
|
||||
|
||||
@@ -33,21 +38,20 @@ ALTER TABLE repl_monitor OWNER TO repmgr;
|
||||
/*
|
||||
* This view shows the latest monitor info about every node.
|
||||
* Interesting thing to see:
|
||||
* replication_lag: in bytes (this is how far the latest xlog record
|
||||
* replication_lag: in bytes (this is how far the latest xlog record
|
||||
* we have received is from master)
|
||||
* apply_lag: in bytes (this is how far the latest xlog record
|
||||
* we have applied is from the latest record we
|
||||
* we have applied is from the latest record we
|
||||
* have received)
|
||||
* time_lag: how many seconds are we from being up-to-date with master
|
||||
*/
|
||||
drop view if exists repl_status;
|
||||
CREATE VIEW repl_status AS
|
||||
WITH monitor_info AS (SELECT *, ROW_NUMBER() OVER (PARTITION BY primary_node, standby_node
|
||||
ORDER BY last_monitor_time desc)
|
||||
FROM repl_monitor)
|
||||
SELECT primary_node, standby_node, last_monitor_time, last_wal_primary_location,
|
||||
last_wal_standby_location, pg_size_pretty(replication_lag) replication_lag,
|
||||
pg_size_pretty(apply_lag) apply_lag,
|
||||
SELECT primary_node, standby_node, last_monitor_time, last_wal_primary_location,
|
||||
last_wal_standby_location, pg_size_pretty(replication_lag) replication_lag,
|
||||
pg_size_pretty(apply_lag) apply_lag,
|
||||
age(now(), last_monitor_time) AS time_lag
|
||||
FROM monitor_info a
|
||||
WHERE row_number = 1;
|
||||
|
||||
Reference in New Issue
Block a user