GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • V11 Documentation
  • Privacy Statement
  • License Agreement
  • Contact Us

This view

  • Original page
  • New address

GeezerVison is showing docs.voltactivedata.com — 11.2. Using Passive Database Replication

  • Volt Active Data
  • Developer Hub
  • Books
    • VoltDB Tutorial
    • Using VoltDB
    • VoltDB Guide to Performance and Customization
    • VoltDB Administrator's Guide
    • Volt Kubernetes Administrator's Guide
    • VoltDB Quick Reference
  • Current docs ▶
  • VoltDB V11
    • VoltDB V16
    • VoltDB V15.3 LTS
    • VoltDB V14.3 LTS
    • VoltDB V13.3 LTS
    • VoltDB V12.3 LTS
    • VoltDB V11.4
    • VoltDB V10.2
    • VoltDB V9.3
11.2. Using Passive Database Replication

Using VoltDB

  • About This Book
  • 1. Overview▶
    • 1.1. What is VoltDB?
    • 1.2. Who Should Use VoltDB
    • 1.3. How VoltDB Works
      • 1.3.1. Partitioning
      • 1.3.2. Serialized (Single-Threaded) Processing
      • 1.3.3. Partitioned vs. Replicated Tables
      • 1.3.4. Ease of Scaling to Meet Application Needs
    • 1.4. Working with VoltDB Effectively
  • 2. Installing VoltDB▶
    • 2.1. Operating System and Software Requirements
    • 2.2. Installing VoltDB
      • 2.2.1. Upgrading From Older Versions
      • 2.2.2. Building a New VoltDB Distribution Kit
    • 2.3. Setting Up Your Environment
    • 2.4. What is Included in the VoltDB Distribution
    • 2.5. VoltDB in Action: Running the Sample Applications
  • 3. Starting the Database▶
    • 3.1. Initializing and Starting a VoltDB Database
    • 3.2. Initializing and Starting a VoltDB Database on a Cluster
    • 3.3. Stopping a VoltDB Database
    • 3.4. Saving the Data
    • 3.5. Restarting a VoltDB Database
    • 3.6. Updating Nodes on the Cluster
    • 3.7. Defining the Cluster Configuration
      • 3.7.1. Determining How Many Sites per Host
      • 3.7.2. Configuring Paths for Runtime Features
      • 3.7.3. Verifying your Hardware Configuration
  • 4. Designing the Database Schema▶
    • 4.1. How to Enter DDL Statements
    • 4.2. Creating Tables and Primary Keys
    • 4.3. Analyzing Data Volume and Workload
    • 4.4. Partitioning Database Tables
      • 4.4.1. Choosing a Column on which to Partition Table Rows
      • 4.4.2. Specifying Partitioned Tables
      • 4.4.3. Design Rules for Partitioning Tables
    • 4.5. Replicating Database Tables
      • 4.5.1. Choosing Replicated Tables
      • 4.5.2. Specifying Replicated Tables
    • 4.6. Modifying the Schema
      • 4.6.1. Effects of Schema Changes on Data and Clients
      • 4.6.2. Viewing the Schema
      • 4.6.3. Modifying Tables
      • 4.6.4. Adding and Dropping Indexes
      • 4.6.5. Modifying Partitioning for Tables and Stored Procedures
  • 5. Designing Stored Procedures to Access the Database▶
    • 5.1. How Stored Procedures Work
      • 5.1.1. VoltDB Stored Procedures are Transactional
      • 5.1.2. VoltDB Stored Procedures are Deterministic
    • 5.2. The Anatomy of a VoltDB Stored Procedure
      • 5.2.1. The Structure of the Stored Procedure
      • 5.2.2. Passing Arguments to a Stored Procedure
      • 5.2.3. Creating and Executing SQL Queries in Stored Procedures
      • 5.2.4. Interpreting the Results of SQL Queries
      • 5.2.5. Returning Results from a Stored Procedure
      • 5.2.6. Rolling Back a Transaction
    • 5.3. Installing Stored Procedures into the Database
      • 5.3.1. Compiling, Packaging, and Loading Stored Procedures
      • 5.3.2. Declaring Stored Procedures in the Schema
      • 5.3.3. Partitioning Stored Procedures in the Schema
  • 6. Designing VoltDB Client Applications▶
    • 6.1. Connecting to the VoltDB Database
      • 6.1.1. Connecting to Multiple Servers
      • 6.1.2. Using the Auto-Connecting Client
    • 6.2. Invoking Stored Procedures
    • 6.3. Invoking Stored Procedures Asynchronously
    • 6.4. Closing the Connection
    • 6.5. Handling Errors
      • 6.5.1. Interpreting Execution Errors
      • 6.5.2. Handling Timeouts
      • 6.5.3. Writing a Status Listener to Interpret Other Errors
    • 6.6. Compiling and Running Client Applications
      • 6.6.1. Starting the Client Application
      • 6.6.2. Running Clients from Outside the Cluster
  • 7. Simplifying Application Development▶
    • 7.1. Using Default Procedures
    • 7.2. Shortcut for Defining Simple Stored Procedures
    • 7.3. Verifying Expected Query Results
    • 7.4. Scheduling Stored Procedures as Tasks
    • 7.5. Directed Procedures: Distributing Transactions to Every Partition
  • 8. Using VoltDB with Other Programming Languages▶
    • 8.1. C++ Client Interface
      • 8.1.1. Writing VoltDB Client Applications in C++
      • 8.1.2. Creating a Connection to the Database Cluster
      • 8.1.3. Invoking Stored Procedures
      • 8.1.4. Invoking Stored Procedures Asynchronously
      • 8.1.5. Interpreting the Results
    • 8.2. JSON HTTP Interface
      • 8.2.1. How the JSON Interface Works
      • 8.2.2. Using the JSON Interface from Client Applications
      • 8.2.3. How Parameters Are Interpreted
      • 8.2.4. Interpreting the JSON Results
      • 8.2.5. Error Handling using the JSON Interface
    • 8.3. JDBC Interface
      • 8.3.1. Using JDBC to Connect to a VoltDB Database
      • 8.3.2. Using JDBC to Query a VoltDB Database
  • 9. Using VoltDB in a Cluster▶
    • 9.1. Starting a Database Cluster
    • 9.2. Updating the Cluster Configuration
    • 9.3. Elastic Scaling to Resize the Cluster
      • 9.3.1. Adding Nodes with Elastic Scaling
      • 9.3.2. Removing Nodes with Elastic Scaling
      • 9.3.3. Configuring How VoltDB Rebalances Nodes During Elastic Scaling
  • 10. Availability▶
    • 10.1. How K-Safety Works
    • 10.2. Enabling K-Safety
      • 10.2.1. What Happens When You Enable K-Safety
      • 10.2.2. Calculating the Appropriate Number of Nodes for K-Safety
    • 10.3. Recovering from System Failures
      • 10.3.1. What Happens When a Node Rejoins the Cluster
      • 10.3.2. Where and When Recovery May Fail
    • 10.4. Avoiding Network Partitions
      • 10.4.1. K-Safety and Network Partitions
      • 10.4.2. Using Network Fault Protection
  • 11. Database Replication▶
    • 11.1. How Database Replication Works
      • 11.1.1. Starting Database Replication
      • 11.1.2. Database Replication, Availability, and Disaster Recovery
      • 11.1.3. Database Replication and Completeness
    • 11.2. Using Passive Database Replication
      • 11.2.1. Specifying the DR Tables in the Schema
      • 11.2.2. Configuring the Clusters
      • 11.2.3. Starting the Clusters
      • 11.2.4. Loading the Schema and Starting Replication
      • 11.2.5. Updating the Schema During Replication
      • 11.2.6. Stopping Replication
      • 11.2.7. Database Replication and Read-only Clients
    • 11.3. Using Cross Datacenter Replication
      • 11.3.1. Designing Your Schema for Active Replication
      • 11.3.2. Configuring the Database Clusters
      • 11.3.3. Starting the Database Clusters
      • 11.3.4. Loading a Matching Schema and Starting Replication
      • 11.3.5. Updating the Schema During Active Replication
      • 11.3.6. Stopping Replication
      • 11.3.7. Example XDCR Configurations
      • 11.3.8. Understanding Conflict Resolution
    • 11.4. Monitoring Database Replication
  • 12. Security▶
    • 12.1. How Security Works in VoltDB
    • 12.2. Enabling Authentication and Authorization
    • 12.3. Defining Users and Roles
    • 12.4. Assigning Access to Stored Procedures
    • 12.5. Assigning Access by Function (System Procedures, SQL Queries, and Default Procedures)
    • 12.6. Using Built-in Roles
    • 12.7. Encrypting VoltDB Communication Using TLS/SSL
      • 12.7.1. Configuring TLS/SSL on the VoltDB Server
      • 12.7.2. Choosing What Ports to Encrypt with TLS/SSL
      • 12.7.3. Using the VoltDB Command Line Utilities with TLS/SSL
      • 12.7.4. Implementing TLS/SSL in the Java Client Applications
      • 12.7.5. Configuring Database Replication (DR) With TLS/SSL
    • 12.8. Integrating Kerberos Security with VoltDB
      • 12.8.1. Installing and Configuring Kerberos
      • 12.8.2. Installing and Configuring the Java Security Extensions
      • 12.8.3. Configuring the VoltDB Servers and Clients
      • 12.8.4. Accessing the Database from the Command Line and the Web
  • 13. Saving & Restoring a VoltDB Database▶
    • 13.1. Performing a Manual Save and Restore of a VoltDB Cluster
      • 13.1.1. How to Save the Contents of a VoltDB Database
      • 13.1.2. How to Restore the Contents of a VoltDB Database Manually
      • 13.1.3. Changing the Cluster Configuration Using Save and Restore
    • 13.2. Scheduling Automated Snapshots
    • 13.3. Managing Snapshots
    • 13.4. Special Notes Concerning Save and Restore
  • 14. Command Logging and Recovery▶
    • 14.1. How Command Logging Works
    • 14.2. Controlling Command Logging
    • 14.3. Configuring Command Logging for Optimal Performance
      • 14.3.1. Log Size
      • 14.3.2. Log Frequency
      • 14.3.3. Synchronous vs. Asynchronous Logging
      • 14.3.4. Hardware Considerations
  • 15. Streaming Data: Import, Export, and Migration▶
    • 15.1. How Data Streaming Works in VoltDB
      • 15.1.1. Understanding Import
      • 15.1.2. Understanding Export
      • 15.1.3. Understanding Migration
      • 15.1.4. Understanding Topics
    • 15.2. The Business Case for Streaming Data
      • 15.2.1. Extract, Transform, Load (ETL)
      • 15.2.2. Change Data Capture
      • 15.2.3. Streaming Data Validation
      • 15.2.4. Caching
      • 15.2.5. Archiving
    • 15.3. VoltDB Export Connectors
      • 15.3.1. How Export Works
      • 15.3.2. The File Export Connector
      • 15.3.3. The HTTP Export Connector
      • 15.3.4. The JDBC Export Connector
      • 15.3.5. The Kafka Export Connector
      • 15.3.6. The Elasticsearch Export Connector
    • 15.4. VoltDB Import Connectors
      • 15.4.1. Bulk Loading Data Using VoltDB Standalone Utilities
      • 15.4.2. Streaming Import Using Built-in Import Features
      • 15.4.3. The Kafka Importer
      • 15.4.4. The Kinesis Importer
    • 15.5. VoltDB Import Formatters
    • 15.6. VoltDB Topics
      • 15.6.1. Types of VoltDB Topics
      • 15.6.2. Declaring VoltDB Topics
      • 15.6.3. Configuring and Managing Topics
      • 15.6.4. Configuring the Topic Server
      • 15.6.5. Calling Topics from Consumers and Producers
      • 15.6.6. Using Opaque Topics
  • A. Supported SQL DDL Statements▶
    • ALTER STREAM
    • ALTER TABLE
    • ALTER TASK
    • ALTER VIEW
    • CREATE AGGREGATE FUNCTION
    • CREATE FUNCTION
    • CREATE INDEX
    • CREATE PROCEDURE AS
    • CREATE PROCEDURE FROM CLASS
    • CREATE ROLE
    • CREATE STREAM
    • CREATE TABLE
    • CREATE TASK
    • CREATE VIEW
    • DR TABLE
    • DROP FUNCTION
    • DROP INDEX
    • DROP PROCEDURE
    • DROP ROLE
    • DROP STREAM
    • DROP TABLE
    • DROP TASK
    • DROP VIEW
    • PARTITION TABLE
  • B. Supported SQL Statements▶
    • DELETE
    • INSERT
    • MIGRATE
    • SELECT
    • TRUNCATE TABLE
    • UPDATE
    • UPSERT
  • C. SQL Functions▶
    • ABS()
    • APPROX_COUNT_DISTINCT()
    • AREA()
    • ARRAY_ELEMENT()
    • ARRAY_LENGTH()
    • ASTEXT()
    • AVG()
    • BIN()
    • BIT_SHIFT_LEFT()
    • BIT_SHIFT_RIGHT()
    • BITAND()
    • BITNOT()
    • BITOR()
    • BITXOR()
    • CAST()
    • CEILING()
    • CENTROID()
    • CHAR()
    • CHAR_LENGTH()
    • COALESCE()
    • CONCAT()
    • CONTAINS()
    • COS()
    • COT()
    • COUNT()
    • CSC()
    • CURRENT_TIMESTAMP()
    • DATEADD()
    • DATEDIFF()
    • DAY(), DAYOFMONTH()
    • DAYOFWEEK()
    • DAYOFYEAR()
    • DECODE()
    • DEGREES()
    • DISTANCE()
    • DWITHIN()
    • EXP()
    • EXTRACT()
    • FIELD()
    • FLOOR()
    • FORMAT_CURRENCY()
    • FORMAT_TIMESTAMP()
    • FROM_UNIXTIME()
    • HEX()
    • HOUR()
    • INET6_ATON()
    • INET6_NTOA()
    • INET_ATON()
    • INET_NTOA()
    • ISINVALIDREASON()
    • ISVALID()
    • IS_VALID_TIMESTAMP()
    • LATITUDE()
    • LEFT()
    • LN(), LOG()
    • LOG10()
    • LONGITUDE()
    • LOWER()
    • MAKEVALIDPOLYGON()
    • MAX()
    • MAX_VALID_TIMESTAMP()
    • MIGRATING()
    • MIN()
    • MIN_VALID_TIMESTAMP()
    • MINUTE()
    • MOD()
    • MONTH()
    • NOW()
    • NUMINTERIORRINGS()
    • NUMPOINTS()
    • OCTET_LENGTH()
    • OVERLAY()
    • PI()
    • POINTFROMTEXT()
    • POLYGONFROMTEXT()
    • POSITION()
    • POWER()
    • QUARTER()
    • RADIANS()
    • REGEXP_POSITION()
    • REPEAT()
    • REPLACE()
    • RIGHT()
    • ROUND()
    • SEC()
    • SECOND()
    • SET_FIELD()
    • SIN()
    • SINCE_EPOCH()
    • SPACE()
    • SQRT()
    • STR()
    • SUBSTRING()
    • SUM()
    • TAN()
    • TIME_WINDOW()
    • TO_TIMESTAMP()
    • TRIM()
    • TRUNCATE()
    • UPPER()
    • VALIDPOLYGONFROMTEXT()
    • WEEK(), WEEKOFYEAR()
    • WEEKDAY()
    • YEAR()
  • D. VoltDB CLI Commands▶
    • csvloader
    • jdbcloader
    • kafkaloader
    • sqlcmd
    • voltadmin
    • voltdb
  • E. Configuration File (deployment.xml)▶
    • E.1. Understanding XML Syntax
    • E.2. The Structure of the Configuration File
  • F. VoltDB Datatype Compatibility▶
    • F.1. Java and VoltDB Datatype Compatibility
  • G. System Procedures▶
    • @AdHoc
    • @Explain
    • @ExplainProc
    • @ExplainView
    • @GetPartitionKeys
    • @Note
    • @Pause
    • @Ping
    • @Promote
    • @QueryStats
    • @Quiesce
    • @Resume
    • @Shutdown
    • @SnapshotDelete
    • @SnapshotRestore
    • @SnapshotSave
    • @SnapshotScan
    • @Statistics
    • @StopNode
    • @SwapTables
    • @SystemCatalog
    • @SystemInformation
    • @UpdateApplicationCatalog
    • @UpdateClasses
    • @UpdateLogging

11.2. Using Passive Database Replication

The following sections provide step-by-step instructions for setting up and running passive replication between two VoltDB clusters. The steps include:

  1. Specifying what tables to replicate in the schema

  2. Configuring the master and replica root directories for DR

  3. Starting the databases

  4. Loading the schema

The remaining sections discuss other aspects of managing passive DR, including:

  • Updating the schema

  • Stopping database replication

  • Promoting the replica database

  • Using the replica for read-only transactions

11.2.1. Specifying the DR Tables in the Schema

First, you must identify which tables you wish to copy from the master to the replica. Only the selected tables are copied. You identify the tables in both the master and the replica database schema with the DR TABLE statement, For example, the following statements identify two tables to be replicated, the Customers and Orders tables:

CREATE TABLE customers (
  customerID INTEGER NOT NULL,
  firstname VARCHAR(128),
  lastname VARCHAR(128)
);
CREATE TABLE orders (
  orderID INTEGER NOT NULL,
  customerID INTEGER NOT NULL,
  placed TIMESTAMP
);
DR TABLE customers;
DR TABLE orders;

You can identify any regular table, whether partitioned or not, as a DR table, as long as the table is empty. That is, the table must have no data in it when you issue the DR TABLE statement.

The important point to remember is that the schema for both databases must contain matching table definitions for any tables identified as DR tables, including the associated DR TABLE declarations. Although it is easiest to have the master and replica databases use the exact same schema, that is not necessary. The replica can have a subset or superset of the tables in the master, as long as it contains matching definitions for all of the DR tables. The replica schema can even contain additional objects not in the master schema, such as additional views. Which can be useful when using the replica for read-only or reporting workloads, just as long as the DR tables match.

11.2.2. Configuring the Clusters

The next step is to properly configure the master and replica clusters. The two database clusters can have different physical configurations (that is, different numbers of nodes, different sites per host, or a different K factor). Identical cluster configurations guarantee the most efficient replication, because the replica does not need to repartition the incoming binary logs. Differing configurations, on the other hand, may incrementally increase the time needed to apply the binary logs.

Before you start the databases, you must initialize the root directories for both clusters with the appropriate DR attributes. You enable DR in the configuration file using the <dr> element, including a unique cluster ID for each database cluster and that cluster's role. The ID is a number between 0 and 127 which VoltDB uses to uniquely identify each cluster as part of the DR process. The role is either master or replica.

For example, you could assign ID=1 for the master cluster and ID=2 for the replica. On the replica, you must also include a <connection> sub-element that points to the master database. For example:

Master Cluster
<dr id="1" role="master"/>
Replica Cluster
<dr id="2" role="replica">
   <connection source="MasterSvrA,MasterSvrB" />
</dr>

11.2.3. Starting the Clusters

The next step is to start the databases. You start the master database as normal with the voltdb start command. If you are creating a new database, you can then load the schema, including the necessary DR TABLE statements. Or you can restore a previous database instance if desired. Once the master database starts, it is ready and can interact with client applications.

For the replica database, you use the voltdb start command to start a new, empty database. Once the database is running, you can execute DDL statements to load the database schema, but you cannot perform any data manipulation queries such as INSERT, UPDATE, or DELETE because the replica is in read-only mode.

The source attribute of the <connection> tag in the replica configuration file identifies the hostname or IP address (and optionally port number) of one or more servers in the master cluster. You can specify multiple servers so that DR can start even if one of the listed servers on the master cluster is currently down.

It is usually convenient to specify the connection information when initializing the database root directory. But this property can be changed after the database is running, in case you do not know the address of the master cluster nodes before starting. (Note, however, that the cluster ID cannot be changed once the database starts.)

11.2.4. Loading the Schema and Starting Replication

As soon as the replica database starts with DR enabled, it will attempt to contact the master database to start replication. The replica will issue warnings that the schema does not match, since the replica does not have any schema defined yet. This is normal. The replica will periodically contact the master until the schema for DR objects on the two databases match. This gives you time to load a matching schema.

As soon as the replica database has started, you can load the appropriate schema. Loading the same schema as the master database is the easiest and recommended approach. The key point is that once a matching schema is loaded, replication will begin automatically.

When replication starts, the following actions occur:

  1. The replica and master databases verify that the DR tables match on the two clusters.

  2. If data already exists in the DR tables on the master, the master sends a snapshot of the current contents to the replica where it is restored into the appropriate tables.

  3. Once the snapshot, if any, is restored, the master starts sending binary logs of changes to the DR tables to the replica.

If any errors occur during the snapshot transmission, replication stops and must be restarted from the beginning. However, once the third step is reached, replication proceeds independently for each unique partition and, in a K safe environment, the DR process becomes durable across node failures and rejoins and other non-fatal events.

If either the master or the replica database crashes and needs to restart, it is possible to restart DR where it left off, assuming the databases are using command logging for recovery. If the master fails, you simply use the voltdb start command to restart the master database. The replica will wait for the master to recover. The master will then replay any DR logs on disk and resume DR where it left off.

If the replica fails, the master will queue the DR logs to disk waiting for the replica to return. If you use the voltdb start command on the replica cluster, the replica will perform the following actions:

  1. Restart the replica database, restoring both the schema and the data, and placing the database in read-only mode.

  2. Contact the master cluster and attempt to re-establish DR.

  3. If both clusters agree on where (that is, what transaction), DR was interrupted, DR will resume from that point, starting with the DR logs that the master database has queued in the interim.

If the clusters do not agree on where DR stopped during step #3, the replica database will generate an error and stop replication. For example, if you recover from an asynchronous command log where the last few DR logs were ACKed to the master but not written to the command log, the master and the replica will be in different states when the replica recovers.

If this occurs, you must restart DR from the beginning, by re-initializing the replica root directory (with the --force flag), restarting the database, and then reloading a compatible schema. Similarly, if you are not using command logging, you cannot recover the replica database and must start DR from scratch.

11.2.5. Updating the Schema During Replication

Because database replication is asynchronous, updating the schema requires a deliberate, planned process. You need to ensure that no transactions that write to the affected tables are executed while the schema is being updated. If the DR consumer (that is, the replica) detects a transaction to a table where the schema does not match, the replica stops requesting and processing binary logs from the master cluster. The master cluster then queues all changes until the schema is updated on the replica. Once the schema on the replica is updated to match the incoming transaction, replication resumes.

The safest way to update the schema is the following:

  1. Pause the master cluster with the voltadmin pause --wait command

  2. Update the schema on the master and replica.

  3. Resume operation on the master with the voltadmin resume command

These steps ensure that no transactions are processed until the schema for both clusters are updated. However, this process also means the master database does not accept any client transactions during the update process.

Because schema validation occurs on a per table, per transaction basis, it is possible to update the schema without pausing the database. However, this only works if you ensure that no client transactions attempt to modify affected tables while the schema differ.

For example, it is possible to add tables to the database schema without pausing the database by adding the tables to the master database and replica in one step, then updating the stored procedures to access the new tables in a second step. This way no client applications access the new tables until they exist and match on both databases, and ongoing transactions are not impacted.

You can even modify existing DR tables without pausing the database. But in this case you must be much more careful about avoiding operations that access the affected tables during the transition. If any transactions attempt to write to an affected table while the schema differ, the replica will stall until the schema match. One way to do this is to create a new table, matching the existing table but with the desired changes. Update the schema on both clusters, then update the client applications and stored procedures to use the new table. Finally, once all client applications are updated, the original table can be deleted.

11.2.6. Stopping Replication

If, for any reason, you wish to stop replication of a database, there are two ways to do this: you can stop sending data from the master or you can "promote" the replica to stop it from receiving data. Since the individual partitions are replicating data independently, if possible you want to make sure all pending transfers are completed before turning off replication.

So, under the best circumstances, you should perform the following steps to stop replication:

  1. Stop write transactions on the master database by putting it in admin mode using the voltadmin pause command.

  2. Wait for all pending DR log transfers to be completed.

  3. Reset DR on the master cluster using the voltadmin dr reset command.

  4. Depending on your goals, either shut down the replica or promote it to a fully-functional database as described in Section 11.2.6.3, “Promoting the Replica When the Master Becomes Unavailable”.

11.2.6.1. Stopping Replication on the Master if the Replica Becomes Unavailable

If the replica becomes unavailable and is not going to be recovered or restarted, you should consider stopping DR on the master database, to avoid consuming unnecessary disk space.

The DR process is resilient against network glitches and node or cluster failures. This durability is achieved by the master database continually queueing DR logs in memory and — if too much memory is required — to disk while it waits for the replica to ACK the last message. This way, when the network interruption or other delay is cleared, the DR process can pick up where it left off. However, the master database has no way to distinguish a temporary network failure from an actual stoppage of DR on the replica.

Therefore, if the replica stops unexpectedly, it is a good idea to restart the replica and re-initiate DR as soon as convenient. Or, if you are not going to restart DR, you should reset DR on the master to cancel the queuing of DR logs and to delete any pending logs. To reset the DR process on the master database, use the voltadmin dr reset command. For example:

$ voltadmin dr reset --host=serverA

Of course, if you do intend to recover and restart DR on the replica, you do not want to reset DR on the master. Resetting DR on the master will delete any queued DR logs and make restarting replication where it left off impossible and force you to start DR over from the beginning.

11.2.6.2. Database Replication and Disaster Recovery

If unforeseen events occur that make the master database unreachable, database replication lets you replace the master with the replica and restore normal business operations with as little downtime as possible. You switch the replica from read-only to a fully functional database by promoting it. To do this, perform the following steps:

  1. Make sure the master is actually unreachable, because you do not want two live copies of the same database. If it is reachable but not functioning properly, be sure to pause or shut down the master database.

  2. Promote the replica to a read/write mode using the voltadmin promote command.

  3. Redirect the client applications to the newly promoted database.

Figure 11.4, “Promoting the Replica” illustrates how database replication reduces the risk of major disasters by allowing the replica to replace the master if the master becomes unavailable.

Once the master is offline and the replica is promoted, the data is no longer being replicated. As soon as normal business operations have been re-established, it is a good idea to also re-establish replication. This can be done using any of the following options:

  • If the original master database hardware can be restarted, take a snapshot of the current database (that is, the original replica), restore the snapshot on the original master and redirect client traffic back to the original. Replication can then be restarted using the original configuration.

  • An alternative, if the original database hardware can be restarted but you do not want to (or need to) redirect the clients away from the current database, is to use the original master hardware to create a replica of the newly promoted cluster — essentially switching the roles of the master and replica databases — as described in Section 11.2.6.4, “Reversing the Master/Replica Roles”.

  • If the original master hardware cannot be recovered effectively, create a new database cluster in a third location to use as a replica of the current database.

11.2.6.3. Promoting the Replica When the Master Becomes Unavailable

If the master database becomes unreachable for whatever reason (such as catastrophic system or network failure) it may not be possible to turn off DR in an orderly fashion. In this case, you may choose to “turn on” the replica as a fully active (writable) database to replace the master. To do this, you use the voltadmin promote command. When you promote the replica database, it exits read-only mode and becomes a fully operational VoltDB database. For example, the following Linux shell command uses voltadmin to promote the replica node serverB:

$ voltadmin promote --host=serverB

11.2.6.4. Reversing the Master/Replica Roles

If you do promote the replica and start using it as the primary database, you will likely want to establish a new replica as soon as possible to return to the original production configuration and level of durability. You can do this by creating a new replica cluster and connecting to the promoted database as described in Section 11.2.3, “Starting the Clusters”. Or, if the master database can be restarted, you can reuse that cluster as the new replica, by modifying the configuration file to change the DR role from master to replica, and add the necessary <connection> element, re-initializing the database root directory, and then starting the new database cluster with the voltdb start command.

11.2.7. Database Replication and Read-only Clients

While database replication is occurring, the only changes to the replica database come from the binary logs. Client applications can connect to the replica and use it for read-only transactions, including read-only ad hoc queries and system procedures. However, any attempt to perform a write transaction from a client application returns an error.

There will always be some delay between a transaction completing on the master and its results being applied on the replica. However, for read operations that do not require real-time accuracy (such as reporting), the replica can provide a useful source for offloading certain less-frequent, read-only transactions from the master.

Figure 11.5. Read-Only Access to the Replica

Read-Only Access to the Replica

You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.