solidDB Help : Configuring and administering : Configuring and administering HotStandby : HotStandby administration tasks : Synchronizing primary and secondary servers
  
Synchronizing primary and secondary servers
To start HotStandby (HSB) replication, the databases on the primary and secondary servers must be identical. The secondary database must be an exact copy of the primary database. The process of making the databases of a HSB system identical is called HotStandby synchronization.
The following situations are examples of when the primary and secondary databases must be synchronized:
The secondary server is new and does not yet have a copy of the primary database.
The secondary server was not running for a while and the secondary database is not up-to-date.
Both servers were running in PRIMARY ALONE state at the same time, and thus have conflicting data.
The disk drive on the secondary server fails, or the file is corrupted and must be replaced.
There are two main ways of synchronizing the data on the servers: catchup and full copy.
Catchup
Catchup is the process by which, when the HSB pair of servers are reconnected, the primary server forwards transactions that the secondary server did not receive while the servers were disconnected.
Catchup can be used only if the primary server has stored a copy of all of the transactions that the secondary server did not receive.
A primary server stores transactions (to forward to the secondary server) only while it is in PRIMARY ALONE state, not while it is in STANDALONE state or is operating as a non-HSB server. If the primary server has not been operating solely in PRIMARY ALONE state since it last was connected with the secondary server, the primary server does not have all the transactions and cannot do catchup. Instead, you must do a full copy of the database.
There is no explicit catchup command. The servers try to catch up automatically when you connect them by using the ADMIN COMMAND 'hotstandby connect' command.
When the primary and secondary servers are connected, they automatically check to see whether the primary server has data in its transaction logs to send to the secondary server. If the data is there, the servers automatically attempt to catch up.
During the catchup process, the primary and secondary servers stay in PRIMARY ALONE and SECONDARY ALONE states respectively. Clients can continue to submit queries and commit transactions. The catchup process is transparent to the client applications.
If the servers recognize that the primary and secondary databases are not identical even after the transactions are copied from the primary server to the secondary server, an error message is displayed.
If catchup fails (or if you know that catchup will not work because the primary server was in STANDALONE state, for example), you must do a full copy of the database.
Catchup applies only when the secondary server has already been running in SECONDARY ACTIVE state at some point. If you have a new secondary server then, even if the primary server was running in PRIMARY ALONE state and has stored all transactions since the time that the primary server started, you must do a full copy of the database to give the secondary server an initial copy of the database.
For more information about the catchup process, see Bringing the secondary server back online.
Full copy (hsb netcopy)
A full copy involves copying all the database files from the primary server to the secondary server.
A full copy is used in the following situations:
The secondary server is getting the initial copy of the primary database.
The primary server has written transactions when it was not in the PRIMARY ALONE state, and therefore catchup is not possible.
The secondary database is corrupted or missing.
The secondary server is diskless and has failed. When a diskless secondary server is started after a failure, the diskless server requires a complete copy of the database by using the hotstandby netcopy command. Unlike a disk-based secondary server, a diskless secondary server cannot read the transaction log and apply the changes that occurred while it was inoperable.
The primary server has all of the data that is needed for catchup, but catchup is expected to take longer than copying the current data files.
Important If the secondary server has old database files, a full copy writes over those old files. If for any reason the files on the secondary server contain data that was not in the primary server (for example, if both servers were operating in PRIMARY ALONE state at the same time), that data is lost.
There are two HSB commands that can do a full copy, that is, copy the database files from the primary server to the secondary server. You can use either of the following commands:
ADMIN COMMAND 'hotstandby netcopy';
ADMIN COMMAND 'hotstandby copy [directory_name]';
The netcopy operation copies the database over the network to a secondary server that is running and can receive the files over the network. The copy operation copies the database files to a specified disk drive directory that is visible to the primary server. The secondary server must not be running during the copy operation. The netcopy command is usually preferable to the copy command, so most of the examples show only netcopy, not copy. For more information about netcopy, see netcopy: This command can be used copy the primary database or diskless in-memory data to a secondary server. The database files are copied through the network link, using the connection defined with the HotStandby.Connect parameter in the solid.ini file on the primary server..
The following table describes an example of using the netcopy command:
 
Description
Illustration
Normal operation
The diagram is described in the first column of the row
The secondary server fails and the primary server uses the transaction log to store details to send to the secondary server.
The diagram is described in the first column of the row
The secondary server is down for a long time so the primary server stops using the transaction log to store details to send to the secondary server.
Note The log is still used for local server recovery.
The diagram is described in the first column of the row
The primary database is copied to the secondary server, by using the command:
hsb netcopy
and the primary server starts using the transaction log again to store details to send to the secondary server.
The diagram is described in the first column of the row
When the database copy completes, you can connect the servers by using the command:
hsb connect
and then the primary server sends the transaction log file changes to the secondary server.
The diagram is described in the first column of the row
Using a watchdog to synchronize servers
The commands that synchronize servers manually can also be used by a watchdog program to synchronize servers automatically.
If catchup is sufficient, all that the watchdog must do is monitor the secondary server to see when it is available, and then run the command to connect the primary server to the secondary server. If a full copy is required, the watchdog can instruct the primary server to do a netcopy operation. A full copy overwrites any data on the secondary server.
Go up to
HotStandby administration tasks