From 3644223660fb67941a4ae9163f61c629547ae6b8 Mon Sep 17 00:00:00 2001 From: miker Date: Fri, 21 Aug 2009 05:14:25 +0000 Subject: [PATCH] beginnings of database replication helper scripts git-svn-id: svn://svn.open-ils.org/ILS/trunk@13911 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- Open-ILS/examples/build-eg-replication.sh | 105 ++++++++++++++++++++++++++++++ 1 file changed, 105 insertions(+) create mode 100644 Open-ILS/examples/build-eg-replication.sh diff --git a/Open-ILS/examples/build-eg-replication.sh b/Open-ILS/examples/build-eg-replication.sh new file mode 100644 index 0000000000..9da71b7370 --- /dev/null +++ b/Open-ILS/examples/build-eg-replication.sh @@ -0,0 +1,105 @@ +#!/bin/sh +# +# Copyright (C) 2009 Equinox Software, Inc. +# Author: Mike Rylander +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# + +# +# This script will help build the slonik scripts required to start +# replicating an Evergreen database using Slony-I. +# +# See: slony-1.2.16/tools/configure-replication.txt +# for more information on the process +# +# See: slony1-1.2.16/doc/adminguide/firstdb.html +# for an example of how to get the schema copied +# + +if [ "_$NUMNODES" == "_" ]; then + echo 'Please set the NUMNODES environment variable to the number of new nodes to be created in the new cluster' + exit +fi + +if [ "_$CLUSTER" == "_" ]; then + echo 'Please set the CLUSTER environment variable to the new cluster name' + exit +fi + +if [ "_$PGDATABASE" == "_" ]; then + echo 'Please set the PGDATABASE environment variable to the database name' + exit +fi + +if [ "_$PGPORT" == "_" ]; then + echo 'Please set the PGPORT environment variable to the database port' + exit +fi + +if [ "_$PGUSER" == "_" ]; then + echo 'Please set the PGPORT environment variable to the database superuser' + exit +fi + +TABLES=$(psql -tc " + select array_to_string(array_accum(table_schema || '.' || table_name),' ') + from information_schema.tables + where table_schema in ( + 'action', 'actor', 'asset', 'authority', 'auditor', 'biblio', 'config', + 'container', 'extend_reporter', 'metabib', 'money', 'offline', 'permission', + 'reporter', 'search', 'stats', 'vandely' + ) and table_type = 'BASE TABLE' order by 1; +") + +SEQUENCES=$(psql -tc "select array_to_string(array_accum(schemaname || '.' || relname),' ') from pg_statio_user_sequences;") + + +if [ "_$1" == "_" ]; then + echo 'Please specify at least one host!' + exit +fi + +DB1=$PGDATABASE +USER1=$PGUSER +PORT1=$PGPORT +HOST1=$1 + +if [ "_$2" != "_" ]; then + DB2=$PGDATABASE + USER2=$PGUSER + PORT2=$PGPORT + HOST2=$2 +fi + +if [ "_$3" != "_" ]; then + DB3=$PGDATABASE + USER3=$PGUSER + PORT3=$PGPORT + HOST3=$3 +fi + +if [ "_$4" != "_" ]; then + DB4=$PGDATABASE + USER4=$PGUSER + PORT4=$PGPORT + HOST4=$4 +fi + +if [ "_$5" != "_" ]; then + DB5=$PGDATABASE + USER5=$PGUSER + PORT5=$PGPORT + HOST5=$5 +fi + +./configure-replication.sh + -- 2.11.0