background image
<< Starting and running replication | Replication and security >>

Stopping replication

<< Starting and running replication | Replication and security >>
Derby Server and Administration Guide
80
While replication is running, neither the slave or the master database is permitted to be
shut down. Replication must be stopped before you can shut down either the slave or the
master database. There is one exception to this rule: if the entire system is shut down,
the peer that is shut down notifies the other replication peer that replication is stopped.
If you install jar files on the master system while replication is running, the same jars are
not automatically installed on the slave. But because the transaction log information sent
to the slave system includes the jar file installation, the slave database has a record of
the jar files, even though they are not actually there. Therefore, you must install the jar
files on the former slave after a failover by calling either
SQLJ.remove_jar
followed by
SQLJ.install_jar
, or
SQLJ.replace_jar
. (For information on installing jar files,
see "Loading classes from a database" in the Derby Developer's Guide and "System
procedures for storing jar files in a database" in the Derby Reference Manual.)
If the jar files must be available to clients immediately after a failover, you must stop
replication and then start replication over again from the beginning, so that the slave
database will have the same jar files as the master.
Stopping replication
To stop replication of a database, connect to the master database using the
stopMaster=true connection URL attribute. The master sends the remaining log records
that await shipment, and then sends a stop replication command to the slave. The slave
then writes all logs to disk and shuts down the database. For example, for a database
named
wombat
, you might specify the following connection URL:
jdbc:derby:wombat;stopMaster=true
To stop replication on the slave system if the connection to the master is lost, use the
stopSlave=true connection URL attribute.
See the Derby Reference Manual for details about these attributes.
You cannot resume replication after it has been stopped. You need to start replication
over again from the beginning using the startMaster=true attribute, as described in
Starting and running replication
.
Forcing a failover
At any time, you can transform the Derby database that has the slave role into a normal
Derby database that can process transactions. This transformation from being a slave
to becoming an active Derby database is called failover. During failover, the slave
applies the parts of the transaction log that have not yet been processed. It then undoes
operations that belong to uncommitted transactions, resulting in a transaction-consistent
state that includes all transactions whose commit log record has been sent to the slave.
You perform failover from the master system. To do so, you connect to the database on
the master system using the failover=true connection URL attribute. For example, for a
database named
wombat
, you might specify the following connection URL:
jdbc:derby:wombat;failover=true
If the network connection between the master system and the slave system is lost, you
can perform failover from the slave system.
See the Derby Reference Manual for details about the failover=true attribute.