Setup for Automatic Microsoft SQL Replication
Setup for Automatic Microsoft SQL Replication lets OpCon automate the configuration and removal of SQL Server transactional replication, removing the need for manual DBA intervention on each failover cycle.
Database replication in SQL Server uses a publishing metaphor with three roles: publisher, distributor, and subscriber. OpCon uses transactional replication to distribute data from the production database to the failover database. Data moves from publisher to distributor, then is either "pushed" to the subscriber by the distributor or "pulled" from the distributor by the subscriber.
This topic assumes the publisher and subscriber run on distinct SQL Server instances on separate machines. The distributor may share an instance with either the publisher or subscriber, or run on its own.
Prerequisites
- The OpCon database server must have Microsoft SQL Server Standard or Enterprise edition installed.
- The Microsoft SQL Server Backward Compatibility Components must be installed. To download this package, go to: https://technet.microsoft.com/en-us/library/cc707787(v=sql.120).aspx.
- The version of SQL Server on the distributor must be the same or later than the version on the publisher.
- The OpCon database must exist on both the Publisher Server and Subscriber Server before starting replication setup. Both databases must have the Recovery model set to Full.
- OpCon SAM and supporting services must be installed on the Primary and Secondary OpCon servers.
- The Windows Agent must be installed on both the primary and secondary OpCon servers to facilitate backup file transfers during failover recovery. Machines must also be configured to enable SMA File Transfer. For information on configuring machines to support file transfer, refer to Advanced Machine Configuration in the Concepts online help.
- Complete the Replication Information Worksheet.
Considerations
The publisher and subscriber should run on comparable systems that can handle identical workloads.
Do not change the password for the distributor_admin login manually. Always use the sp_changedistributor_password stored procedure, the Distributor Properties dialog, or the Update Replication Passwords dialog in SQL Server Management Studio. Password changes made this way are applied to local publications automatically. If the distributor_admin password is changed manually, the DistributorKey entry in SMA_SetDBReplicationScriptingVariables.cmd must also be updated.
Microsoft recommends running each replication agent under a different Windows account with Windows authentication for all agent connections. Grant only the required privileges for each agent:
The scripts provided by Continuous to automate the replication setup automatically grant the appropriate database privileges. Folder share permissions must be configured manually.
Snapshot Agent
- Be a member of the
db_ownerfixed database role in the distribution database. - Have write permissions on the snapshot share.
- Be a member of the
db_ownerfixed database role in the publication database.
Log Reader Agent
- Be a member of the
db_ownerfixed database role in the distribution database. - Be a member of the
db_ownerfixed database role in the publication database.
Distribution Agent for a pull subscription
- Be a member of the
db_ownerfixed database role in the subscription database. - Be a member of the PAL (Publication Access List).
- Have read permissions on the snapshot share.
Distribution Agent for a push subscription
- Be a member of the
db_ownerfixed database role in the distribution database. - Be a member of the PAL.
- Have read permissions on the snapshot share.
- Be a member of the
db_ownerfixed database role in the subscription database.
A Windows domain user with SQL Server sysadmin fixed server role privileges on the distributor and subscriber SQL Server instances must exist. This user serves as the proxy for the replication agent accounts.
If using a pull subscription, use a network share rather than a local path for the snapshot folder.
Before releasing the SMAReplicationRecoverToPrimary Schedule, ensure all other OpCon Schedules are On Hold and no jobs are running.
Configuration
Configuration for automating replication setup includes the following steps:
- Verify Windows Accounts
- Configure the Command Files
- Configure Snapshot Folder Share and Permissions
- Import the SMAReplication Schedules
- Configure the Agent Machine Definitions
- Validate Property Definitions
- Configure the SMAReplicationSetup Schedule
- Configure the SMAReplicationMonitor Schedule
- Configure the SMAReplicationTearDown Schedule
Verify Windows Accounts
In the completed Replication Information Worksheet, there are Windows domain user accounts required for the replication process. With the completed worksheet for reference, complete the procedures below to verify that the users exist and that they are granted the sysadmin fixed server role in the distributor and subscriber SQL Server instances.
Verify and Create Windows Domain Accounts
To verify that the required Windows domain accounts exist and create any that are missing, complete the following steps:
- Log in as a domain administrator.
- Go to Start > Control Panel.
- Select Administrative Tools.
- Select Active Directory Users and Computers.
- Expand the Active Directory Name (for example,
CompanyName.local). - Select the Users folder.
- Find the user account listed for the DomainUser variable in the Name column on the right.
- If the account does not exist, right-click the Users folder and select New > User.
- Enter a descriptive name in the First Name field.
- Enter a last name in the Last Name field.
- Enter the name defined for the variable in the User Login Name field, then select Next.
- Enter a password in the Password field.
- Re-enter the password in the Confirm Password field.
- Clear the User must change password at next logon option.
- Select the Password never expires option, then select Next.
- If an Exchange server is on the network, choose the desired settings and select Next.
- Review the summary information and select Finish.
- Repeat steps 8–17 for the RunSnapshotAgentAs, RunLogReaderAgentAs, and RunDistributionAgentAs variables.
Result: The required Windows domain accounts exist and are ready for assignment.
Configure the Command Files
Continuous provides the following command files to automate replication setup:
SMA_DBReplicationSetUpDistributor.cmdSMA_DBReplicationSetUpPublisher.cmdSMA_DBReplicationCreatePullSubscriptionOnSubscriber.cmdSMA_DBReplicationCreatePullSubscriptionOnPublisher.cmdSMA_DBReplicationCreatePushSubscriptionOnPublisher.cmdSMA_DBReplicationStartSnapshotAgent.cmdSMA_DBReplicationMonitorLogReaderAgent.cmdSMA_DBReplicationMonitorDistributionAgent.cmd
Continuous provides the following command files to automate disabling replication:
SMA_DBReplicationDropPullSubscriptionOnSubscriber.cmdSMA_DBReplicationDropSubscriptionOnPublisher.cmdSMA_DBReplicationDropPushSubscriptionOnSubscriber.cmdSMA_DBReplicationRemovePublisher.cmdSMA_DBReplicationRemoveDistributor.cmdSMA_StopServiceManager.cmd
Continuous provides the following command file to automate recovery to the primary machine:
SMA_DBReplicationRestoreDBOnPublisher.cmd
Continuous provides the following command files to set scripting variables required by the other command files:
SMA_SetDBReplicationScriptingVariables.cmdSMA_SetDBMaintenanceScriptingVariables.cmd
Modify the Scripting Variables Command Files on the Primary Server
To set the scripting variable values for the primary server, complete the following steps:
- Log on as a Windows user with access to the OpCon installation directories.
- Go to Start > All Programs > OpConxps > Utilities > SMA OpCon Configuration Utility.
- Select the Replication tab.
- Replace the default values of the scripting variables according to the Replication Information Worksheet.
- After reviewing all values on the screen, select the Replication Variables Verified option at the end of the list.
- If not previously configured during installation, configure the Environment and Maintenance tabs and replace the default values.
- Select Update Scripts.
- Select Close.
Result: The scripting variable values are saved and the command files are updated for the primary server.
Copy the Command Files to the Secondary Server
To copy the command files from the primary server to the secondary server, complete the following steps:
-
On the primary OpCon Server, right-click Start and select Explore.
-
Go to
<Configuration Directory>\Utilities\Database\.noteThe Configuration Directory location depends on where you installed OpCon. For more information, refer to File Locations in the Concepts online help.
-
Hold the Ctrl key and select each of the following files:
SMA_DBReplicationSetUpDistributor.cmdSMA_DBReplicationSetUpPublisher.cmdSMA_DBReplicationCreatePullSubscriptionOnSubscriber.cmdSMA_DBReplicationCreatePullSubscriptionOnPublisher.cmdSMA_DBReplicationCreatePushSubscriptionOnPublisher.cmdSMA_DBReplicationStartSnapshotAgent.cmdSMA_DBReplicationMonitorLogReaderAgent.cmdSMA_DBReplicationMonitorDistributionAgent.cmdSMA_DBReplicationDropPullSubscriptionOnSubscriber.cmdSMA_DBReplicationDropSubscriptionOnPublisher.cmdSMA_DBReplicationDropPushSubscriptionOnSubscriber.cmdSMA_DBReplicationRemovePublisher.cmdSMA_DBReplicationRemoveDistributor.cmdSMA_StopServiceManager.cmdSMA_DBReplicationRestoreDBOnPublisher.cmdSMA_SetDBReplicationScriptingVariables.cmdSMA_SetDBMaintenanceScriptingVariables.cmd
-
Press Ctrl+C to copy the files.
-
Go to
<Configuration Directory>\Utilities\Database\on the secondary SAM Application server.noteTo access the directory on the secondary server, that directory must be shared to the user currently logged on to the primary machine, or the user must have administrative access to the secondary server.
-
Press Ctrl+V to paste the files.
Result: All command files are available on both the primary and secondary servers.
Modify the SMA_SetReplicationScriptingVariables.cmd File on the Secondary Server
To update the server name variable for the secondary server, complete the following steps:
- Right-click
SMA_SetDBReplicationScriptingVariables.cmdand select Edit. - Find the OpConxpsServerName variable.
- Change the value of the variable to the correct value for the secondary server.
- Go to File > Save.
- Close the file.
Result: The secondary server command file references the correct server name.
Configure Snapshot Folder Share and Permissions
The snapshot folder on the Distributor server must be shared, and the SQL Agent users must have the correct permissions to the share.
Create the Snapshot Folder Share and Grant Permissions
To create the snapshot folder share and assign the required permissions, complete the following steps:
- Log on to the Distributor Database Server as a Windows user with local administrative privileges.
- Right-click Start and select Explore.
- Go to the repldata folder in the SQL installation path. The default path is
C:\Program Files\Microsoft SQL Server\MSSQL.10.MSSQLServer\MSSQL\repldata. - If the repldata folder does not exist:
- Select the MSSQL folder.
- Go to File > New > Folder.
- Enter
repldatato replace the NewFolder name.
- Right-click the repldata folder and select Sharing and Security.
- Select the Share this folder option.
- In the Share Name field, enter the share name used to define the REPLDATAFolder variable in
SMA_SetDBReplicationScriptingVariables.cmd. - Select Permissions.
- In the Permissions for repldata window, select Add.
- In the Select Users, Computers, or Groups window, if the From this location field does not contain the correct Active Directory location:
- Select Locations.
- Expand Entire Directory.
- Select the desired active directory name and select OK.
- Select Advanced, then select Find Now.
- Hold the Ctrl key and select both the RunSnapshotAgentAs and RunDistributionAgentAs users from the Name column.
- Select OK, then select OK again.
- In the Permissions for repldata window, select the user defined for the RunSnapshotAgentAs variable and select the Change option in the Permissions list.
- Select the user defined for the RunDistributionAgentAs variable and select the Read option in the Permissions list.
Result: The snapshot share is created and the SQL Agent service accounts have the correct permissions.
Import the SMAReplication Schedules
Continuous provides the SMAReplication.MDB file as a transport database for the Schedules and jobs that automate the replication processes.
Create a DSN for the Transport Database
To create a system DSN for the SMAReplication transport database, complete the following steps:
The first time the utility starts, a prompt appears to select a DSN for the Microsoft Access database. If this is not the first time the utility has started, log in to the OpCon database, then create the DSN for the SMAUtility database and the AdHoc database.
- Log in to the primary SAM application server as a local administrative user.
- Go to Start > Programs > Opconxps > Utilities > Schedule Import Export.
- Select ODBC.
- Select the System DSN tab and select Add.
- Select Microsoft Access Driver (*.mdb) in the list and select Finish.
- Enter
SMAReplicationin the Data Source Name field. - (Optional) Enter a description in the Description field and select Select.
- In the Directories frame, browse to the
SMAReplication.MDBfile (for example,C:\Program Files\OpConxps\Utilities\IMPEX.MDB). - Select the
.mdbfile and select OK. - Select OK three times to close all dialogs.
Result: A system DSN named SMAReplication is available for use by the Schedule Import Export utility.
Log In to the Schedule Import Export Utility
To log in to the Schedule Import Export utility and select the SMAReplication data source, complete the following steps:
- Enter any OpCon user account with privileges to import and export Schedules (for example,
ocadm) in the User Login ID field. For information on user accounts, refer to User Accounts in the Concepts online help. - Enter the password for the user in the Password field.
- Select the OpCon database in the Data Source field and select OK.
- Go to File > Select Access DSN.
- Select the SMAReplication data source in the list and select OK.
Import the SMAReplication Schedules
To import the SMAReplication Schedules from the transport database, complete the following steps:
- Select one of the four Schedules in the Transport Database list to select them all.
- Select Import from Transport Database on the toolbar.
- Select the Machine tab.
- Select the machine named SMAReplicationPrimary.
- Select the Machine Name of the Windows Agent installed on the primary OpCon server.
- Select the machine named SMAReplicationSecondary.
- Select the Machine Name of the Windows Agent installed on the secondary OpCon server.
- Select Import.
- Select OK on the warning message about Batch User IDs.
- Select OK on the termination message.
Result: The SMAReplication Schedules are imported into the OpCon database.
Configure the Agent Machine Definitions
The Agents on the primary and secondary SAM application servers must have specific configurations for all replication jobs to run successfully. Complete the procedures below to make the required configurations.
Log In to the Primary Database from Enterprise Manager
To log in to the primary OpCon database using Enterprise Manager, complete the following steps:
- Go to Start > Programs > OpConxps > Enterprise Manager.
- Enter a case-sensitive User Login ID (for example,
ocadm) in the Username field. - Enter the case-sensitive password in the Password field.
- Select the Profile to the Primary database in the Profile list.
- Select Login.
Configure the Agent Machine Definitions
To configure the machine definitions for the primary and secondary Agents, complete the following steps:
- Select Machines.
- Select the Primary Machine in the Select Machine list.
- Right-click the machine graphic and select Stop Communication.
- Select Open Advanced Settings Panel.
- Select Allow "Kill Job".
- Select True from the list and select Update.
- Select the Communication Settings tab.
- Select JORS Port Number.
- Enter the JORS Port Number as defined in the
MSLSAM.inifile in the Agent's<Configuration Directory>\MSLSAMfolder (for example,3110), then select Update. - Select Requires XML Escape Sequences.
- Confirm the value is True and select Accept.
- Review the value for SMA Communications Protocol. If it is set to Contemporary XML, continue with this procedure. If the setting has any other value, contact support@smatechnologies.com for more information.
- Select the File Transfer Settings tab.
- Select File Transfer.
- Select Two-way in the list and select Update.
- Select File Transfer Port Number.
- Enter the same port number entered for the JORS Port Number in step 9, then select Update.
- Select Save.
- Right-click the machine graphic and select Start Communication.
- Select the Secondary Machine in the Select Machine list.
- Repeat steps 3–19 for the secondary machine.
Result: Both Agents are configured with the correct communication and file transfer settings for replication.
Validate Property Definitions
The replication jobs use several OpCon Global Properties. The values for these properties must be configured correctly for the replication jobs to succeed.
To validate and update the required Global Property values, complete the following steps:
- In Enterprise Manager under Administration, select Global Properties.
- Select SMAOpConDataPath in the Select Global Property list.
- In the Global Property Value field, verify the path to the
<Configuration Directory>on the SAM Application server.- If the path differs from the default (
C:\ProgramData\OpConxps\), update the value to match the correct path. - Select Save.
- If the path differs from the default (
- Select SMAOpConPath in the Select Global Property list.
- In the Global Property Value field, verify the path to the Utilities folder on the SAM Application server.
- If the path differs from the default (
C:\Program Files\OpConxps\), update the value. - Select Save.
- If the path differs from the default (
- Select PrimaryDBUpdateKey in the Select Global Property list.
- Replace
SMA$usain the Global Property Value field with the sa password on the Primary Database Server, then select Save. - Select FullDBBackupOn2ndary in the Select Global Property list.
- In the Global Property Value field, verify the full path and file name of the full database backup file on the secondary SAM Application server as created by the
SMADBBackupjob.- If the path or file name differs, update the value, then select Save.
- Select FullDBBackupOnPrimary in the Select Global Property list.
- In the Global Property Value field, verify the full path and file name of the full database backup file on the primary SAM Application server as created by the
SMADBBackupjob.- If the path or file name differs, update the value, then select Save.
- Select SecondaryDBUpdateKey in the Select Global Property list.
- Replace
SMA$usain the Global Property Value field with the sa password on the Secondary Database Server, then select Save. - Select TLogBackupOn2ndary in the Select Global Property list.
- In the Global Property Value field, verify the full path and file name of the transaction log backup file on the secondary SAM Application server as created by the
SMATLogBackupjob.- If the path or file name differs, update the value, then select Save.
- Select TLogBackupOnPrimary in the Select Global Property list.
- In the Global Property Value field, verify the full path and file name of the transaction log backup file on the primary SAM Application server as created by the
SMADBBackupjob.- If the path or file name differs, update the value, then select Save.
Result: All Global Properties are verified and set to the correct values for replication.
Configure the SMAReplicationSetup Schedule
By default, Continuous distributes the SMAReplicationSetup Schedule with Pull Replication configured. The CreatePullSubscriptionOnPublisher and CreatePullSubscriptionOnSubscriber jobs are active by default. If Push Replication will be used, modify the job frequencies to disable the Pull jobs and enable the CreatePushSubscriptionOnPublisher job.
Configure the SMAReplicationSetup Jobs for Push Replication
To configure the SMAReplicationSetup Schedule for Push Replication, complete the following steps:
- Select Job Master.
- Select SMAReplicationSetup in the Schedule list.
- Select CreatePullSubscriptionOnPublisher in the Job list.
- Select the Frequency tab.
- Select the Do Not Schedule option in the Job Build Status frame and select Save.
- Select CreatePullSubscriptionOnSubscriber in the Job list.
- Select the Do Not Schedule option and select Save.
- Select CreatePushSubscriptionOnPublisher in the Job list.
- Select the Release option and select Save.
Result: The SMAReplicationSetup Schedule is configured to use Push Replication.
Configure the SMAReplicationMonitor Schedule
The SMAReplicationMonitor Schedule must run every day to ensure replication runs without interruption. If either monitor job fails, configure notifications so an administrator can address the problem and restart replication.
Configure the SMAReplicationMonitor Schedule for Auto-Build and Delete
To configure the SMAReplicationMonitor Schedule for automatic build and delete, complete the following steps:
- Select Schedule Master.
- Select SMAReplicationMonitor in the Schedule list.
- Select the Auto Build option.
- Enter
1or any desired value for the days in advance to build. - Enter
1or any desired value for the number of days to build. - Select the Auto Delete option.
- Enter
1or any desired value for the days ago to delete. - Select Save.
Result: The SMAReplicationMonitor Schedule builds and deletes automatically each day.
Set Up Notifications for the SMAReplicationMonitor Jobs
The following procedure configures text message notifications through job-level events. The notification can use any $NOTIFY event type and can instead be managed through the Event Notification System (ENS). For information on ENS, refer to Event Notification in the Concepts online help.
If notifications are not configured on the SMAReplicationMonitor jobs, replication could fail without anyone noticing. While the method described below is not required, Continuous strongly recommends configuring some form of automatic notification.
To configure text message notifications for the SMAReplicationMonitor jobs, complete the following steps:
- In Enterprise Manager under Administration, select Job Master.
- Select SMAReplicationMonitor in the Schedule list.
- Select MonitorDistributionAgent in the Job list.
- Select the Events tab.
- Select Add.
- Select the $NOTIFY:TEXTMSG template in the Event Template list.
- Select Failed in the Job Status list.
- In the text field below the Job Status list:
- Replace
<to>with the email address for the cell phone number. - Replace
<message>with the notification text. Continuous recommends:Replication has failed on the OpConxps database. The [[$JOB NAME]] job has failed.
noteThe completed event string reads:
$NOTIFY:TEXTMSG,5551212@cellprovider.com,Replication has failed on the OpConxps database. The [[$JOB NAME]] job has failed.- Select all of the text defined for
<to>and<message>and press Ctrl+C to copy it for use with the next job. - Select OK.
- Replace
- Select MonitorLogReaderAgent in the Job list.
- Select the Events tab and select Add.
- Select the $NOTIFY:TEXTMSG template in the Event Template list.
- Select Failed in the Job Status list.
- Select the text field below the Job Status list and press Ctrl+V to paste the text from the previous event definition.
- Modify the email address and message if desired and select OK.
Result: Both SMAReplicationMonitor jobs send a text message notification when they fail.
Configure the SMAReplicationTearDown Schedule
By default, Continuous distributes the SMAReplicationTearDown Schedule with Pull Replication configured. The DropPullSubscriptionOnSubscriber and DropPullSubscriptionOnPublisher jobs are active by default. If Push Replication will be used, modify the job frequencies to disable the Pull jobs and enable the DropPushSubscriptionOnPublisher and DropPushSubscriptionOnSubscriber jobs.
Configure the SMAReplicationTearDown Jobs for Push Replication
To configure the SMAReplicationTearDown Schedule for Push Replication, complete the following steps:
- Select Job Master (if not already open).
- Select SMAReplicationTearDown in the Schedule list.
- Select DropPullSubscriptionOnSubscriber in the Job list.
- Select the Frequency tab.
- Select the Do Not Schedule option in the Job Build Status frame and select Save.
- Select DropPullSubscriptionOnPublisher in the Job list.
- Select the Do Not Schedule option and select Save.
- Select DropPushSubscriptionOnPublisher in the Job list.
- Select the Release option and select Save.
- Select DropPushSubscriptionOnSubscriber in the Job list.
- Select the Release option and select Save.
Result: The SMAReplicationTearDown Schedule is configured to use Push Replication.
Automated Replication Setup
Continuous provides two Schedules for automated replication setup:
SMAReplicationSetup Schedule Definition
The SMAReplicationSetup Schedule runs on demand when initially setting up replication, when the primary server comes back online after an outage, or after a failover event. The Schedule consists of the following OpCon jobs:
- SetUpDistributor
- SetUpPublisher
- CreatePullSubscriptionOnSubscriber
- CreatePullSubscriptionOnPublisher
- CreatePushSubscriptionOnPublisher
- StartSnapshotAgent
SetUpDistributor
The SetUpDistributor job runs SMA_DBReplicationSetUpDistributor.sql via SMA_DBReplicationSetUpDistributor.cmd. This job configures the distributor, creates the distribution database, adds the replication housekeeping jobs to SQL Server Agent, and adds the Snapshot Agent job and Log Reader Agent job to SQL Server Agent on the distributor instance.
The log file is placed in the directory configured in the SQLScriptOutputDirectory scripting variable and is named <PublicationName>_ReplicationSetUpDistributor.log. After the job finishes, review this log file for errors, paying special attention to SQL Server errors.
SetUpPublisher
The SetUpPublisher job runs SMA_DBReplicationSetUpPublisher.sql via SMA_DBReplicationSetUpPublisher.cmd. This job configures the publisher server, enables the OpCon database for publishing, creates the publication, and adds the articles to be published.
The log file is named <PublicationName>_ReplicationSetUpPublisher.log. After the job finishes, review this log file for errors, paying special attention to SQL Server errors.
CreatePullSubscriptionOnSubscriber
The CreatePullSubscriptionOnSubscriber job runs SMA_DBReplicationCreatePullSubscriptionOnSubscriber.sql via SMA_DBReplicationCreatePullSubscriptionOnSubscriber.cmd. This job creates the pull subscription on the subscriber server and adds the distribution agent job to SQL Server Agent on the subscriber instance.
The log file is named <PublicationName>_SubscriberCreatePullSubscription.log. After the job finishes, review this log file for errors, paying special attention to SQL Server errors.
CreatePullSubscriptionOnPublisher
The CreatePullSubscriptionOnPublisher job runs SMA_DBReplicationCreatePullSubscriptionOnPublisher.sql via SMA_DBReplicationCreatePullSubscriptionOnPublisher.cmd. This job creates the pull subscription information on the publisher server.
The log file is named <PublicationName>_CreatePullSubscriptionOnPublisher.log. After the job finishes, review this log file for errors, paying special attention to SQL Server errors.
CreatePushSubscriptionOnPublisher
The CreatePushSubscriptionOnPublisher job runs SMA_DBReplicationCreatePushSubscriptionOnPublisher.sql via SMA_DBReplicationCreatePushSubscriptionOnPublisher.cmd. This job creates the push subscription on the publisher server. By default, this job's frequency is set to Do Not Schedule because Pull subscription is enabled by default. To use Push subscription, set this job to a Release build status and change the Pull subscription jobs to Do Not Schedule. For more information, refer to Configure the SMAReplicationSetup Jobs for Push Replication.
The log file is named <PublicationName>_CreatePushSubscriptionOnPublisher.log. After the job finishes, review this log file for errors, paying special attention to SQL Server errors.
StartSnapshotAgent
The StartSnapshotAgent job runs SMA_DBReplicationStartSnapshotAgent.cmd. This job uses SMASqlSMOAPP.EXE to start the Snapshot Agent on the distributor server so that the initial snapshot of the OpCon database is created.
The log file is named StartSnapshotAgent.log. After the job finishes, review this log file for errors, paying special attention to SQL Server errors.
SMAReplicationMonitor Schedule Definition
The SMAReplicationMonitor Schedule runs every day to continuously monitor the Log Reader Agent and Distribution Agent SQL Server Agent jobs. The Schedule consists of two OpCon jobs.
MonitorDistributionAgent
The MonitorDistributionAgent job runs SMA_DBReplicationMonitorDistributionAgent.cmd. This job uses SMASqlSMOAPP.EXE to monitor the Distribution Agent and verify that it is running continuously. For pull subscriptions, the Distribution Agent runs on the subscriber server; for push subscriptions, it runs on the distributor server. The job automatically detects the subscription type and runs against the correct SQL instance.
If this job fails, review the SQL Server Agent Error Logs in SQL Server Management Studio under SQL Server Agent > Error Logs.
MonitorLogReaderAgent
The MonitorLogReaderAgent job runs SMA_DBReplicationMonitorLogReaderAgent.cmd. This job uses SMASqlSMOAPP.EXE to monitor the Log Reader Agent on the distributor server and verify that it is running continuously.
If this job fails, review the SQL Server Agent Error Logs in SQL Server Management Studio under SQL Server Agent > Error Logs.
Building and Running the Replication Setup Schedules
After meeting all of the Prerequisites and completing the Configuration, you can set up replication at any time by building the SMAReplicationSetup and SMAReplicationMonitor Schedules. Complete the procedures in this section to set up replication.
Build the Replication Schedules On Hold
To build the replication Schedules, complete the following steps:
- Log in to Enterprise Manager using the Log In to the Primary Database from Enterprise Manager procedure.
- Select Schedule Build.
- Select SMAReplicationSetup in the Schedule Selection frame.
- Accept the default options so the Schedules build for today.
- Select the Overwrite existing schedules option and select Build.
- Accept the default selection to build the Schedule On Hold and select OK.
- Select SMAReplicationMonitor in the Schedule Selection frame.
- Accept the default date for the Start date (today).
- In the Stop date, select tomorrow's date from the calendar.
- Select the Overwrite option and select Build.
- Accept the default selection to build the Schedule On Hold and select OK.
- Select Close.
Result: Both Schedules are built for today with a status of On Hold.
Run the SMAReplicationSetup Schedule
To run the SMAReplicationSetup Schedule and start replication, complete the following steps:
- Select List.
- Select today's date.
- In the tree view, select SMAReplicationSetup to see the jobs.
- Right-click SMAReplicationSetup and select Release.
- Wait for all jobs to finish with a status of Finished OK. If any jobs fail, review the log files to determine the cause, fix the error, then restart the failed job.
- After all jobs finish with Finished OK, review the log files for each job to verify replication is set up correctly.
Microsoft SQL Server procedures for setting up replication do not always return error codes to scripts. Review the log files for each job as described in the SMAReplicationSetup Schedule Definition section.
Result: Replication is set up and running between the publisher and subscriber servers.
Run the SMAReplicationMonitor Schedule and Configure Daily Monitoring
After replication is successfully set up through the SMAReplicationSetup Schedule, complete the following steps to monitor replication status automatically:
- In the tree view under today's date, select SMAReplicationMonitor to see the jobs.
- Right-click SMAReplicationMonitor and select Release.
Result: The SMAReplicationMonitor Schedule runs and begins monitoring replication daily.
Controlled Failover with Automation
The SMAReplicationTearDown Schedule is included with the SMA Replication Schedules for use in failover testing. This Schedule assists customers who perform disaster recovery, business continuity, and failover and recovery testing.
SMAReplicationTearDown Schedule Definition
The SMAReplicationTearDown Schedule consists of nine OpCon jobs:
- KillReplicationMonitors
- DropPullSubscriptionOnSubscriber
- DropPullSubscriptionOnPublisher
- DropPushSubscriptionOnPublisher
- DropPushSubscriptionOnSubscriber
- RemovePublisher
- RemoveDistributor
- RunDBUpdateCmdOnSecondary
- StopSMAServiceManagerOnPrimary
After the RemoveDistributor job runs, you can check the Replication Monitor to confirm that the replication process has been completely removed.
KillReplicationMonitors
The KillReplicationMonitors job stops the jobs running on the SMAReplicationMonitor Schedule before replication is stopped by the other jobs. The job is a NULL job that finishes with Finished OK and then triggers $JOB:KILL events.
DropPullSubscriptionOnSubscriber
The DropPullSubscriptionOnSubscriber job runs SMA_DBReplicationDropPullSubscriptionOnSubscriber.sql via SMA_DBReplicationDropPullSubscriptionOnSubscriber.cmd. This job drops the pull subscription from the subscriber server and removes the distribution agent job from SQL Server Agent on the subscriber instance.
The log file is named <PublicationName>_SubscriberDropPullSubscription.log. After the job finishes, review this log file for errors, paying special attention to SQL Server errors.
When this job finishes with Finished OK, replication has stopped and data processed on the publisher server will not be sent to the subscriber server.
DropPullSubscriptionOnPublisher
The DropPullSubscriptionOnPublisher job runs SMA_DBReplicationDropSubscriptionOnPublisher.sql via SMA_DBReplicationDropSubscriptionOnPublisher.cmd. This job drops the pull subscription from the publisher server.
The log file is named <PublicationName>_DropSubscriptionOnPublisher.log. After the job finishes, review this log file for errors, paying special attention to SQL Server errors.
DropPushSubscriptionOnPublisher
The DropPushSubscriptionOnPublisher job runs SMA_DBReplicationDropSubscriptionOnPublisher.sql via SMA_DBReplicationDropSubscriptionOnPublisher.cmd. This job drops the push subscription from the publisher server. By default, this job's frequency is set to Do Not Schedule because Pull subscription is enabled by default. To use Push subscription, set this job to a Release build status and change the Pull subscription jobs to Do Not Schedule. For more information, refer to Configure the SMAReplicationTearDown Jobs for Push Replication.
The log file is named <PublicationName>_DropSubscriptionOnPublisher.log. After the job finishes, review this log file for errors, paying special attention to SQL Server errors.
When this job finishes with Finished OK, replication has stopped and data processed on the publisher server will not be sent to the subscriber server.
DropPushSubscriptionOnSubscriber
The DropPushSubscriptionOnSubscriber job runs SMA_DBReplicationDropPushSubscriptionOnSubscriber.sql via SMA_DBReplicationDropPushSubscriptionOnSubscriber.cmd. This job cleans up metadata about the push subscription on the subscriber server. By default, this job's frequency is set to Do Not Schedule because Pull subscription is enabled by default. To use Push subscription, set this job to a Release build status and change the Pull subscription jobs to Do Not Schedule. For more information, refer to Configure the SMAReplicationTearDown Jobs for Push Replication.
The log file is named <PublicationName>_SubscriberDropPushSubscription.log. After the job finishes, review this log file for errors, paying special attention to SQL Server errors.
RemovePublisher
The RemovePublisher job runs SMA_DBReplicationRemovePublisher.sql via SMA_DBReplicationRemovePublisher.cmd. This job drops the published articles from the publication, drops the publication, disables replication on the OpCon database, and drops the subscriber SQL Server instance as a registered subscriber on the publisher instance.
The log file is named <PublicationName>_RemoveReplicationPublisher.log. After the job finishes, review this log file for errors, paying special attention to SQL Server errors.
RemoveDistributor
The RemoveDistributor job runs SMA_DBReplicationRemoveDistributor.sql via SMA_DBReplicationRemoveDistributor.cmd. This job drops the publisher at the distributor, drops the distribution database, disables distribution on the distributor, and removes the Log Reader Agent job and Distribution Agent job from SQL Server Agent on the distributor.
The log file is named <PublicationName>_RemoveReplicationDistributor.log. After the job finishes, review this log file for errors, paying special attention to SQL Server errors. When this job finishes with Finished OK, replication is disabled on the primary server. The next jobs prepare the secondary server to take over processing.
RunDBUpdateCmdOnSecondary
The RunDBUpdateCmdOnSecondary job runs DB_Update.cmd, which runs the following SQL scripts:
Schema_Install.sqlSMALOOKUP_Update.sqlDBFuncs_Install.sqlDBProcs_Install.sqlPDSAFramework.sqlPDSAFrameworkData.sql
This job ensures all primary keys and object permissions are applied to the OpCon database on the subscriber server, and that the database functions, stored procedures, and pertinent OpCon system data tables are current.
StopSMAServiceManagerOnPrimary
The StopSMAServiceManagerOnPrimary job runs SMA_StopServiceManager.cmd to stop the SMA Service Manager Windows service on the primary server. This job is optional and can be disabled if you prefer to stop SMA Service Manager manually.
If anyone is still logged in to a graphical interface with its DSN pointing at the primary OpCon database, this job stays in a Running state because the database cannot be updated after the SMA Service Manager stops.
Building and Running the SMAReplicationTearDown Schedule
After meeting all of the Prerequisites and completing the Configuration, you can disable replication at any time by building the SMAReplicationTearDown Schedule.
Build the SMAReplicationTearDown Schedule On Hold
To build the SMAReplicationTearDown Schedule, complete the following steps:
- Log in to Enterprise Manager using the Log In to the Primary Database from Enterprise Manager procedure.
- Select Schedule Build.
- Select SMAReplicationTearDown in the Schedule Selection frame.
- Accept the default options so the Schedule builds for today.
- Select the Overwrite existing schedules option and select Build.
- Accept the default selection to build the Schedule On Hold and select OK.
- Select Close.
Result: The SMAReplicationTearDown Schedule is built for today with a status of On Hold.
Run the SMAReplicationTearDown Schedule
To run the SMAReplicationTearDown Schedule and disable replication, complete the following steps:
- Select List.
- Select today's date.
- In the tree view, select SMAReplicationTearDown to see the jobs.
- Right-click SMAReplicationTearDown and select Release.
- Wait for all jobs to finish with a status of Finished OK. If any jobs fail, review the log files, fix the error, then restart the failed job.
- After all jobs finish with Finished OK, review the log files for each job to confirm replication is fully disabled.
Microsoft SQL Server procedures for disabling replication do not always return error codes to scripts. Review the log files for each job as described in the SMAReplicationTearDown Schedule Definition section.
Result: Replication is disabled and the secondary server is prepared to take over processing.
Fail Over to the Subscribing Database and Secondary SMA Service Manager
If SMA Service Manager should begin processing on the secondary server, configure SMA Service Manager on the secondary server, then complete the following steps to start the service:
- Log on to the secondary SAM application server as a local administrative user.
- Go to Start > Control Panel.
- Select Administrative Tools.
- Select Services.
- Select the SMA OpCon Service Manager service.
- Select Automatic (Delayed Start) in the Startup type list and select OK.
- Select Start to start the service, then close the Services window.
- Go to Start > Programs > OpConxps > Log Monitors > Log File.
- Open the
SMANetCom.log,SAM Critical.log, andSAM.logfiles to verify that the secondary server is processing normally. - When SAM 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.
Result: SMA Service Manager is running on the secondary server and processing jobs from the subscribing database.
Recovery to the Primary Server
The SMAReplicationRecoverToPrimary Schedule is included with the SMA Replication Schedules for use when transferring processing back to the primary server.
SMAReplicationRecoverToPrimary Schedule Definition
The SMAReplicationRecoverToPrimary Schedule consists of five OpCon jobs:
- TransferFullDBBackupToPrimary
- TransferTLogBackupToPrimary
- RestoreDatabaseOnPrimary
- RunDBUpdateCmdOnPrimary
- StopSMAServiceManagerOnSecondary
TransferFullDBBackupToPrimary
The TransferFullDBBackupToPrimary job uses the OpCon File Transfer feature to move the secondary database backup file to the primary server as a binary file.
TransferTLogBackupToPrimary
The TransferTLogBackupToPrimary job uses the OpCon File Transfer feature to move the secondary database transaction log file to the primary server as a binary file.
RestoreDatabaseOnPrimary
The RestoreDatabaseOnPrimary job runs SMA_DBReplicationRestoreDBOnPublisher.cmd to restore the database from the subscriber server onto the publisher server.
The RestoreDatabaseOnPrimary job performs three steps:
- Kill any database sessions active at the time.
- Restore the database.
- Delete the replication stored procedures (
sp_MS...) from the database.
RunDBUpdateCmdOnPrimary
The RunDBUpdateCmdOnPrimary job runs DB_Update.cmd, which runs the following SQL scripts:
Schema_Install.sqlSMALOOKUP_Update.sqlDBFuncs_Install.sqlDBProcs_Install.sqlPDSAFramework.sqlPDSAFrameworkData.sql
This job ensures all primary keys and object permissions are applied to the OpCon database on the publisher server, and that the database functions, stored procedures, and pertinent OpCon system data tables are current.
StopSMAServiceManagerOnSecondary
The StopSMAServiceManagerOnSecondary job runs SMA_StopServiceManager.cmd to stop the SMA Service Manager Windows service on the secondary server. This job is optional and can be disabled if you prefer to stop SMA Service Manager manually.
If anyone is still logged in to a graphical interface with its DSN pointing at the primary OpCon database, this job stays in a Running state because the database cannot be updated after the SMA Service Manager stops.
Building and Running the SMAReplicationRecoverToPrimary Schedule
After meeting all of the Prerequisites and completing the Configuration, you can restore processing to the primary server at any time by building the SMAReplicationRecoverToPrimary Schedule.
Build the SMAReplicationRecoverToPrimary Schedule On Hold
To build the SMAReplicationRecoverToPrimary Schedule, complete the following steps:
- Log in to Enterprise Manager using the Log In to the Primary Database from Enterprise Manager procedure.
- Select Schedule Build.
- Select SMAReplicationRecoverToPrimary in the Schedule Selection frame.
- Accept the default options so the Schedule builds for today.
- Select the Overwrite existing schedules option and select Build.
- Accept the default selection to build the Schedule On Hold and select OK.
- Select Close.
Result: The SMAReplicationRecoverToPrimary Schedule is built for today with a status of On Hold.
Run the SMAReplicationRecoverToPrimary Schedule
To run the SMAReplicationRecoverToPrimary Schedule and restore the primary database, complete the following steps:
- Select List.
- Select today's date.
- In the tree view, select SMAReplicationRecoverToPrimary to see the jobs.
- Right-click SMAReplicationRecoverToPrimary and select Release.
- Wait for all jobs to finish with a status of Finished OK. If any jobs fail, review the log files, fix the error, then restart the failed job.
Result: The primary database is restored from the secondary server and ready for the SMA Service Manager to start.
Start the SMA Service Manager on the Primary Server
After properly configuring SMA Service Manager on the primary server, complete the following steps to start the service:
- Go to Start > Control Panel.
- Select Administrative Tools.
- Select Services.
- Scroll to the SMA OpCon Service Manager service.
- Select SMA OpCon Service Manager.
- Select Automatic (Delayed Start) in the Startup type list and select OK.
- Select SMA OpCon Service Manager and select Start.
- Go to Start > Programs > OpConxps > Log Monitors > Log File Name.
- Review the
SMAServMan,SAM,Critical,SMANetCom, andSMANetComTracelogs to verify that SAM and SMANetCom connected successfully to the database.
Result: SMA Service Manager is running on the primary server and processing jobs from the primary database.