Microsoft SQL Replication v1 28-January-2016 Revision: Release
Publication Information 2016 Imagine Communications Corp. Proprietary and Confidential. Imagine Communications considers this document and its contents to be proprietary and confidential. Except for making a reasonable number of copies for your own internal use, you may not reproduce this publication, or any part thereof, in any form, by any method, for any purpose, or in any language other than English without the written consent of Imagine Communications. All others uses are illegal. This publication is designed to assist in the use of the product as it exists on the date of publication of this manual, and may not reflect the product at the current time or an unknown time in the future. This publication does not in any way warrant description accuracy or guarantee the use for the product to which it refers. Imagine Communications reserves the right, without notice to make such changes in equipment, design, specifications, components, or documentation as progress may warrant to improve the performance of the product. Trademarks Product names and other brands (such as ADC, D-Series, Nexio, Nexio Insight, Nexio Motion, PowerSmart, Versio ) are trademarks or trade names of Imagine Communications or its subsidiaries. Microsoft and Windows are registered trademarks of Microsoft Corporation. All other trademarks and trade names are the property of their respective companies. Contact Information Imagine Communications has office locations around the world. For domestic and international location and contact information, visit our Contact page (http://www.imaginecommunications.com/company/contact-us.aspx). Support Contact Information For domestic and international support contact information see: Support Contacts (http://www.imaginecommunications.com/how-buy/contact-us) Worldwide Support e-mail (mailto: service@imaginecommunications.com) Customer Community Portal (http://app.imaginecommunications.com/customercommunity) Warranty & Contract Information (http://www.imaginecommunications.com/services/customercare) Academy Training (http://www.imaginecommunicationsacademy.com) Product Manuals (http://www.imaginecommunications.com/services/product-manuals) 2016 Imagine Communications Corp. Proprietary and Confidential 28-January-2016 Page 2 of 35
Contents Contents Introduction... 4 About this Document... 4 Installing Replication... 5 Replication Feature... 5 Publisher, Subscriber and a Distributor... 7 Windows accounts needed for Replication... 7 Preparing the Snapshot Folder... 8 To create a share for the snapshot folder and assign permissions... 8... 11 Configuring distribution at the Publisher... 11 Setting database permissions at the Publisher... 15 To create a publication database... 17 Setting database permissions at the Subscriber... 24 To create the subscription... 26 Backups & Recovery... 34 Bringing the Backup FileServer online... 34 Managing Client Disconnects... 34 Recovery Process... 34 Manual switch over (scheduled maintenance) procedure... 35 2016 Imagine Communications Corp. Proprietary and Confidential 28-January-2016 Page 3 of 35
Introduction Introduction About this Document This guide provides one Redundancy method for the ADC database, called Replication. This method copies and distributes data and database objects from one database to another and synchronizes between databases to maintain consistency. It allows 2-way mirroring of data added, deleted, or modified in any of the two SQL Servers. Since this is SQL-specific functionality, it does not provide redundancy for other files stored on the File Servers, such as As-run Logs, List Files, Error Logs, etc. ADC clients can be connected to any of the two SQL instances. In this configuration, if any of the File Servers go offline, those clients connected to the online File Server continue normal operations while the clients connected to the offline File Server are re-configured to access the online database and the offending offline File Server is repaired. Testing of this functionality was done using Windows Server 2012, SQL Server Standard 2014 and ADC Clients 4.25. An IMPORTANT NOTE Regarding SQL EXPRESS: According to Microsoft, in a Redundancy configuration SQL Server Express cannot serve as a Publisher or Distributor, but it can serve as a Subscriber. (This has not yet been tested in the Imagine Communications lab.) 2016 Imagine Communications Corp. Proprietary and Confidential 28-January-2016 Page 4 of 35
Installing Replication Installing Replication Replication Feature The Replication Feature must be installed on all SQL Servers that will be subscribing to the Replication service. 1. When installing SQL Server 2014 (either a new installation or adding the Replication feature), select setup.exe, select New SQL Server stand-alone installation or add features to an existing installation. 2. (Option) If this feature is being added to an existing SQL server, on the Installation Type screen, select the Add features to an existing instance of SQL Server 2014 radio button. 3. On the Feature Selection screen under Database Engine Services, select SQL Server Replication. 2016 Imagine Communications Corp. Proprietary and Confidential 28-January-2016 Page 5 of 35
Installing Replication 4. Select the Next button and wait until the Ready to Install screen displays. 5. Select the Install button and wait while the install progresses. 2016 Imagine Communications Corp. Proprietary and Confidential 28-January-2016 Page 6 of 35
Installing Replication 6. On the Install Complete screen select the Close button. Publisher, Subscriber and a Distributor Microsoft SQL server replication uses a Publisher, Subscriber and a Distributor: Publisher is the server or database that sends its data to another server or database. Subscriber is the server or database that receives data from another server or database. Distributor is an intermediary between publisher and subscriber. Receives published transactions or snapshots and then stores and forwards these publications to the subscriber. Windows accounts needed for Replication The following accounts are required for Replication. Create local Windows accounts for replication agents on the server hosting the Publisher database. 1. Open Computer Management. 2. Expand Local Users and Groups. 3. Right-click Users and then click New User. 4. Enter repl_snapshot in the User name box, provide the password and other relevant information, and then click Create to create the repl_snapshot account. 5. Repeat the previous step to create the repl_logreader, repl_distribution, and repl_merge accounts. Note: Users do not need to be added to the Administrators group. 6. Click Close. 2016 Imagine Communications Corp. Proprietary and Confidential 28-January-2016 Page 7 of 35
Installing Replication Create local Windows accounts for replication agents on the server hosting the Subscriber database. 1. Open Computer Management. 2. Expand Local Users and Groups. 3. Right-click Users and then click New User. 4. Enter repl_distribution in the User name box, provide the password and other relevant information, and then click Create to create the repl_distribution account. 5. Repeat the previous step to create the repl_merge account. Note: Users do not need to be added to the Administrators group. 6. Click Close. Preparing the Snapshot Folder The snapshot folder is used to create and store the publication snapshot. Note: The Snapshot folder is only created on the Publisher server. To create a share for the snapshot folder and assign permissions 1. In Windows Explorer, navigate to the SQL Server data folder. The default location is C:\Program Files\Microsoft SQL Server\MSSQL.X\MSSQL\Data. 2. Create a new folder named repldata. 3. Right-click this folder and click Properties. 4. On the Sharing tab in the repldata Properties dialog box, click Advanced Sharing. 5. In the Advanced Sharing dialog box, click Share this folder, and then click Apply, OK. 2016 Imagine Communications Corp. Proprietary and Confidential 28-January-2016 Page 8 of 35
Installing Replication 6. On the Security tab, click Edit. 7. In the Permissions dialog box, click Add. In the Select User, Computers, Service Account, or Groups text box, type the name of the Snapshot Agent account created previously, as <Machine_Name>\repl_snapshot, where <Machine_Name> is the name of the Publisher. Click Check Names, and then click OK. 2016 Imagine Communications Corp. Proprietary and Confidential 28-January-2016 Page 9 of 35
Installing Replication 8. Under Permissions for repl_snapshot, select Allow for the Full Control permission. 9. Repeat the previous step to add permissions for the Distribution Agent, as <Machine_Name>\repl_distribution, and for the Merge Agent as <Machine_Name>\repl_merge with Read permissions. 2016 Imagine Communications Corp. Proprietary and Confidential 28-January-2016 Page 10 of 35
Configure distribution at the Publisher and set the required permissions on the publication and distribution databases. Configuring distribution at the Publisher 1. Connect to the Publisher in SQL Server Management Studio, and then expand the server node. 2. Right-click the Replication folder and click Configure Distribution. 3. The Distribution Configuration Wizard launches. 4. On the Distributor page, select '<ServerName>' will act as its own Distributor; SQL Server will create a distribution database and log, and then click Next. Note: The distributor database can be installed on another SQL server instance if desired. 2016 Imagine Communications Corp. Proprietary and Confidential 28-January-2016 Page 11 of 35
5. If the SQL Server is not running, on the SQL Server Agent Start page, select Yes, configure the SQL Server Agent service to start automatically. Click Next. 6. Enter \\<Machine_Name>\repldata in the Snapshot folder text box, where <Machine_Name> is the name of the Publisher, and then click Next. 2016 Imagine Communications Corp. Proprietary and Confidential 28-January-2016 Page 12 of 35
7. Accept the default values on the remaining pages of the wizard. Click Next on each page. 2016 Imagine Communications Corp. Proprietary and Confidential 28-January-2016 Page 13 of 35
8. Click Finish to enable distribution. 9. When Configuration Wizard finishes select the Close button 2016 Imagine Communications Corp. Proprietary and Confidential 28-January-2016 Page 14 of 35
Setting database permissions at the Publisher 1. In SQL Server Management Studio, expand Security, right-click Logins, and then select New Login. 2. On the General page, click Search, enter <Machine_Name>\repl_snapshot in the Enter the object name to select box, where <Machine_Name> is the name of the local Publisher server, click Check Names, and then click OK. 2016 Imagine Communications Corp. Proprietary and Confidential 28-January-2016 Page 15 of 35
3. On the User Mapping page, in the Users mapped to this login list select both the distribution database and the database that will be the Publisher databases. In the Database role membership list select the db_owner role for the login for both databases. 2016 Imagine Communications Corp. Proprietary and Confidential 28-January-2016 Page 16 of 35
4. Click OK to create the login. 5. Repeat steps 1-4 to create a login for the local repl_logreader account. This login must also be mapped to users that are members of the db_owner fixed database role in the distribution and the Publisher databases. 6. Repeat steps 1-4 to create a login for the local repl_distribution account. This login must be mapped to a user that is a member of the db_owner fixed database role in the distribution database. 7. Repeat steps 1-4 to create a login for the local repl_merge account. This login must have user mappings in the distribution and the Publisher databases. To create a publication database 1. Connect to the Publisher in Microsoft SQL Server Management Studio, and then expand the server node. 2. Expand the Replication folder, and then right-click the Local Publications folder. 2016 Imagine Communications Corp. Proprietary and Confidential 28-January-2016 Page 17 of 35
3. Click New Publication. 4. Follow the pages in the New Publication Wizard to: a. Choose a publication database. 2016 Imagine Communications Corp. Proprietary and Confidential 28-January-2016 Page 18 of 35
b. Select a publication type. c. Select Subscriber Types 2016 Imagine Communications Corp. Proprietary and Confidential 28-January-2016 Page 19 of 35
d. Specify data and database objects to publish. e. Click Next on the Articles issues screen. 2016 Imagine Communications Corp. Proprietary and Confidential 28-January-2016 Page 20 of 35
f. Click Next on the Filter Tables Rows 2016 Imagine Communications Corp. Proprietary and Confidential 28-January-2016 Page 21 of 35
g. Set the Snapshot Agent h. Specify the credentials under which the snapshot agent runs and make connections: 2016 Imagine Communications Corp. Proprietary and Confidential 28-January-2016 Page 22 of 35
i. Specify a name for the publication. Select Finish 5. The following screen will display. 2016 Imagine Communications Corp. Proprietary and Confidential 28-January-2016 Page 23 of 35
6. When finished the new publication database will display under Local Publications Setting database permissions at the Subscriber 1. Connect to the Subscriber in SQL Server Management Studio, expand Security, right-click Logins, and then select New Login. 2016 Imagine Communications Corp. Proprietary and Confidential 28-January-2016 Page 24 of 35
2. On the General page, enter <Machine_Name>\repl_merge in the User name box, click the ellipsis ( ) button, click Browse, select <Machine_Name>\repl_merge, click OK, click Check Names, and then click OK. 3. In Database role membership, select db_owner for the database that will be the subscribing database, and then click OK to create the user. 2016 Imagine Communications Corp. Proprietary and Confidential 28-January-2016 Page 25 of 35
To create the subscription Merge replication offers two subscription types: server and client. Subscribers with a server subscription can: Republish data to other Subscribers. Serve as alternate synchronization partners. Resolve conflicts according to a priority you set. Most Subscribers do not require this functionality and can use a client subscription. Client subscriptions still allow conflict detection and resolution, but Subscribers are not assigned a priority: the first Subscriber to submit a change to the Publisher wins any conflicts that might arise from that change. In this set up, the Client Subscription type is selected. IMPORTANT: After a subscription is created, it cannot be changed from one type to another. 1. Connect to the Subscriber in SQL Server Management Studio, expand the server node, expand the Replication folder, right-click the Local Subscriptions folder, and then click New Subscriptions. 2016 Imagine Communications Corp. Proprietary and Confidential 28-January-2016 Page 26 of 35
2. The New Subscription Wizard launches. 3. On the Publication page, click Find SQL Server Publisher in the Publisher list. 2016 Imagine Communications Corp. Proprietary and Confidential 28-January-2016 Page 27 of 35
4. In the Connect to Server dialog box, enter the name of the server hosting the publication database, and click Connect. 5. Click the Publication database, and click Next. 2016 Imagine Communications Corp. Proprietary and Confidential 28-January-2016 Page 28 of 35
6. On the Merge Agent Location page, click Run each agent at its Subscriber, and then click Next. 7. On the Subscribers page, select the instance name of the Subscriber server, and under Subscription Database, select the database that will be subscribing to the publication from the list. 2016 Imagine Communications Corp. Proprietary and Confidential 28-January-2016 Page 29 of 35
8. On the Merge Agent Security page, click the ellipsis ( ) button, enter <Machine_Name>\repl_merge in the Process account box, supply the password for this account, click OK, click Next, and then click Next again. 9. On the Synchronization Schedule page, select Run Continuously from the Agent Schedule list, click Next, and then click Next again. 2016 Imagine Communications Corp. Proprietary and Confidential 28-January-2016 Page 30 of 35
10. On the Initialize Subscriptions page, select Immediately from the Initialize When list, click Next, and then click Next again. 2016 Imagine Communications Corp. Proprietary and Confidential 28-January-2016 Page 31 of 35
11. On the Subscription Type page, select Client in the Subscription Type Value box, and then click Next. 12. On the Wizard Actions page, select the Create the subscription(s) box. Click Next. 2016 Imagine Communications Corp. Proprietary and Confidential 28-January-2016 Page 32 of 35
13. On the Complete the Wizard page, review the choices and click Finish. 14. On the Creating Subscriptions page, wait for the Success status on both Creating subscription and +Starting the Snapshot Agent actions. When success is reported for both, click Close. 2016 Imagine Communications Corp. Proprietary and Confidential 28-January-2016 Page 33 of 35
Backups & Recovery Backups & Recovery Bringing the Backup FileServer online Merge replication continually runs. A synchronization agent runs and updates the backup fileserver. When adds, changes, deletions are applied to the main fileserver, those are written to the distribution database and then synched with the backup fileserver and vice versa. Managing Client Disconnects Client disconnects don t really have an effect on replication. However, if a client is disconnected from SQL server for any reason, following are steps taken for client disconnects: If clients are disconnected from the main fileserver s database (SQL Service down), Media client goes into an unresponsive state and eventually, a database error displays 'SDBC_E _Wrong_Connection state'. 1. Close and reopen the client in order to create a new connection after the service is started again. If Media Client is ingesting content and the SQL service is stopped, the recording finishes, but it is not written to the DB. The 'Not in DB', next to the Status field is still red. The client does not display any error. After a bit, the message SQL Server is unable to connect to server 'FileserverX' displays. 1. After the SQL service is started, select the Write to DB option. The Error message SDBC_E_Wrong_Connection_State (Error #220) displays. 2. Close and reopen the client to initiate a new connection. 3. Ingest will need to be done again. Air Client eventually goes into an unresponsive state with the error message Error 17, Message ODBC SQL Server Driver Shared Memory SQL Server does not exist or access denied. 1. Select OK to that message and then the message Could not open database C:\AClient\error SDBC_ESql_Connect (Error #102). 2. After the SQL service is back up and running, close and reopen the client to establish the SQL connection. Recovery Process When the Main is repaired and brought back online, system recovery and synchronization is automatic. With merge replication a new column (the rowguid column) is created in all the database tables that are being replicated on both the publisher and on the subscriber(s). If a database is off line and then brought back up, this column is compared. If any of the databases are missing a rowguid that one of the other databases has, it will be synchronized (replicated) to the database that was missing the data. 2016 Imagine Communications Corp. Proprietary and Confidential 28-January-2016 Page 34 of 35
Backups & Recovery Manual switch over (scheduled maintenance) procedure There is no coordination for an automatic failover or failback. It is a manual process to switch the connection between servers. 1. Change the client s ODBC connection to the subscriber database from the publication database. 2. Turn off SQL services to the main database. 3. Do required maintenance. 4. Turn on the SQL services on the publication database. The ingested data will be replicated back up to the publication database. 5. After the replication is completed, change the ODBC connection back to the publication database. 2016 Imagine Communications Corp. Proprietary and Confidential 28-January-2016 Page 35 of 35