PostgreSQL

manlybluegooseΔιαχείριση Δεδομένων

27 Νοε 2012 (πριν από 5 χρόνια και 1 μήνα)

287 εμφανίσεις

Redefi ni ng Data Protecti on
NVE 7025-6A 07/23-07
PagePage
for
PostgreSQL
BakBone Software
9540 Towne Centre Drive, Suite 100  San Diego, California 92121  866.484.2663
Copyrights
NetVault:Replicator - Database Configuration Guide for PostgreSQL
Software Copyright © 2007 BakBone Software
Documentation Copyright © 2007 BakBone Software
This software product is copyrighted and all rights are reserved. The distribution and
sale of this product are intended for the use of the original purchaser only per the terms
of the License Agreement. All other product trademarks are the property of their
respective owners.
The NetVault:Replicator - Database Configuration Guide for PostgreSQL
documentation is copyrighted and all rights are reserved.
This document may not, in whole or part, be copied, photocopied, reproduced,
translated, reduced or transferred to any electronic medium or machine-readable form
without prior consent in writing from BakBone Software.
THIS PUBLICATION IS PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND,
EITHER EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE,
OR NON-INFRINGEMENT.
THIS PUBLICATION COULD INCLUDE TECHNICAL INACCURACIES OR
TYPOGRAPHICAL ERRORS. CHANGES ARE PERIODICALLY ADDED TO THE
INFORMATION HEREIN; THESE CHANGES WILL BE INCORPORATED INTO NEW
EDITIONS OF THE PUBLICATION. BAKBONE SOFTWARE MAY MAKE
IMPROVEMENTS AND/OR CHANGES IN THE PRODUCT(S) AND/OR THE
PROGRAM(S) DESCRIBED IN THIS PUBLICATION AT ANY TIME.
1.0.0 - NetVault:Replicator and PostgreSQL - An Overview
........................5
• 1.0.1 - Write Order Fidelity for Database Integrity
..................................................................5
• 1.0.2 - The Purpose of this Guide
.........................................................................................5
- 1.0.2.a - Target Audience
....................................................................................................5
- 1.0.2.b - Companion Documentation
....................................................................................5
- 1.0.2.c - Terminology Used in this Guide
..............................................................................6
1.1.0 - Phase 1: Installation
..........................................................................................6
• 1.1.1 - Step 1: Installation Pre-requisites
...............................................................................7
• 1.1.2 - Step 2: NetVault:Replicator Pre-Installation
................................................................7
• 1.1.3 - Step 3: Installing Replicator
.......................................................................................8
1.2.0 - Phase 2: Configuring for PostgreSQL
........................................................8
• 1.2.1 - Step 1: Creating the “nvr.conf” File
............................................................................8
- 1.2.1.a - Creating a Master “nvr.conf” File Manually
...............................................................8
1.3.0 - Phase 3: Replication
..........................................................................................9
• 1.3.1 - Initial Synchronization
.............................................................................................10
- 1.3.1.a - Step 1: Initiating the Synchronization
.....................................................................10
- 1.3.1.b - Step 2: Client Configuration
..................................................................................10
• 1.3.2 - On-going Replication Operations
.............................................................................11
1.4.0 - PostgreSQL Server Recovery
......................................................................11
- 1.4.0.a - Using the Standby PostgreSQL Server as the Primary Server
..................................11
- 1.4.0.b - Recovering the Primary PostgreSQL Server
..........................................................12
1.5.0 - Technical Support
.............................................................................................13
• 1.5.1 - Helpdesk Support Lines
...........................................................................................13
• 1.5.2 - BakBone Software’s Web Site
..................................................................................14
Working with PostgreSQL
Working with PostgreSQL
4
NetVault
®
:Replicator
Database Configuration Guide
5
1.0.0 NetVault:Replicator and PostgreSQL - An
Overview
NetVault:Replicator
TM
(also referred to herein as “Replicator”) is installed on a
PostgreSQL
®
Database Server to provide continuous data protection. This
application can be installed on these servers in the data center or on remote
servers in other offices or data centers. Once installed and configured, Replicator
continuously replicates changing byte-level data to dedicated hot-standby servers
located anywhere on a network. NetVault:Replicator continuously maintains an on-
line mirror backup on another server for increased protection and faster recovery.
Replicator is an efficient software that replicates only the changing bytes,
independent of the underlying storage. This unique capability allows the solution to
scale to protect any size of data.
1.0.1 Write Order Fidelity for Database Integrity
NetVault:Replicator continuously replicates changing byte-level data to dedicated
hot-standby servers located anywhere on a network. NetVault:Replicator offers
hybrid byte-level differencing technology that is optimized to provide reliable
replication of a PostgreSQL Server database in real-time while preserving write
ordering fidelity and the transactional integrity of the underlying database. The
software preserves the order of the write operations to guarantee changes are
applied consistently on the destination server to guarantee data integrity.
1.0.2 The Purpose of this Guide
This guide is intended to instruct IT managers, on any considerations and specific
configurations for NetVault:Replicator when installed on servers running
PostgreSQL software.
The procedures outlined in this guide will allow you to target a single PostgreSQL
Database Server and replicate its full range of database data to a second system.
This second system will then be usable as the PostgreSQL Database Server in the
event that the primary server is to fail.
1.0.2.a Target Audience
This guide is designed to assist an IT Manager in setting up Replicator to run in a
PostgreSQL Server environment. Therefore, it is recommended that only those
individuals with Administrator-level knowledge and access attempt any of the
procedures outlined in this guide.
1.0.2.b Companion Documentation
This document may reference both the NetVault
®
:Replicator - Installation Guide
and the NetVault
®
:Replicator - Administrator’s Guide. Have both of these
documents readily available for reference.
Working with PostgreSQL
6
1.0.2.c Terminology Used in this Guide
Following are some common terms used throughout this document, and a brief
definition for each.

Primary Production Server - This is the PostgreSQL Server that will serve
as the target of the Replication (i.e., the machine being replicated).

Standby Server - This is the machine that is configured to serve as the
destination of the replication (i.e., data is replicated from the Primary
Production Server to this machine).

“Active” vs. “Passive” - These two terms refer to the intended “end result”
state of the Hot-Standby Server. If the system is to be set up so that it can
immediately assume the role of a new PostgreSQL Server upon failure of the
Primary Production Server, it is considered “Active”. If the Standby Server is
intended to serve simply as a target for replicated data (e.g., individual
PostgreSQL database data is to be stored on the machine for later recovery
to the Primary Production Server), it is considered “Passive”.

Replication Sets (“Repsets”) - Repsets define the relationship between
hosts and data sets that are to be replicated. A repset contains information
that defines which machine is serving as the Primary Production Server (the
replication “source”), and which machine is acting as the Standby Server (the
replication “destination”). A Repset must consist of one source and at least
one destination.

Replication Scheme - This phrase is used to describe all of the systems
involved in the replication process (e.g., a Primary Production Server
replicating its PostgreSQL Database data to a Standby Server would
constitute a “Replication Scheme”).
1.1.0
Phase 1: Installation
Replicator does not require separate components be installed in order to support
the replication of a PostgreSQL Server. However, it does require that you perform
certain pre-requisite procedures before actually installing the Replicator software
(i.e., these pre-requisites must be met before installing any NetVault:Replicator
software on the PostgreSQL Server that is to be replicated as well as the
system(s) to which it is to be replicated).
NetVault
®
:Replicator
Database Configuration Guide
7
1.1.1 Step 1: Installation Pre-requisites
Prior to installing Replicator, the following pre-requisites must be met in order to
successfully use the software:

Both PostgreSQL servers (Primary and Standby) are installed and configured
correctly.

Both servers are running the same version of PostgreSQL database.

Both database servers configured the same way (i.e. both have the same
structures: database instances, tables, etc).

Both servers must be able to resolve each other's hostnames-for example
use a simple "ping" test or "dig/nslookup".

PostgreSQL should not be configured to start at system boot.

PostgreSQL should be shut down on both systems upon which Replicator is
to be installed.

Make Replicator a Permanent System Service:

It is recommended that Replicator be made a permanent system service
on the Primary and Standby Server. By doing so, the nvr_replicator
service will automatically restart after a system reboot. Issue the following
command:
chkconfig -level 2345 nvr_replicator on

The Postgresql service will not automatically restart after a system reboot.
Issue the following command:
chkconfig -level 0123456 postgresql off
1.1.2 Step 2: NetVault:Replicator Pre-Installation
With all of the pre-requisites discussed in the previous section completely met,
verify if database Postgresql is installed. To verify successful installation, perform
the following:
1.Initiate a terminal session.
2.Issue the following command at the prompt:
rpm -qa | grep postgresql
Important:
If you have already installed Replicator on any of the machines in a
PostgreSQL Server replication scheme, without first performing the pre-requisite procedures
outlined below, it may be necessary to remove and re-install Replicator from all relevant
machines. In this instance, please contact BakBone Software Technical Support for further
instructions -- for contact information, please see the section, Technical Support on page 13.
Working with PostgreSQL
8
1.1.3 Step 3: Installing Replicator
Review and perform all of the steps outlined in the NetVault
®
:Replicator -
Installation Guide in order to install the Replicator application on all machines in
the replication scheme.
1.2.0
Phase 2: Configuring for PostgreSQL
The sections that follow illustrate configuration of Replicator once it has been
successfully installed in order to accommodate the replication of a PostgreSQL
Server environment.
1.2.1 Step 1: Creating the “nvr.conf” File
Among other things, the “nvr.conf” is the file used by Replicator to specify what is
to be replicated on the Primary Production Server, and where it is to be replicated
to on the Standby Server. In order to properly replicate a PostgreSQL Server, you
must create an appropriate nvr.conf file. This can be accomplished using either
the NetVault:Replicator Availability Manager application (hereinafter referred to
as the “Replicator GUI”), or manually, using any text editing application.
1.2.1.a Creating a Master “nvr.conf” File Manually
This procedure requires the use of a text editing application to create an nvr.conf
with the proper settings, followed by saving the file on all relevant machines in the
PostgreSQL replication scheme. Follow the steps below to create the file:
1.Launch a text editing application (e.g., Notepad or Wordpad).
NetVault
®
:Replicator
Database Configuration Guide
9
Figure 1-1:
An example of
the input
required for
the “nvr.conf”
file to be used
2.Create a file to appear as revealed in
the image at right. The configuration
supplied should be modified, as it
assumes a number of things that may
not be true for any given environment:

The primary system is named
"primary".

The standby system is named
"secondary".

There's a machine called "gateway"
that's reliable and can be used to
arbitrate splitbrain.

The pgsql data and configuration files
are all under /var/lib/pgsql.

The startup script for Postgresql is /etc/
init.d/postgresql.
This configuration should be placed on both
the primary and secondary systems using a
network copy tool such as scp. The
nvr_verifyconfig utility should then be
used on both systems to verify that the two
hosts can successfully communicate each
other. After configuration, use chkconfig or
your system's equivalent to ensure that
Replicator will start upon reboot.
1.3.0
Phase 3: Replication
With all configuration procedures completed, it is now possible to begin the
replication process. The sections here outline the steps required to begin the
replication process.
Working with PostgreSQL
10
1.3.1 Initial Synchronization
The first step in beginning replication is to perform an initial synchronization of the
PostgreSQL Server database files and log files. This will sync all PostgreSQL
database files between the Primary Production Server and the Standby Server.
1.3.1.a
Step 1: Initiating the Synchronization
The initial synchronization can be performed using the procedure outlined below:
1.Initiate a terminal session on both systems, starting with the primary system,
and run the Replicator startup script.
2.Input the following command to begin the synchronization process:
nvr_sync -d /var/lib/
3.Verify that the initial synchronization completed successfully by running the
follwing command:
nvr_stat -l
While replication is active, the number of pending and in progress items in the
replication queue will be greater than zero. When the initial synchronization
finishes, the number of pending and in progress items reaches zero. Verify
that there are no reschedule tasks (or nvr_waitempty).
1.3.1.b Step 2: Client Configuration
All PostgreSQL clients should be configured to access PostgreSQL through the
fo_vaddr used in the nvr.conf configuration file. For ease of configuration and
use, BakBone recommends that this IP address should be associated with a
hostname using DNS so that all clients can be configured simply and correctly.
Replicator will set up this IP address on the interface described in the
configuration file for the primary system, and will migrate this IP to the standby
system when the primary system fails. It will also ensure that PostgreSQL is only
running on whichever system is the primary system at that time.
1.3.1.c Post-Synchronization
With the synchonization completed, the following must be performed:

Restart PostgreSQL Server on the Primary Production Server - After the
initial synchronization has completed and verified, PostgreSQL Server should
be started on the Primary Production Server. Please consult the relevant
PostgreSQL Server documentation for complete details on starting these
services.

Leave PostgreSQL Server Disabled on the Standby Server - Because the
Standby Server is only to be used in the event of a failure of the Primary
NetVault
®
:Replicator
Database Configuration Guide
11
Production Server, the PostgreSQL Server should never be started on the
destination server during replication.
1.3.2 On-going Replication Operations
The day-to-day operation of NetVault:Replicator requires little if any user
intervention. The “nvr_stat” tool may be used to monitor the status of the
replication service, including the number of replication events that have occurred,
the number of items currently being replicated, and the number of items that are
pending replication.
1.4.0
PostgreSQL Server Recovery
In the event of a system failure on the Primary Production Server, the replicated
database files and log files may be used to recover the state of PostgreSQL
Server on the Standby Server. After a failover, when the primary PostgreSQL
server is down, and the secondary PostgreSQL server is up and running, there are
two methods for resuming replication:
a.Continue to use the Standby PostgreSQL server as the main server.
b.Recover the Primary PostgreSQL server and use it again.
The following sections will outline the steps necessary for both methodologies.
1.4.0.a Using the Standby PostgreSQL Server as the Primary Server
Follow the steps below to set the Standby Server as the Primary Database Server
(i.e., in the event of Primary Production Server failure).
1.Shutdown PostgreSQL services if they are running.
2.Open a Command Prompt on the Standby server and issue the following
command:
nvr_pushconfig
This will bring up the Replicator services on the Primary PostgreSQL server.
3.Issue the following command on the Standby server:
nvr_sync -d <Postgresql datadir>
4.At this point, the Primary server is now the Standby server, and the Standby
server has become the Primary.
5.The setup is ready for another failover.
Important:
Ensure that the NetVault:Replicator configuration is modified to match the
current IP/hostnames.
Working with PostgreSQL
12
1.4.0.b Recovering the Primary PostgreSQL Server
Follow the steps below to recover the Primary Server for continued use and
shutdown the Standby Server (i.e., in the event of Primary Production Server
failure).
1.Start up the Primary PostgreSQL server system.
2.Shutdown the Primary PostgreSQL server if running.
3.Issue the following command on the Standby server:
nvr_sync -d <Postgresql datadir>
4.After the replication is complete, dissconnect/shutdown the system that the
Standby PostgreSQL server is running.
5.Wait for NetVault:Replicator to failover and startup the Primary PostgreSQL
server.
6.Boot the Standby PostgreSQL server system.
7.Issue the following command on the Primary Server:
nvr_pushconfig
8.The setup is ready for another failover.
Important:
Ensure that the NetVault:Replicator configuration is modified to match the
current IP/hostnames.
NetVault
®
:Replicator
Database Configuration Guide
13
1.1.0
Technical Support
BakBone Software is dedicated to providing friendly, expert advice to NetVault
customers. Our highly trained professionals are available to answer questions,
offer solutions to problems and generally help make the most of any NetVault
purchase. Log on to our web site, or contact our Helpdesk, for more information.
1.1.1 Helpdesk Support Lines
Region
Contact
North America
Telephone
1 877 955 BONE (2663)
E-mail
support@bakbone.com
Europe
Telephone
+44 (0) 1189 224 801
+44 (0)1189 224 802 (German) +49 (0)8 999 216 388 (German)
+44 (0)1189 224 803 (French) +33 (0)805 409 409 (French)
E-mail
support@bakbone.co.uk
Japan
Telephone
+81 3 5908 3511
E-mail:
support@bakbone.co.jp
Asia Pacific
Telephone
+81 3 5908 3517 (English) +81 3 5908 3816 (Chinese)
E-mail:
Multiple offices exist in our Asia, Pacific Rim district. Please con-
tact the closest support office for assistance:
Greater China Office:
India Office:
chinasupport@bakbone.com indiansupport@bakbone.com
Korea Office:
Southeast Asia Office:
koreasupport@bakbone.com aseansupport@bakbone.com
South Pacific Office:
anzsupport@bakbone.com
Working with PostgreSQL
14
1.1.2 BakBone Software’s Web Site
BakBone’s web site can be reached at the following address:
http://www.bakbone.com