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