Setup for Automatic Microsoft SQL Replication
Theme: Configure
Who Is It For? System Administrator
What Is It?
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 MSLSAM 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, or the Distributor Properties, or the Update Replication Passwords dialog boxes 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 will automatically grant the appropriate database privileges. Folder share permissions must be configured manually.
Snapshot Agent
Be a member of the db_owner fixed database role in the distribution database
Have write permissions on the snapshot share
Be a member of the db_owner fixed database role in the publication database
Log Reader Agent
Be a member of the db_owner fixed database role in the distribution database
Be a member of the db_owner fixed database role in the publication database
Distribution Agent for a pull subscription
Be a member of the db_owner fixed 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_owner fixed 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_owner fixed 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:
- 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/or Create Windows Domain Accounts
Log in as a domain administrator
Use menu path: Start > Control Panel
Select Administrative Tools
Select Active Directory Users and Computers
Expand the Active Directory Name (e.g., CompanyName.local)
Select the Users folder
Find the user account listed for the DomainUser variable in the Name column on the right
If it does not exist, right-click the Users folder
Select New > User from the menu
Enter, in the First Name field, a name to help describe the user for the variable
Enter, in the Last Name field, a last name to help describe the user for the variable
Enter the name defined for the variable in the User Login Name field and select Next
Enter a password for the user in the Password field
Reenter the password for the user in the Confirm Password field
Unselect the User must change password at next logon option
Select the Password never expires option and select Next
If an Exchange server is on the network, choose the desired settings and select Next
Review the summary information for the user and select Finish
Find the user account listed for the RunSnapshotAgentAs variable in the Name column on the right
If it does not exist, right-click the Users folder
Repeat Steps 9 - 16
Find the user account listed for the RunLogReaderAgentAs variable in the Name column on the right
If it does not exist, right-click the Users folder
Repeat Steps 9 - 16
Find the user account listed for the RunDistributionAgentAs variable in the Name column on the right
If it does not exist, right-click the Users folder
Repeat Steps 9 - 16
Configure the Command Files
Continuous provides the following command files to automate replication setup:
- SMA_DBReplicationSetUpDistributor.cmd
- SMA_DBReplicationSetUpPublisher.cmd
- SMA_DBReplicationCreatePullSubscriptionOnSubscriber.cmd
- SMA_DBReplicationCreatePullSubscriptionOnPublisher.cmd
- SMA_DBReplicationCreatePushSubscriptionOnPublisher.cmd
- SMA_DBReplicationStartSnapshotAgent.cmd
- SMA_DBReplicationMonitorLogReaderAgent.cmd
- SMA_DBReplicationMonitorDistributionAgent.cmd
Continuous provides the following command files to automate disabling replication:
- SMA_DBReplicationDropPullSubscriptionOnSubscriber.cmd
- SMA_DBReplicationDropSubscriptionOnPublisher.cmd
- SMA_DBReplicationDropPushSubscriptionOnSubscriber.cmd
- SMA_DBReplicationRemovePublisher.cmd
- SMA_DBReplicationRemoveDistributor.cmd
- SMA_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.cmd
- SMA_SetDBMaintenanceScriptingVariables.cmd
Modify the Scripting Variables Command Files on the Primary Server
- Log on as a Windows user with access to the OpCon installation directories
- Use menu path: 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 the values on the screen, select the Replication Variables Verified option at the end of the list of values
- If not previously configured during installation, configure the Environment and Maintenance tabs
- Replace the default values of the scripting variables
- Select the Update Scripts button
- Close the program
Copy the Command Files to the Secondary Server
On the OpCon Server:
- Right-click on Start and select Explore
- Browse to the <Configuration Directory>\Utilities\Database\ directorynote
The Configuration Directory location is based on where you installed your programs. For more information, refer to File Locations in the Concepts online help.
- Press the Ctrl key and hold while clicking the following files:
- SMA_DBReplicationSetUpDistributor.cmd
- SMA_DBReplicationSetUpPublisher.cmd
- SMA_DBReplicationCreatePullSubscriptionOnSubscriber.cmd
- SMA_DBReplicationCreatePullSubscriptionOnPublisher.cmd
- SMA_DBReplicationCreatePushSubscriptionOnPublisher.cmd
- SMA_DBReplicationStartSnapshotAgent.cmd
- SMA_DBReplicationMonitorLogReaderAgent.cmd
- SMA_DBReplicationMonitorDistributionAgent.cmd
- SMA_DBReplicationDropPullSubscriptionOnSubscriber.cmd
- SMA_DBReplicationDropSubscriptionOnPublisher.cmd
- SMA_DBReplicationDropPushSubscriptionOnSubscriber.cmd
- SMA_DBReplicationRemovePublisher.cmd
- SMA_DBReplicationRemoveDistributor.cmd
- SMA_StopServiceManager.cmd
- SMA_DBReplicationRestoreDBOnPublisher.cmd
- SMA_SetDBReplicationScriptingVariables.cmd
- SMA_SetDBMaintenanceScriptingVariables.cmd
- Press Ctrl+C to copy the files or right-click the selected list and select Copy from the menu
- Browse to the Secondary SAM Application server to the <Configuration Directory>\Utilities\Database directory and select in the foldernote
To access the directory on the Secondary server, the 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, or right select in the directory and select Paste from the menu
Continue with the procedure below from the same Explorer window and directory open to the Secondary server.
Modify the SMA_SetReplicationScriptingVariables.cmd File on the Secondary Server
- Right-click the SMA_SetDBReplicationScriptingVariables.cmd file and select Edit from the menu
- Find the OpConxpsServerName variable
- Change the value of the variable to the correct value for the Secondary server
- Use menu path: File > Save
- Close the file
Configure Snapshot Folder Share and Permissions
The snapshot folder on the Distributer 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
Log on to the Distributer Database Server as a Windows user with local administrative privileges
Right-click on Start and select Explore
In the Explorer window: Browse 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
- Use menu path: File > New > Folder
- Enter repldata to replace the NewFolder name
Right-click the repldata folder and select Sharing and Security from the menu
Select the Share this folder radio button
In the Share Name field, set the name to the share name used to define the REPLDATAFolder variable in the SMA_SetDBReplicationScriptingVariables.cmd file
Select the Permissions button
In the Permissions for repldata window: Select Add
In the Select Users, Computers, or Groups window: If the From this location box does not contain the correct Active Directory Location:
- Select the Locations button
- Expand the Entire Directory
- Select the desired active directory name and select OK
In the Select Users, Computers, or Groups window: Select the Advanced button
Select the Find Now button
Press and hold the Ctrl key on the keyboard
In the Name column, select the users definedfor the RunSnapshotAgentAs and RunDistributionAgentAs variables in the SMA_SetDBReplicationScriptingVariables.cmd file
Release the Ctrl key and select OK
Select OK again
In the Permissions for repldata window: Select the user defined for the RunSnapshotAgentAs variable
Select the Change option in the Permissions list
Select the user defined for the RunDistributionAgentAs variable
Select the Read option in the Permissions list
Import the SMAReplication Schedules
Continuous provides the SMAReplication.MDB file as a transport database for the schedules and jobs to automate the replication processes.
Create a DSN for the Transport Database
The first time the utility is activated, there is a prompt to select a DSN for the Microsoft Access database. If this is not the first time the utility has been activated, log in to the OpCon database and 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
Use menu path: Start > Programs > Opconxps > Utilities > Schedule Import Export
Select the ODBC button
Select the System DSN tab and select Add
Select Microsoft Access Driver (*.mdb) in the list and select Finish
Enter SMAReplication in the Data Source Name text box
(Optional) Enter a description in the Description text box and select Select
Go to the Directories frame
Browse to the SMAReplication.MDB file (e.g., C:\Program Files\OpConxps\Utilities\IMPEX.MDB)
Select the .mdb file then select OK
Select OK(again)
Select OK
Select OK
Log In to the Schedule Import Export Utility to Import the SMAReplication Schedule
- Enter, in the User Login ID field, any OpCon user account with privileges to import and export schedules (e.g., ocadm). For information on User Accounts, refer to User Accounts in the Concepts online help
- Enter the password for the user in the Password text box
- Select the OpCon database in the Data Source field and select OK
- Use menu path: File > Select Access DSN
- Select the new SMAReplication datasource in the list and select OK
Import the SMAReplication Schedules
Select on one of the four schedules in the Transport Database list box to select them all
Select the Import from Transport Database button on the toolbar
Select the Machine tab
Select the machine named SMAReplicationPrimary
Select the Machine Name of the MSLSAM installed on the Primary OpCon server
Select the machine named SMAReplicationSecondary
Select the Machine Name of the MSLSAM installed on the Secondary OpCon server
Select the Import button
Select OK on the warning message about Batch User IDs
Select OK on the termination message
Configure the agent Machine Definitions
The agents on the Primary and Secondary SAM application servers must have certain configurations in the database for all replication jobs to run successfully. Complete the procedures below to make the required configurations.
Log in to the Primary Database from the Enterprise Manager
- Use menu path: Start > Programs > OpConxps > Enterprise Manager
- Enter a case-sensitive User Login ID (e.g., ocadm) in the Username text box
- Enter the case-sensitive password for the user in the Password text box
- Select the Profile to the Primary database in the Profile list
- Select Login to login to the Enterprise Manager
Configure the agent Machine Definitions
Select Machines
Select the Primary Machine in the Select Machine list
Right-click over the graphic and select Stop Communication from the menu
Select on 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 it is defined in the MSLSAM.ini file found in the agent's <Configuration Directory>\MSLSAM folder (e.g., 3110), and select Update
Select Requires XML Escape Sequences
Confirm the value for this setting is True and select Accept
Look at the value for the SMA Communications Protocol. If it is set to Contemporary,XML, continue with this procedure. If the parameter 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 box and select Update
Select File Transfer Port Number
Enter the same port number as was entered for the JORS Port Number in Step 8 and select Update
Select Save
Right-click over the graphic and select Start Communication from the menu
Select the Secondary Machine in the Select Machine list
Repeat Steps 3 - 20
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.
Validate Property Definitions
- In EM Navigation under Administration select Global Properties
- On the Global Properties Editor: Select SMAOpConDataPath in the Select Global Property list box
- In the Global Property Value text box, verify the path to the <Configuration Directory> on the SAM Application server
- If the path differs from the default (i.e., C:\ProgramData\OpConxps\), modify the value to match the correct path
- Select
Save
- Select SMAOpConPath in the Select Global Property list box
- In the Global Property Value text box, verify the path to the Utilities folder on the SAM Application server
- If the path differs from the default (i.e., C:\Program Files\OpConxps\), modify the value to match the correct path
- Select
Save
- Select PrimaryDBUpdateKey in the Select Global Property list box
- Replace SMA$usa in the Global Property Value text box with the sa password on the Primary Database Server
- Select
Save
- Select FullDBBackupOn2ndary in the Select Global Property list box
- In the Global Property Value text box, verify the full path and file name of the full database backup file on the Secondary SAM Application Server as would be created by the SMADBBackup job
- If the path or file name differs, modify the value to match the correct path and filename
- Select
Save
- Select FullDBBackupOnPrimary in the Select Global Property list box
- In the Global Property Value text box, verify the full path and file name of the full database backup file on the Primary SAM Application Server as would be created by the SMADBBackup job
- If the path or file name differs, modify the value to match the correct path and filename
- Select
Save
- Select SecondaryDBUpdateKey in the Select Global Property list box
- Replace SMA$usa in the Global Property Value text box with the sa password on the Secondary Database Server
- Select
Save
- Select TLogBackupOn2ndary in the Select Global Property list box
- In the Global Property Value text box, verify the full path and file name of the transaction log backup file on the Secondary SAM Application Server as would be created by the SMATLogBackup job
- If the path or file name differs, modify the value to match the correct path and filename
- Select
Save
- Select TLogBackupOnPrimary in the Select Global Property list box
- In the Global Property Value text box, verify the full path and file name of the transaction log backup file on the Primary SAM Application Server as would be created by the SMADBBackup job
- If the path or file name differs, modify the value to match the correct path and filename
- Select
Save
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
Select Job Master
Select SMAReplicationSetup in the Schedule list
Select CreatePullSubscriptionOnPublisher in the Job list
Select the Frequency tab
Select the Do Not Schedule radio button in the Job Build Status frame and select
Save
Select CreatePullSubscriptionOnSubscriber in the Job list
Select the Do Not Schedule radio button and select
Save
Select CreatePushSubscriptionOnPublisher in the Job list
Select the Release radio button and select
Save
Configure the SMAReplicationMonitor Schedule
The SMAReplicationMonitor schedule must run every day to ensure replication runs without interruption. If either monitor job fails, notifications should be configured so an administrator can address the problem and restart replication.
Configure the SMAReplicationMonitor Schedule for Auto-Build and Delete
- Select Schedule Master
- Select SMAReplicationMonitor in the Schedule list
- Select the Auto Build option
- Enter 1 or any desired value for the days in advance to build
- Enter 1 or any desired value for the number of days to build
- Select the Auto Delete option
- Enter 1 or any desired value for the days ago to delete
- Select
Save
Set up Notifications for the SMAReplicationMonitor Jobs
The following procedure configures text messages through job level events. The notification can be any $NOTIFY type event and could instead be managed through ENS if desired. 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 need not be used, Continuous strongly recommends that some form of automatic notification be configured.
In EM Navigation under Administration: Select Job Master
In the Job Master editor under the Selection section: Select SMAReplicationMonitor in the Schedule list
Select MonitorDistributionAgent in the Job list
In the Job Properties section: Select the Events tab
On the Events tab: Select Add
On the Event Definition dialog: Select the $NOTIFY:TEXTMSG template in the Event Template list
Select Failed in the Job Status list
Below the Job Status list:
- Replace <to> with the email address to a cell phone number
- Replace <message> with the message to deliver in the text. Continuous recommends the following message:
Replication has failed on the OpConxps database. The [[$JOB NAME]] job has failed.noteThe finished event string would read:
$NOTIFY:TEXTMSG,5551212@cellprovider.com,Replication has failed on the OpConxps database. The [[$JOB NAME]] job has failed.::: 3. Select all of the text defined for the <to> and <message> (all of the text should be highlighted gray) 4. Press Ctrl + C on the keyboard to copy the text for use with the next job 5. Select OKUnder the Selection section: Select MonitorLogReaderAgent in the Job list
On the Events tab: Select Add
On the Event Definition dialog: Select the $NOTIFY:TEXTMSG template in the Event Template list
Select Failed in the Job Status list
Select in the field below the Job Status list and press Ctrl + V on the keyboard to paste the text from the previous event definition (refer to Step 8d)
Modify the email address and message if desired and select OK
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
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 radio button in the Job Build Status frame and select
Save
Select DropPullSubscriptionOnPublisher in the Job list
Select the Do Not Schedule radio button and select
Save
Select DropPushSubscriptionOnPublisher in the Job list
Select the Release radio button and select
Save
Select DropPushSubscriptionOnSubscriber in the Job list
Select the Release radio button and select
Save
Automated Replication Setup
Continuous provides two schedules to use for the 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 five 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 LogReader Agent job to the SQL Server Agent on the distributor instance.
The log file is placed in the directory configured in the SQLScriptOutputDirectory scripting variable, 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 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 the SMASQLDMOApp.exe utility 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
This schedule runs every day to continuously monitor the log reader agent and distribution agent SQL Server Agent jobs. The schedule consists of 2 OpCon jobs.
MonitorDistributionAgent
The MonitorDistributionAgent job runs SMA_DBReplicationMonitorDistributionAgent.cmd. This job uses SMASQLDMOApp.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 Microsoft SQL Server Management Studio under the SQL Server Agent in the Error Logs folder.
MonitorLogReaderAgent
The MonitorLogReaderAgent job runs SMA_DBReplicationMonitorLogReaderAgent.cmd. This job uses SMASQLDMOApp.exe to monitor the LogReader Agent on the distributor server and verify that it is running continuously.
If this job fails, review the SQL Server Agent Error Logs in Microsoft SQL Server Management Studio under the SQL Server Agent in the Error Logs folder.
Building and Running the Replication Setup Schedules
After meeting all of the Prerequisites and completing the Configuration, replication can be set up 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
On any machine with an OpCon Enterprise Manager, complete the following steps:
- Log in to the Primary Database from the Enterprise Manager
- Select Schedule Build
- Select the SMAReplicationSetup schedule in the Schedule Selection frame
- Accept the default options so that the schedules will 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 the SMAReplicationMonitor schedule 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 ☒
Run the SMAReplicationSetup Schedule
Select List
Select today's date
In the tree view under the date, select the SMAReplicationSetup schedule to see the jobs
Right-click the SMAReplicationSetup schedule and select Release from the menu
Wait for all jobs to finish with a status of Finished OK. If any jobs fail, review the log files to determine the reason for failure. Fix the error then restart the failed job
After all jobs have Finished OK, review the log files for each job to ensure replication is set up correctly. Microsoft SQL Server procedures for setting up replication do not always return error codes to scripts. For information on the log files to review, see the definitions of each job within the SMAReplicationSetup Schedule Definition
Run the SMAReplicationMonitor and Configure it for Daily Monitoring
After replication is successfully set up through the SMAReplicationSetup schedule, complete the steps below to automatically monitor the replication status.
- Select the SMAReplicationMonitor schedule (in the tree view under today's date) to see the jobs
- Right-click the SMAReplicationMonitor schedule and select Release from the menu
Controlled Failover with Automation
The SMAReplicationTearDown schedule is included with the SMA Replication schedules for use in failover testing. This schedule aids customers who do testing for disaster recovery, business continuity, and failover and recovery procedures.
SMAReplicationTearDown Schedule Definition
The SMAReplicationTearDown schedule consists of 9 OpCon jobs:
- KillReplicationMonitors
- DropPullSubscriptionOnSubscriber
- DropPullSubscriptionOnPublisher
- DropPushSubscriptionOnPublisher
- DropPushSubscriptionOnSubscriber
- RemovePublisher
- RemoveDistributor
- RunDBUpdateCmdOnSecondary
- StopSMAServiceManagerOnPrimary
Once the RemoveDistributor job runs, the Replication Monitor can be checked to ensure 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 OK and then triggers the $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 OK, replication has stopped and any information 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 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 OK, replication has stopped and any information 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 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 LogReader 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 OK, replication has been 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.sql
- SMALOOKUP_Update.sql
- DBFuncs_Install.sql
- DBProcs_Install.sql
- PDSAFramework.sql
- PDSAFrameworkData.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 the SMA Service Manager will be stopped manually.
If anyone is still logged in to a graphical interface with its DSN pointing at the primary OpCon database, the StopSMAServiceManagerOnPrimary job will stay in a Job 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, replication can be disabled any time by building the SMAReplicationTearDown schedule. Complete the procedures in this section to tear down replication.
Build the SMAReplicationTearDown Schedule On Hold
On any machine with an OpCon Enterprise Manager, complete the following steps:
- Log in to the Primary Database from the Enterprise Manager
- Select Schedule Build
- Select the SMAReplicationTearDown schedule in the Schedule Selection frame
- Accept the default options so the schedules will 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 Close ☒
Run the SMAReplicationTearDown Schedule
Select List
Select today's date
In the tree view under the date, select the SMAReplicationTearDown schedule to see the jobs
Right-click the SMAReplicationTearDown schedule
Select Release from the menu
Wait for all jobs to finish with a status of Finished OK. If any jobs fail, review the log files to determine the reason for failure. Fix the error and then restart the failed job
After all jobs have Finished OK, review the log files for each job to ensure replication is disabled completely. Microsoft SQL Server procedures for disabling replication do not always return error codes to scripts. For information on the log files to review, refer to the definitions of each job within the SMAReplicationTearDown Schedule Definition
Fail Over to the Subscribing Database and Secondary SMAServMan
If the SMA Service Manager should begin processing on the secondary server, configure the 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
Use menu path: Start > Control Panel
Select Administrative Tools
Select the Services icon
Select the SMA OpCon Service Manager service
Select Automatic (Delayed Start) in the Startup type list
Select OK
Select Start to start the service and select Close ☒ on the Services window
Use menu path: Start > Programs > OpConxps > Log Monitors > Log File. To Go to the Log files
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
Recovery to the Primary Server
The SMAReplicationRecoverToPrimary is included with the SMA Replication schedules to use when transferring processing back to the primary server.
SMAReplicationRecoverToPrimary Schedule Definition
The SMAReplicationRecoverToPrimary schedule consists of 5 OpCon jobs:
- TransferFullDBBackupToPrimary
- TransferTLogBackupToPrimary
- RestoreDatabaseOnPrimary
- RunDBUpdateCmdOnPrimary
- StopSMAServiceManagerOnSecondary
TransferFullDBBackupToPrimary
The TransferFullDBBackupToPrimary job uses Continuous' File Transfer feature to move the secondary database's backup file to the primary server as a binary file.
TransferTLogBackupToPrimary
The TransferTLogBackupToPrimary job uses Continuous' File Transfer feature to move the secondary database's 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.
There are three steps to the RestoreDatabaseOnPrimary SQL job:
- Kill any database sessions that may be logged in at the time
- Restore the database
- Delete the replication stored procedures (sp_MS...) from the database
RunDBUpdateCmdOnPrimary
TheRunDBUpdateCmdOnPrimary job runs DB_Update.cmd, which runs the following SQL scripts:
- Schema_Install.sql
- SMALOOKUP_Update.sql
- DBFuncs_Install.sql
- DBProcs_Install.sql
- PDSAFramework.sql
- PDSAFrameworkData.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 the SMA Service Manager will be stopped manually.
If anyone is still logged in to a graphical interface with its DSN pointing at the primary OpCon database, the StopSMAServiceManagerOnSecondary job will stay in a Job 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, processing can be restored to the primary server any time by building the SMAReplicationRecoverToPrimary schedule. Complete the procedures in this section to recover processing to the primary server.
Build the SMAReplicationRecoverToPrimary Schedule On Hold
On any machine with an OpCon Enterprise Manager, complete the following steps:
- Log in to the Primary Database from the Enterprise Manager
- Select Schedule Build
- Select the SMAReplicationRecoverToPrimary schedule in the Schedule Selection frame
- Accept the default options so the schedules will 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 Close ☒
Run the SMAReplicationTearDown Schedule
Select List
Select today's date
Select the SMAReplicationRecoverToPrimary (in the tree view under the date) schedule to see the jobs
Right-click the SMAReplicationRecoverToPrimary schedule and select Release from the menu
Wait for all jobs to finish with a status of Finished OK. If any jobs fail, review the log files to determine the reason for failure. Fix the error and then restart the failed job
Start the SMA Service Manager on the Primary Server
After properly configuring the SMA Service Manager on the primary server, complete the following steps to start the service:
- Use menu path: Start > Control Panel
- In the Control Panel window: Select the Administrative Tools icon
- In the Administrative Tools window: Select the Services icon
- In the Services window: Scroll down to the SMA OpCon Service Manager service
- Change the SMAServMan's Startup Type to Automatic (Delayed Start) using the following steps:
- Select on SMA OpCon Service Manager
- Select Automatic (Delayed Start) in the Startup type list and select OK
- In the Services List: Select on SMA OpCon Service Manager and select Start
- Use menu path: Start > Programs > OpConxps > Log Monitors >Log File Name
- View the SMAServMan, SAM, Critical, SMANetCom, and SMANetComTrace logs to verify that the SAM and SMANetCom connected successfully to the database
Configuration Options
| Setting | What It Does | Default | Notes |
|---|
Operations
Monitoring
- After starting the SMA Service Manager on the primary server, view the SMAServMan, SAM, Critical, SMANetCom, and SMANetComTrace logs to verify SAM and SMANetCom connected successfully to the database.
- Before releasing the
SMAReplicationRecoverToPrimaryschedule, ensure all other OpCon schedules are On Hold and no jobs are running.
Common Tasks
- To recover to the primary server, release the
SMAReplicationRecoverToPrimaryschedule from the List view; wait for all jobs to finish with Finished OK status. If any jobs fail, review log files, fix the error, and restart the failed job. - Do not change the distributor_admin password manually; always use
sp_changedistributor_password, Distributor Properties, or the Update Replication Passwords dialog in SQL Server Management Studio. If changed manually, update theDistributorKeyinSMA_SetDBReplicationScriptingVariables.cmdto match. - Each replication agent (Snapshot, Log Reader, Distribution) should run under a different Windows account with Windows authentication; scripts provided by Continuous automatically grant the required database privileges, but folder share permissions must be configured manually.
Alerts and Log Files
- If any jobs in the
SMAReplicationRecoverToPrimaryschedule fail, review the relevant log files to determine the failure cause before restarting the failed job.
FAQs
Q: How many steps does the Setup for Automatic Microsoft SQL Replication procedure involve?
The Setup for Automatic Microsoft SQL Replication procedure involves 262 steps. Complete all steps in order and save your changes.
Q: What does Setup for Automatic Microsoft SQL Replication cover?
This page covers Prerequisites, Considerations, Configuration.
Glossary
JORS (Job Output Retrieval System): The system used to retrieve and display job output — logs and reports — from agent machines directly within the OpCon graphical interfaces.
DSN (Data Source Name): An ODBC connection identifier that stores database connection parameters. OpCon utilities use system DSNs to connect to the OpCon SQL Server database.
SMANetCom (SMA Network Communications Module): Handles TCP/IP communication of platform-specific automation information between SAM and all agents. Uses database tables to maintain reliable communication and data integrity.
SMAServMan (SMA Service Manager): Manages the starting, stopping, and restarting of all OpCon server programs. Monitors configured applications and restarts them automatically if they fail unexpectedly.
SAM-SS (SAM and Supporting Services): The collective term for the OpCon server-side processing programs: SAM, SMANetCom, SMA Notify Handler, SMA Request Router, and SMA Start Time Calculator.
SAM (Schedule Activity Monitor): The logical processor for OpCon workflow automation. SAM monitors schedule and job start times, dependencies, and user commands to determine job execution timing, and processes OpCon events.
LSAM (Local Schedule Activity Monitor): An agent installed on a target platform that runs jobs in the native language of that platform and communicates results back to SAM via SMANetCom over TCP/IP.
Enterprise Manager (EM): OpCon's rich client graphical user interface for Windows and Linux, used to define schedules and jobs, manage automation data, and perform operational tasks.