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 theADMIN 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.
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 thehotstandby 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:
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.