Failover and Recovery with Replication
This section is a guide for manual OpCon failover and recovery with replication including the topics:
- Automatic Failover to the Subscribing OpCon Database Server
- Manual Failover to the Subscribing OpCon Database Server
- Restoring the database to the Publishing Database Server
- Restoring replication
Failure to follow replication failover and recovery procedures in the proper order can result in data corruption. SMA Technologies has tested the following steps in the order listed to achieve successful replication failover and recovery.
Exceeding the number of licensed machines (LSAMs) causes the license to be shortened to 30 days from date of license violation and will void the license key.
Automatic Failover to the Subscribing Database Server
When configured, automatic failover to the Subscribing OpCon Database Server occurs when the Secondary SMA Service Manager encounters a failover trigger. For further information, refer to Automatic Failover.
Manual Failover to the Subscribing Database Server
If the Publishing OpCon Database Server fails and cannot be brought back up for processing, failover to the Subscribing OpCon Database Server. Complete the procedures below when replication is using either a push or a pull subscription.
The Disable Replication procedure below can only be successful if the administrator configured the StopRepl.cmd or StopRepl_WinAuth.cmd file for the correct subscription type. For information on configuring the StopRepl.cmd file, refer to Configuring Failover Scripts and the SMA Service Manager.
Disable Replication
- Log in as a Windows user with Local Administrative Rights.
- Right-click Start and select Explore.
- Browse to the <Configuration Directory>\Utilities\Database\ directory.
- Double-click the StopRepl.cmd file.
Fail Over to the Subscribing Database and Secondary SMAServMan
- Log on to the Secondary SAM application server as a local administrative user.
- Use menu path: Start > Control Panel.
- Double-click Administrative Tools.
- Double-click the Services icon.
- Double-click the SMA OpCon Service Manager service.
- Select Automatic (Delayed Start) in the Startup type drop-down list.
- Click OK.
- Click Start to start the service.
- Click Close ☒ on the Services window.
- Use menu path: Start > Programs > OpConxps > Log Monitors > Log File.
- Open the SMANetCom.log, SAM Critical.log, and SAM.log to verify that the Secondary Server is processing normally.
When the SAM-SS is processing normally with the Subscribing database, all graphical interfaces should connect to the Subscribing database for production processing until the OpCon administrator indicates that the Publishing Database Server is available again.
Restoring the Database to the Publishing Server
When the Publishing Database Server is brought back up and running reliably, restore the current data from the Subscribing server to the Publishing Server. The Primary SMA Service Manager may then start the SAM-SS to resume processing. The steps in this section describe the manual steps to restore processing to the primary server. If the SMA Replication schedules have been configured, use the SMAReplicationRecoverToPrimary schedule to restore.
If the hard drive was lost, a new copy of Windows and MSSQL is on the server. Verify that all OpCon system requirements are met. Refer to Getting Started in the OpCon Installation online help.
Stopping the SMA Service Manager on the Secondary Server
To prevent OpCon from writing to a disabled database, stop the SMA Service Manager on the Secondary Server by following the steps below.
Stop the SMA Service Manager
- Use menu path: Start > Control Panel.
- Double-click Administrative Tools.
- Double-click the Services icon.
- Click SMA OpCon Service Manager.
- Click Stop (■).
- Click Close ☒ on the Services window.
Verifying the SMA Service Manager's Status on the Primary Server
To ensure the primary SMA Service Manager has stopped, verify the SMAServMan's status by performing the steps below.
Verify SMAServMan's Status
- Use menu path: Start > Control Panel.
- Double-click Administrative Tools.
- Double-click the Services icon.
- Click SMA Service Manager.
- Confirm the SMA Service Manager is stopped. If it is not, click Stop to stop the service.
- Click Close ☒ on the Services window.
Backing Up the Subscribing Database
Follow the procedures below to create a backup of the subscribing database for the restoration of the publishing database.
Locate the Server in Management Studio
On the Subscribing Database Server:
- Log in as a local administrative user.
- Use menu path: Start > All Programs > SQL Server Management Studio.
- In the Connect to Server window: Select Database Engine in the Server type drop-down list.
- Select the desired [OpCon Database Server] in the Server name drop-down list.
- Select one of the following options in the Authenticationdrop-down list:
- Windows Authentication to log in with the current Windows User with local administrative authority.
- SQL Server Authentication then enter sa in the Login text box and the sa's password in the Password text box.
- Click the Connect button.
- In the Microsoft SQL Server Management Studio window: Expand (+) the Databases folder.
- Identify the OpCon database.
Back Up the Database
- Right-click the OpCon database and choose Tasks > Back Up.
- Confirm the OpCon database is selected in the Database drop-down list.
- Enter the backup job name in the Name text box.
- Select Full in the Backup type drop-down list for a complete backup.
- Go to the Destination frame.
- Select the Disk radio button.
- Click Add to add the location and name of the backup file if the default destination is not desired. You should see the default directory for SQL backups listed in the Select Backup Destination window.
- Enter, in the File name field, a file name followed by a .bak file extension at the end of the file path. If this is not the desired location, enter the full path and file name followed by a .bak file extension (e.g., D:\MSSQL\Backup\Opconxps.bak).
- Click OK to accept the backup (.bak) filename.
- Click on the Options tab in the Select a page menu.
- Go to the Overwrite media frame.
- Select the Append to the existing backup set or Overwrite all existing backup sets radio button. Either option is acceptable. The database administrator should make this decision.
- Click OK.
- click OK when the backup completes successfully.
Restoring the Backup File to the Publishing Server
Follow the procedures below to restore the publishing database with the backup of the subscribing database.
Copy the Backup File
Copy the backup (.bak) file to the default SQL Backup directory (e.g., <Target Directory>\Microsoft SQL Server\MSSQL\BACKUP\).
Connect to Management Studio
On the Publishing Database Server:
- Log in as a local administrative user.
- Use menu path: Start > All Programs > SQL Server Management Studio.
- In the Connect to Server window: Select Database Engine in the Server type drop-down list.
- Select the desired [OpCon Database Server] in the Server name drop-down list.
- Select one of the following options in the Authenticationdrop-down list:
- Windows Authentication to log in with the current Windows User with local administrative authority.
- SQL Server Authentication then enter sa in the Login text box and the sa's password in the Password text box.
- Click the Connect button.
Disable Replication
If publishing is still set up on the Publishing Database Server, complete the steps in this section to disable publishing.
- Go to the Object Explorer frame.
- Right-click the Replication folder and select Disable Publishing and Distributions.
- On the Disable Publishing and Distribution Wizard welcome screen:
- Click Next.
- Select the Yes, disable publishing on this server radio button and click Next.
- Leave the settings at default and click Next.
- Click Finish.
- Watch as it processes and make sure it completes successfully then click Close.
Restore the Backup File
- Go to the Object Explorer screen.
- Expand (+) the Databases folder.
- Right-click the <database name> icon and choose Tasks > Restore > Database.
- Verify that the OpCon database is selected in the To database combo box. If the OpCon database does not already exist in the To database combo box, enter the database name.
- Go to the Source for restore frame.
- Select the From device radio button.
- Click the ellipsis (...) button beside the From device radio button to browse to the desired backup (.bak) file.
- Select the desired backup (.bak) file in the Backup location drop-down list. If it is not found in this list, then click Add.
- Browse through the folders and select the desired backup (.bak) file.
- Click OK.
- Click OK.
- Go to Select the backup sets to restore frame.
- Select the desired backup (.bak) file checkbox.
- Click the Options tab in the Select a page menu.
- Select the Overwrite the existing database checkbox.
- Go to the Restore the database files as frame.
- Make sure that the file name and path are valid for the database's data and log files.
- Go to the Recovery state frame.
- Click the radio button by Leave the database ready to use by rolling back uncommitted transactions. Additional transaction logs cannot be restored. (RESTORE WITH RECOVERY)
- Click OK.
- When the restore completes successfully, click OK.
Executing Required Scripts on the Publishing Server
After restoration to the publishing database server, the OpCon database may not be fully functional. To make the database fully functional, execute the DB_Update.cmd file to apply all necessary privileges and primary keys. For information on running the Database Upgrade scripts, refer to Update Database in the Utilities online help.
Resetting SQL Login IDs
Following restoration, it is possible to have a mismatch of SQL Login IDs between the restored database and the SQL server. This mismatch prevents SAM's SQL Login ID (opconsam) and the graphical interface's SQL Login ID (opconui) from in to the database. To fix this problem, complete the steps below.
Reset opconsam and opconui SQL Login IDs
On the Publishing Database Server:
- Log in as a local administrative user.
- Use menu path: Start > All Programs > SQL Server Management Studio.
- In the Connect to Server window: Select Database Engine in the Server type drop-down list.
- Select the desired [OpCon Database Server] in the Server name drop-down list.
- Select one of the following options in the Authenticationdrop-down list:
- Windows Authentication to log in with the current Windows User with local administrative authority.
- SQL Server Authentication then enter sa in the Login text box and the sa's password in the Password text box.
- Click the Connect button.
- In the Microsoft SQL Server Management Studio window: Expand (+) the Databases folder and click the OpCon database.
- On the Standard toolbar: Click the New Query button.
- Select the OpCon Database from the list at the top of the screen.
- Enter the query:
dbo.sp_change_users_login 'update_one','opconsam','opconsam'
. - Click the Execute button or press F5 to execute the query.
- Enter the query:
dbo.sp_change_users_login 'update_one' ,'opconui','opconui'
. - Click the Execute button or press F5 to execute the query.
Deleting Stored Procedures from Last Replication Setup
If using SQL Server Management Studio 2014, then you can skip this entire manual procedure. The stored procedures are automatically deleted by SQL Server during the process of stopping/turning off replication. If using an earlier version of SQL Server Management Studio, you must follow this procedure to delete the stored procedures.
In order for SQL to work correctly after restoration, delete all stored procedures from the subscribing OpCon database created during the previous setup of replication.
Delete Stored Procedures
On the Subscribing Database Server:
- Log in as a local administrative user.
- Use menu path: Start > All Programs > SQL Server Management Studio.
- In the Connect to Server window: Select Database Engine in the Server type drop-down list.
- Select the desired [OpCon Database Server] in the Server name drop-down list.
- Select one of the following options in the Authenticationdrop-down list:
- Windows Authentication to log in with the current Windows User with local administrative authority.
- SQL Server Authentication then enter sa in the Login text box and the sa's password in the Password text box.
- Click the Connect button.
- In the Microsoft SQL Server Management Studio window: Expand (+) the subscribing OpCon database.
- Expand (+) the Programmability folder.
- Click the Stored Procedures folder.
- In the Object Explorer Details frame: Select the first procedure starting with sp_MS.note
If unable to see the Object Explorer Details frame, use menu path: View>Object Explorer Details.
- Press the Shift key on the keyboard then select the last procedure in the list beginning with sp_MS.
- Right-click on the highlighted list and select Delete.
- In the Delete Objects window:
- Click OK.
Verifying Regular Backups on the OpCon Database
- If the database backups are scheduled in OpCon, verify that the information in the jobs is still correct. For information on automated backups in OpCon, refer to SMA Database Backup in the Concepts online help.
- If there is a database maintenance plan in place for the OpCon database, verify the setup. Make sure that the maintenance plan is restarted. This may have to be done manually by right clicking and starting the full database backup job. This can be found in Management Studio under *<Server Name>*> SQL Agent > Jobs. After the full backup is complete, start the Transaction Log backup.
- If the Maintenance plan appears to be corrupt, delete it and step through the wizard to create a new one. SMA Technologies recommends a full database backup once per day. Schedule this for a low processing time. The recommendation for the Transaction log backup is every 30 minutes starting at midnight (12:00 am) and ending at 11:59 pm. However, the Transaction log may be backed up as often as the database administrator decides.
Restoring Replication
If replication was in use, restore replication manually or through the SMA Replication schedules. For information on manually setting up replication, refer to Manual Setup for Microsoft SQL Replication. For information on using the SMA Replication schedules, refer to Setup for Automatic Microsoft SQL Replication.