Skip to content

Commit e03cc5a

Browse files
committed
Initial import
Import the pgsqlms script, its required libs, docs and others files from its old location in the pgsql-resource-agent repository. For history, see: https://github.com/dalibo/pgsql-resource-agent
1 parent 3ff18e8 commit e03cc5a

21 files changed

+3630
-0
lines changed

Build.PL

Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
#!/usr/bin/env perl
2+
3+
use strict;
4+
use warnings;
5+
6+
use File::Spec;
7+
use Storable;
8+
use Module::Build;
9+
10+
my $lib_ocf_root = '/usr/lib/ocf';
11+
my $ocft_confs = '/usr/share/resource-agents/ocft/configs';
12+
my $lib_ocf_dirs;
13+
my $ocf_dirs;
14+
my %ocf_dirs;
15+
16+
my $build = Module::Build->new(
17+
module_name => 'PAF',
18+
license => 'bsd',
19+
requires => {
20+
'perl' => '5.8.0'
21+
},
22+
create_packlist => 1,
23+
#create_readme => 1,
24+
create_makefile_pl => 'traditional',
25+
dist_version => '1.0.0',
26+
dist_abstract => 'PostgreSQL multistate OCF resource agent for Pacemaker',
27+
dist_author => [
28+
'Mael Rimbault <[email protected]>',
29+
'Jehan-Guillaume <[email protected]>'
30+
],
31+
script_files => [ 'script/pgsqlms' ],
32+
PL_files => {
33+
'lib/OCF_Directories.pm.PL' => 'lib/OCF_Directories.pm'
34+
},
35+
tests_files => {
36+
't/pgsqlms' => 'tests/pgsqlms'
37+
},
38+
get_options => {
39+
with_ocf_root => {
40+
type => '=s',
41+
store => \$lib_ocf_root
42+
},
43+
with_ocft_confs => {
44+
type => '=s',
45+
store => \$ocft_confs
46+
}
47+
},
48+
add_to_cleanup => [
49+
'lib/OCF_Directories.pm',
50+
],
51+
meta_merge => {
52+
resources => {
53+
'homepage' => 'http://dalibo.github.io/PAF/',
54+
'repository' => 'https://github.com/dalibo/PAF',
55+
'bugtracker' => 'https://github.com/dalibo/PAF/issues'
56+
}
57+
},
58+
);
59+
60+
# Check given ocf_root or default values
61+
for my $dir (
62+
$lib_ocf_root, '/usr/lib/ocf', '/usr/lib32/ocf', '/usr/lib64/ocf'
63+
) {
64+
if ( -d $dir and -s "$dir/lib/heartbeat/ocf-directories" ) {
65+
print STDERR "Found OCF_ROOT: $dir\n";
66+
$lib_ocf_root = $dir;
67+
last;
68+
}
69+
}
70+
71+
$lib_ocf_dirs = "$lib_ocf_root/lib/heartbeat/ocf-directories";
72+
73+
die "Couldn't find OCF shell functions in «OCF_ROOT/lib/heartbeat»!\n"
74+
."Try to build using the --with_ocf_root argument.\n" if ! -f $lib_ocf_dirs;
75+
76+
$ocf_dirs = qx{
77+
. "$lib_ocf_dirs" 2> /dev/null
78+
echo "\$INITDIR"
79+
echo "\$HA_DIR"
80+
echo "\$HA_RCDIR"
81+
echo "\$HA_CONFDIR"
82+
echo "\$HA_CF"
83+
echo "\$HA_VARLIB"
84+
echo "\$HA_RSCTMP"
85+
echo "\$HA_RSCTMP_OLD"
86+
echo "\$HA_FIFO"
87+
echo "\$HA_BIN"
88+
echo "\$HA_SBIN_DIR"
89+
echo "\$HA_DATEFMT"
90+
echo "\$HA_DEBUGLOG"
91+
echo "\$HA_RESOURCEDIR"
92+
echo "\$HA_DOCDIR"
93+
echo "\$HA_VARRUN"
94+
echo "\$HA_VARLOCK"
95+
echo "\$prefix"
96+
echo "\$exec_prefix"
97+
};
98+
99+
@ocf_dirs{
100+
'INITDIR', 'HA_DIR', 'HA_RCDIR', 'HA_CONFDIR', 'HA_CF',
101+
'HA_VARLIB', 'HA_RSCTMP', 'HA_RSCTMP_OLD', 'HA_FIFO', 'HA_BIN',
102+
'HA_SBIN_DIR', 'HA_DATEFMT', 'HA_DEBUGLOG', 'HA_RESOURCEDIR', 'HA_DOCDIR',
103+
'HA_VARRUN', 'HA_VARLOCK', 'prefix', 'exec_prefix'
104+
} = split /\n/ => $ocf_dirs;
105+
106+
$build->install_path( 'lib' => "$lib_ocf_root/lib/heartbeat" );
107+
$build->install_path( 'script' => "$lib_ocf_root/resource.d/heartbeat" );
108+
109+
for my $dir (
110+
$ocft_confs, "$ocf_dirs{'prefix'}/share/resource-agents/ocft/configs"
111+
) {
112+
if ( -d $dir ) {
113+
print STDERR "Found OCFT_CONFS: $dir\n";
114+
$ocft_confs = $dir;
115+
116+
$build->add_build_element('tests');
117+
$build->install_path( 'tests' => "$ocft_confs" );
118+
last;
119+
}
120+
}
121+
122+
$build->create_build_script;
123+
124+
Storable::store( \%ocf_dirs, File::Spec->tmpdir."/ocf_dirs.bin" );

LICENSE

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
Copyright (c) 2016, Jehan-Guillaume de Rorthais, Mael Rimbault.
2+
3+
Permission to use, copy, modify, and distribute this software and its
4+
documentation for any purpose, without fee, and without a written agreement
5+
is hereby granted, provided that the above copyright notice and this
6+
paragraph and the following two paragraphs appear in all copies.
7+
8+
IN NO EVENT SHALL THE AUTHOR OR DISTRIBUTORS BE LIABLE TO ANY PARTY FOR
9+
DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING
10+
LOST PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS
11+
DOCUMENTATION, EVEN IF THE AUTHOR OR DISTRIBUTORS HAVE BEEN ADVISED OF THE
12+
POSSIBILITY OF SUCH DAMAGE.
13+
14+
THE AUTHOR AND DISTRIBUTORS SPECIFICALLY DISCLAIMS ANY WARRANTIES,
15+
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
16+
AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
17+
ON AN "AS IS" BASIS, AND THE AUTHOR AND DISTRIBUTORS HAS NO OBLIGATIONS TO
18+
PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
19+

MANIFEST

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
Build.PL
2+
LICENSE
3+
MANIFEST This list of files
4+
README.md
5+
docs/FENCING.md
6+
docs/INSTALL.md
7+
docs/Quick_Start-CentOS-6.md
8+
docs/Quick_Start-CentOS-7.md
9+
lib/OCF_Directories.pm.PL
10+
lib/OCF_Functions.pm
11+
lib/OCF_ReturnCodes.pm
12+
script/pgsqlms
13+
t/pgsqlms
14+
t/README

MANIFEST.SKIP

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
2+
#!start included /usr/share/perl/5.20/ExtUtils/MANIFEST.SKIP
3+
# Avoid version control files.
4+
\bRCS\b
5+
\bCVS\b
6+
\bSCCS\b
7+
,v$
8+
\B\.svn\b
9+
\B\.git\b
10+
\B\.gitignore\b
11+
\b_darcs\b
12+
\B\.cvsignore$
13+
14+
# Avoid VMS specific MakeMaker generated files
15+
\bDescrip.MMS$
16+
\bDESCRIP.MMS$
17+
\bdescrip.mms$
18+
19+
# Avoid Makemaker generated and utility files.
20+
\bMANIFEST\.bak
21+
\bMakefile$
22+
\bblib/
23+
\bMakeMaker-\d
24+
\bpm_to_blib\.ts$
25+
\bpm_to_blib$
26+
\bblibdirs\.ts$ # 6.18 through 6.25 generated this
27+
28+
# Avoid Module::Build generated and utility files.
29+
\bBuild$
30+
\b_build/
31+
\bBuild.bat$
32+
\bBuild.COM$
33+
\bBUILD.COM$
34+
\bbuild.com$
35+
36+
# Avoid temp and backup files.
37+
~$
38+
\.old$
39+
\#$
40+
\b\.#
41+
\.bak$
42+
\.tmp$
43+
\.#
44+
\.rej$
45+
46+
# Avoid OS-specific files/dirs
47+
# Mac OSX metadata
48+
\B\.DS_Store
49+
# Mac OSX SMB mount metadata files
50+
\B\._
51+
52+
# Avoid Devel::Cover and Devel::CoverX::Covered files.
53+
\bcover_db\b
54+
\bcovered\b
55+
56+
# Avoid MYMETA files
57+
^MYMETA\.
58+
#!end included /usr/share/perl/5.20/ExtUtils/MANIFEST.SKIP
59+
60+
# Avoid configuration metadata file
61+
^MYMETA\.
62+
63+
# Avoid Module::Build generated and utility files.
64+
\bBuild$
65+
\bBuild.bat$
66+
\b_build
67+
\bBuild.COM$
68+
\bBUILD.COM$
69+
\bbuild.com$
70+
^MANIFEST\.SKIP
71+
72+
# Avoid archives of this distribution
73+
\bPAF-[\d\.\_]+
74+
75+
# Avoid developers doc
76+
^docs\/dev\/.*

README.md

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
# PostgreSQL Automatic Failover
2+
3+
High-Availibility for Postgres, based industry references on Pacemaker and
4+
Corosync.
5+
6+
## Description
7+
8+
Pacemaker is nowadays the industry reference for High Availability. In the same
9+
fashion than for Systemd, all Linux distributions moved (or are moving) to this
10+
unique Pacemaker+Corosync stack, removing all other existing high availability
11+
stacks (CMAN, RGManager, OpenAIS, ...). It is able to detect failure on various
12+
services and automatically decide to failover the failing resource to another
13+
node when possible.
14+
15+
To be able to manage a specific service resource, Pacemaker interact with it
16+
through a so-called "Resource Agent". Resource agents must comply to the OCF
17+
specification which define what they must implement (start, stop, promote,
18+
etc), how they should behave and inform Pacemaker of their results.
19+
20+
PostgreSQL Automatic Failover is a new OCF resource Agent dedicated to
21+
PostgreSQL. Its original wish is to keep a clear limit between the Pacemaker
22+
administration and the PostgreSQL one, to keep things simple, documented and
23+
yet powerful.
24+
25+
Once your PostgreSQL cluster built using internal streaming replication, PAF is
26+
able to expose to Pacemaker what is the current status of the PostgreSQL
27+
instance on each node: master, slave, stopped, catching up, etc. Should a
28+
failure occurs on the master, Pacemaker will try to recover it by default.
29+
Should the failure be non-recoverable, PAF allows the slaves to be able to
30+
elect the best of them (the closest one to the old master) and promote it as
31+
the new master. All of this thanks to the robust, feature-full and most
32+
importantly experienced project: Pacemaker.
33+
34+
For information about how to install this agent, see``docs/INSTALL.md``.
35+
36+
## Setup and requirements
37+
38+
PAF supports PostgreSQL 9.3 and higher. It has been extensively tested under
39+
CentOS 6 and 7 in various scenario.
40+
41+
PAF has been written to give to the administrator the maximum control
42+
over their PostgreSQL configuration and architecture. Thus, you are 100%
43+
responsible for the master/slave creations and their setup. The agent
44+
will NOT edit your setup. It only requires you to follow these pre-requisites:
45+
46+
* slave __must__ be in hot_standby (accept read-only connections)
47+
* you __must__ provide a template file on each node which will be copied as
48+
the local ``recovery.conf`` when needed by the agent
49+
* the recovery template file __must__ contain ``standby_mode = on``
50+
* the recovery template file __must__ contain ``recovery_target_timeline = 'latest'``
51+
* the ``primary_conninfo`` parameter in the recovery template file __must__
52+
set the ``application_name`` to the node name as seen in Pacemaker
53+
(usually, the hostname)
54+
55+
When setting up the resource in Pacemaker, here are the available parameters you
56+
can set:
57+
58+
* ``bindir``: location of the PostgreSQL binaries (default: ``/usr/bin``)
59+
* ``pgdata``: location of the PGDATA of your instance (default:
60+
``/var/lib/pgsql/data``)
61+
* ``pghost``: the socket directory or IP address to use to connect to the
62+
local instance (default: ``/tmp``)
63+
* ``pgport``: the port to connect to the local instance (default: ``5432``)
64+
* ``recovery_tpl``: the local template that will be copied as the
65+
``PGDATA/recovery.conf`` file. This template file must exists on all node
66+
(default: ``$PGDATA/recovery.conf.pcmk``)
67+
* ``system_user``: the system owner of your instance's process (default:
68+
``postgres``)
69+
70+
For a demonstration about how to setup a cluster, see
71+
``docs/Quick_Start-CentOS-6.md`` or ``docs/Quick_Start-CentOS-7.md``.
72+

0 commit comments

Comments
 (0)