{"id":46,"date":"2016-06-21T19:05:39","date_gmt":"2016-06-21T23:05:39","guid":{"rendered":"http:\/\/langstonsoftware.com\/?p=46"},"modified":"2016-06-28T09:07:54","modified_gmt":"2016-06-28T13:07:54","slug":"how-i-did-it-sql-server-transactional-replication","status":"publish","type":"post","link":"https:\/\/langstonsoftware.com\/2016\/06\/21\/how-i-did-it-sql-server-transactional-replication\/","title":{"rendered":"How I did it: Sql Server Transactional Replication"},"content":{"rendered":"

Configuring SQL server replication isn’t something I do every day, so I thought I might enjoy some breadcrumbs to follow the next time I travel down this path.<\/p>\n

My client needed to have a number of tables and views replicated to a reporting server. The reporting server needed near real-time data, as small a deployment downtime window as possible, and minimal regular performance degradation. <\/p>\n

For these reasons I selected MS SQL server’s transactional replication. This would provide the near real-time data. With a few configuration choices it has a small deployment downtime window. Finally performance degradation is manageable, with few locks, and plenty of knobs to adjust to fix any issues.<\/p>\n

I had the replication components installed on sql servers during day.
\nhttps:\/\/msdn.microsoft.com\/en-us\/library\/ms143677.aspx<\/a><\/p>\n

Then I created destination database in subscribing server. I gave it the same name as the publisher so existing scripts should work without many modifications.<\/p>\n

Next I created new publication using a deprecated table. I choose the publishing server to act as the distributor. In the future, a separate server can be designated as the distributor if additional publications degrade performance. There is an option to use the SQL server agent’s security settings, but it is not recommended. I ran the snapshot immediately because I wanted to see any potential issues.
\n
https:\/\/msdn.microsoft.com\/en-us\/library\/ms151160.aspx<\/a><\/p>\n

I immediately discovered a wrinkle. The compatibility levels were not the same, since the existing database had been moved from older versions of SQL server. We could have lowered the compatibility level on the reporting server to match, but the error messages didn’t seem to indicate that would have solved the problem. Our errors were around datatypes which were not supported in older versions. For this reason, and because of the possible performance improvements with updated compatibility levels, we moved forward with updating the publisher database.<\/p>\n

In order to discover any issues with upgrading the compatibility level, we did several things. First, we tried to use SQL upgrade advisor, but could not get it to work with the already upgraded server.
\n
https:\/\/msdn.microsoft.com\/en-us\/library\/ms144256(v=sql.120).aspx<\/a>
\nSecond, we went through major issues on compatibility level checklist, spot checking the databse for potential issues.
\n
https:\/\/msdn.microsoft.com\/en-us\/library\/bb510680.aspx<\/a>
\nFinally, we updated compatibility level in test environment. After several hours of running at the new compatibility level, we then updated the compatibility level in production after hours.<\/p>\n

Returning to replication, we created a new subscription on the reporting server.
\n
https:\/\/msdn.microsoft.com\/en-us\/library\/ms152566.aspx<\/a>
\nWe exclusively chose push subscriptions because of reported lock behavior.
\n
http:\/\/dba.stackexchange.com\/questions\/73629\/how-to-generate-replication-snapshot-without-locking-tables<\/a>
\nPull subscription reduces demand on publisher, so we’ll switch to using it later if performance requirements demand.<\/p>\n

A linked server had to be added on the reporting server for a view, since all the components of a view must be available for replication to occur.<\/p>\n

After all of these changes, the replication monitor showed success, the event viewer showed no additional errors, and the databases were populated on the reporting server.<\/p>\n

Even after all the compatibility level checks, we still encountered timeout issues later that week that appeared to be compatibility level related. New indexes had to be created to alleviate these issues. Also, additional tables have been identified that will have to replicated for reporting, which should also continue to reduce load on the server.<\/p>\n

If you have any additions, thoughts, or comments about SQL replication or updating compatibility levels, please add them below. I’d love to hear from you.<\/p>\n","protected":false},"excerpt":{"rendered":"

Configuring SQL server replication isn’t something I do every day, so I thought I might enjoy some breadcrumbs to follow the next time I travel down this path. My client needed to have a number of tables and views replicated to a reporting server. The reporting server needed near real-time data, as small a deployment …<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"nf_dc_page":"","jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","enabled":false},"version":2}},"categories":[4],"tags":[5],"class_list":["post-46","post","type-post","status-publish","format-standard","hentry","category-sql","tag-after-action-report"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p6Os38-K","_links":{"self":[{"href":"https:\/\/langstonsoftware.com\/wp-json\/wp\/v2\/posts\/46"}],"collection":[{"href":"https:\/\/langstonsoftware.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/langstonsoftware.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/langstonsoftware.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/langstonsoftware.com\/wp-json\/wp\/v2\/comments?post=46"}],"version-history":[{"count":7,"href":"https:\/\/langstonsoftware.com\/wp-json\/wp\/v2\/posts\/46\/revisions"}],"predecessor-version":[{"id":53,"href":"https:\/\/langstonsoftware.com\/wp-json\/wp\/v2\/posts\/46\/revisions\/53"}],"wp:attachment":[{"href":"https:\/\/langstonsoftware.com\/wp-json\/wp\/v2\/media?parent=46"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/langstonsoftware.com\/wp-json\/wp\/v2\/categories?post=46"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/langstonsoftware.com\/wp-json\/wp\/v2\/tags?post=46"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}